Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp758087pxk; Wed, 9 Sep 2020 19:20:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxA4XxfIzlQf6X3elExXs75qJVXokT4zo9tmVtf+i4rpzYPmviRjCJZf2Hk5epgWLOsxxms X-Received: by 2002:a17:906:60d5:: with SMTP id f21mr6536373ejk.94.1599704409451; Wed, 09 Sep 2020 19:20:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599704409; cv=none; d=google.com; s=arc-20160816; b=lNHc4c87aWfspyHQDZ8p35o3bS47LLr0zuQRL+EsJs2abItgr9W2sldeRpuV+VnXL5 44Pc0PkQzwyd4NLzFZszdP07qo04scNTzG6jnF+OBqwV3X/zTryar9boBvNacwnedm63 xBt5Q6bBXQpvNdw/1zUjotFv9dT3IetXMNPQ1BQv/8vmcjRt1aWc0TYhFk7oUlDRRvs7 cV4GKE1mptRu0gsGtso6Ul1cB+Nejd+ZlhuClHCInrc4dEbMgaWedQECHKPxKPW3nRhd XSiz9OY16vRFA8is/88RNFypPQ1wiwpiLcVApRC+EdwGf0x+qqhmUiQ3/Wi9CcpSvQQn FUiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:ironport-sdr:ironport-sdr; bh=OepgvYcimGQqFutGVi9+v4Ad+EeZjodYqkHsOBpnYG8=; b=mdBmCe9gRIC1tkrUMDXuRRSztCQrgegSLxs3v2oL3dzVySUKPkwc5kmoCfpIgn0A+O pjQM3H6/Qec0dD946Pw1GNYkJOfvs/lEYocU3b4D24B4L2gMn4jn9kLR/FL2DfIzdyau G3fwysVnY005bn2XNEcJTbW4cFQPbX0Z2qrpINcPN8SNJ6qgH2+R4umEnSOTYL0EuKFC 1vlqR2u/e42bSMAYgIJwsU7RE8aBL3OgYDbnaJmtpE47OfY5P9I3Q+MH8VjmaZTvVrcq lavHYpJxJotSsqWfxGPQdTvZ5TMKLH2gqUXdVSTT/kBjrXO/poGdI2PsfDGY9slKja1H 8D3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q24si2476435eja.493.2020.09.09.19.19.46; Wed, 09 Sep 2020 19:20:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730817AbgIJCTJ (ORCPT + 99 others); Wed, 9 Sep 2020 22:19:09 -0400 Received: from mga04.intel.com ([192.55.52.120]:22269 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730412AbgIJCNa (ORCPT ); Wed, 9 Sep 2020 22:13:30 -0400 IronPort-SDR: tg7JqTb3yYaey4qBcGFO8DDf2wpoAnFGcY6tCHl65BqL3AGXEmQSTGSLvipg33+DQGiAafOpet uad7GWg0mXsw== X-IronPort-AV: E=McAfee;i="6000,8403,9739"; a="155833449" X-IronPort-AV: E=Sophos;i="5.76,410,1592895600"; d="scan'208";a="155833449" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Sep 2020 16:25:20 -0700 IronPort-SDR: 97ngTUD1zf87z1J3aBsa0H7mLbs6F9XUx1PagpQMhF0Zgnk57KKBy1hAnm4cgbBt1RMBPolWPy 18nZ0L9a9LoQ== X-IronPort-AV: E=Sophos;i="5.76,410,1592895600"; d="scan'208";a="329101836" Received: from yyu32-mobl1.amr.corp.intel.com (HELO [10.212.243.130]) ([10.212.243.130]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Sep 2020 16:25:18 -0700 Subject: Re: [PATCH v11 25/25] x86/cet/shstk: Add arch_prctl functions for shadow stack To: Dave Hansen , Andy Lutomirski Cc: Dave Martin , "H.J. Lu" , Florian Weimer , X86 ML , "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , LKML , "open list:DOCUMENTATION" , Linux-MM , linux-arch , Linux API , Arnd Bergmann , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Weijiang Yang References: <086c73d8-9b06-f074-e315-9964eb666db9@intel.com> <20200826164604.GW6642@arm.com> <87ft892vvf.fsf@oldenburg2.str.redhat.com> <0e9996bc-4c1b-cc99-9616-c721b546f857@intel.com> <4f2dfefc-b55e-bf73-f254-7d95f9c67e5c@intel.com> <20200901102758.GY6642@arm.com> <32005d57-e51a-7c7f-4e86-612c2ff067f3@intel.com> <46dffdfd-92f8-0f05-6164-945f217b0958@intel.com> <6e1e22a5-1b7f-2783-351e-c8ed2d4893b8@intel.com> <5979c58d-a6e3-d14d-df92-72cdeb97298d@intel.com> <08c91835-8486-9da5-a7d1-75e716fc5d36@intel.com> From: "Yu, Yu-cheng" Message-ID: Date: Wed, 9 Sep 2020 16:25:16 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/9/2020 4:11 PM, Dave Hansen wrote: > On 9/9/20 4:07 PM, Yu, Yu-cheng wrote: >> What if a writable mapping is passed to madvise(MADV_SHSTK)?  Should >> that be rejected? > > It doesn't matter to me. Even if it's readable, it _stops_ being even > directly readable after it's a shadow stack, right? I don't think > writes are special in any way. If anything, we *want* it to be writable > because that indicates that it can be written to, and we will want to > write to it soon. > But in a PROT_WRITE mapping, all the pte's have _PAGE_BIT_RW set. To change them to shadow stack, we need to clear that bit from the pte's. That will be like mprotect_fixup()/change_protection_range().