From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0D49C43461 for ; Tue, 8 Sep 2020 18:25:29 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 37B182080A for ; Tue, 8 Sep 2020 18:25:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 37B182080A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5D68C6B0037; Tue, 8 Sep 2020 14:25:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5864A8E0001; Tue, 8 Sep 2020 14:25:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4C32E6B005C; Tue, 8 Sep 2020 14:25:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0171.hostedemail.com [216.40.44.171]) by kanga.kvack.org (Postfix) with ESMTP id 39DD96B0037 for ; Tue, 8 Sep 2020 14:25:28 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 21AD18248047 for ; Tue, 8 Sep 2020 18:25:27 +0000 (UTC) X-FDA: 77240721894.13.sleep74_3605a17270d6 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id F392018140B7C for ; Tue, 8 Sep 2020 18:25:26 +0000 (UTC) X-HE-Tag: sleep74_3605a17270d6 X-Filterd-Recvd-Size: 5026 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Tue, 8 Sep 2020 18:25:25 +0000 (UTC) IronPort-SDR: 3vjKTvA1jy72f6Kz5Yn4VrK5WewEYGkO7HhOnqnO5jxjfSNPGKZWzpwo/Mfkr7g5uadntQejsc xpVhOb6ZOLhA== X-IronPort-AV: E=McAfee;i="6000,8403,9738"; a="138245480" X-IronPort-AV: E=Sophos;i="5.76,406,1592895600"; d="scan'208";a="138245480" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2020 11:25:23 -0700 IronPort-SDR: bTS1USQJwqhUAqTZ1mXCWmgKPD1f8ak2tiuGhfZUz3y/kZrFWzwSTM0whGUwwHvZRrXPondA26 9gLrCKJRf3PA== X-IronPort-AV: E=Sophos;i="5.76,406,1592895600"; d="scan'208";a="448891489" Received: from yyu32-mobl1.amr.corp.intel.com (HELO [10.209.111.239]) ([10.209.111.239]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2020 11:25:21 -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> <73c2211f-8811-2d9f-1930-1c5035e6129c@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> From: "Yu, Yu-cheng" Message-ID: <6e1e22a5-1b7f-2783-351e-c8ed2d4893b8@intel.com> Date: Tue, 8 Sep 2020 11:25:20 -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 X-Rspamd-Queue-Id: F392018140B7C X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 9/8/2020 10:57 AM, Dave Hansen wrote: > On 9/8/20 10:50 AM, Yu, Yu-cheng wrote: >> What about this: >> >> - Do not add any new syscall or arch_prctl for creating a new shadow s= tack. >> >> - Add a new arch_prctl that can turn an anonymous mapping to a shadow >> stack mapping. >> >> This allows the application to do whatever is necessary.=C2=A0 It can = even >> allow GDB or JIT code to create or fix a call stack. >=20 > Fine with me. But, it's going to effectively be >=20 > arch_prctl(PR_CONVERT_TO_SHS..., addr, len); >=20 > when it could just as easily be: >=20 > madvise(addr, len, MADV_SHSTK...); >=20 > Or a new syscall. The only question in my mind is whether we want to d= o > something generic that we can use for other similar things in the > future, like: >=20 > madvise2(addr, len, flags, MADV2_SHSTK...); >=20 > I don't really feel strongly about it, though. Could you please share > your logic on why you want a prctl() as opposed to a whole new syscall? >=20 A new syscall is more intrusive, I think. When creating a new shadow=20 stack, the kernel also installs a restore token on the top of the new=20 shadow stack, and it is somewhat x86-specific. So far no other arch's=20 need this. Yes, madvise is better if the kernel only needs to change the mapping.=20 The application itself can create the restore token before calling=20 madvise().