Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1936136pxk; Tue, 1 Sep 2020 11:14:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdPGiE+tOZzQHpKXQ1ln803qVK4BrgLvLe3Bc79EPe75d+zIdPiujf1GANymJ4JZlIM16j X-Received: by 2002:a17:906:5f8f:: with SMTP id a15mr2869241eju.291.1598984088329; Tue, 01 Sep 2020 11:14:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598984088; cv=none; d=google.com; s=arc-20160816; b=zxdtfmGeeoH4KrK7hLr/eQuT0YLRhF8QdHKNGucAMLIIf4+RCdiMiqncY83x1e2oz1 ZTLGYd2IXlI9fe9YLFDqkrpihM+oH76JPzHjWlC7QiP4DG5avmA4R1Se/l2XvmglpA2C FWV0aA6PFQx7bkyvu8bEo+0blN++4B8SkRc+AuYOwTlGLb5hN4NAjv6zNObRd2LWyAl+ /J+e8wu1YyCf5caqvqM6GjNH0gg1GoxGMPGQssjQzdYkb0KW0aZM4z4MJAwvW+1jab6F 1TFo2evW85FE1w5krd+pYOdKES2bUjLnhapjQ6V/4ktOvWr1HgPgDI/Du68sl/3SaUGV 8yXA== 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:autocrypt:from:references:cc:to:subject:ironport-sdr :ironport-sdr; bh=cIXcH7+9suAe/aXCqwb3cpBnAvIOA8ImeChA6uKof7c=; b=0bKrKrzHqYLKZUt8Oje+3YEFYjYrNZb8yVSA+90s7W3nluzf5E2j0LOosT3LIDEy5U +QfbTQaF5oOt0NHJzyddEpBUrX+mNQ57r4rM705KR6B7HR3B47TF9vwsAF6Cu13c+Ob1 tGkvsdJ3IPONQXYdcjeJa9Mylq3KMgPIuyLPVNmugtfTViXPJeL+GjiKz9QBQeJ6o1LA MITKIXtkzNboxB/tSF4otNCr3xqC/Mfwz1m143lUinb98eOYpydmLXkXB6DhdD33D3EF BxW60SwFIjN3IVs2+jI3MfBYTZ9bvoU3e+vVUGQS02MLQngP0OdXoeKpp6QNUoJtqL9h ElAA== 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 u16si1056699ejn.165.2020.09.01.11.14.23; Tue, 01 Sep 2020 11:14:48 -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 S1729754AbgIASLn (ORCPT + 99 others); Tue, 1 Sep 2020 14:11:43 -0400 Received: from mga11.intel.com ([192.55.52.93]:64009 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726377AbgIASLl (ORCPT ); Tue, 1 Sep 2020 14:11:41 -0400 IronPort-SDR: pyb1UTA7YQrED807E2mO0Oj962rUapGJYQ2yC67d6yAUs4F+1zuiifAu2dQHYA00xIKKjo34T3 1rzmp2Db3NZQ== X-IronPort-AV: E=McAfee;i="6000,8403,9731"; a="154751471" X-IronPort-AV: E=Sophos;i="5.76,379,1592895600"; d="scan'208";a="154751471" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2020 11:11:39 -0700 IronPort-SDR: U9Za4Fsprnn24UWgzswsDS3jgMDfq4GjY2CkedkkCRDY31krR7oOGKyx9lKCG8Pc9lJkNVr+uQ OXMdfSgp5/bw== X-IronPort-AV: E=Sophos;i="5.76,379,1592895600"; d="scan'208";a="301533104" Received: from jcervan1-mobl1.amr.corp.intel.com (HELO [10.212.146.17]) ([10.212.146.17]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Sep 2020 11:11:38 -0700 Subject: Re: [PATCH v11 25/25] x86/cet/shstk: Add arch_prctl functions for shadow stack To: Andy Lutomirski , "Yu, Yu-cheng" 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> From: Dave Hansen Autocrypt: addr=dave.hansen@intel.com; keydata= xsFNBE6HMP0BEADIMA3XYkQfF3dwHlj58Yjsc4E5y5G67cfbt8dvaUq2fx1lR0K9h1bOI6fC oAiUXvGAOxPDsB/P6UEOISPpLl5IuYsSwAeZGkdQ5g6m1xq7AlDJQZddhr/1DC/nMVa/2BoY 2UnKuZuSBu7lgOE193+7Uks3416N2hTkyKUSNkduyoZ9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Ymsp8kXKMk9GSfmZpuMQB9c6io1qZc6nW/3TtvK pNGz7KPPtaDzvKA4S5tfrWPnDr7n15AU5vsIZvgMjU42gkbemkjJwP0B1RkifIK60yQqAAlT YZ14P0dIPdIPIlfEPiAWcg5BtLQU4Wg3cNQdpWrCJ1E3m/RIlXy/2Y3YOVVohfSy+4kvvYU3 lXUdPb04UPw4VWwjcVZPg7cgR7Izion61bGHqVqURgSALt2yvHl7cr68NYoFkzbNsGsye9ft M9ozM23JSgMkRylPSXTeh5JIK9pz2+etco3AfLCKtaRVysjvpysukmWMTrx8QnI5Nn5MOlJj 1Ov4/50JY9pXzgIDVSrgy6LYSMc4vKZ3QfCY7ipLRORyalFDF3j5AGCMRENJjHPD6O7bl3Xo 4DzMID+8eucbXxKiNEbs21IqBZbbKdY1GkcEGTE7AnkA3Y6YB7I/j9mQ3hCgm5muJuhM/2Fr OPsw5tV/LmQ5GXH0JQ/TZXWygyRFyyI2FqNTx4WHqUn3yFj8rwTAU1tluRUYyeLy0ayUlKBH ybj0N71vWO936MqP6haFERzuPAIpxj2ezwu0xb1GjTk4ynna6h5GjnKgdfOWoRtoWndMZxbA z5cecg== Message-ID: <32005d57-e51a-7c7f-4e86-612c2ff067f3@intel.com> Date: Tue, 1 Sep 2020 11:11:37 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 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/1/20 10:45 AM, Andy Lutomirski wrote: >>> For arm64 (and sparc etc.) we continue to use the regular mmap/mprotect >>> family of calls. One or two additional arch-specific mmap flags are >>> sufficient for now. >>> >>> Is x86 definitely not going to fit within those calls? >> That can work for x86. Andy, what if we create PROT_SHSTK, which can >> been seen only from the user. Once in kernel, it is translated to >> VM_SHSTK. One question for mremap/mprotect is, do we allow a normal >> data area to become shadow stack? > I'm unconvinced that we want to use a somewhat precious PROT_ or VM_ > bit for this. Using a flag bit makes sense if we expect anyone to > ever map an fd or similar as a shadow stack, but that seems a bit odd > in the first place. To me, it seems more logical for a shadow stack > to be a special sort of mapping with a special vm_ops, not a normal > mapping with a special flag set. Although I realize that we want > shadow stacks to work like anonymous memory with respect to fork(). > Dave? I actually don't like the idea of *creating* mappings much. I think the pkey model has worked out pretty well where we separate creating the mapping from doing something *to* it, like changing protections. For instance, it would be nice if we could preserve things like using hugetlbfs or heck even doing KSM for shadow stacks. If we're *creating* mappings, we've pretty much ruled out things like hugetlbfs. Something like mprotect_shstk() would allow an implementation today that only works on anonymous memory *and* sets up a special vm_ops. But, the same exact ABI could do wonky stuff in the future if we decided we wanted to do shadow stacks on DAX or hugetlbfs or whatever. I don't really like the idea of PROT_SHSTK those are plumbed into a bunch of interfaces. But, I also can't deny that it seems to be working fine for the arm64 folks.