Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp880373ybi; Thu, 30 May 2019 08:09:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqzCWm5d0GBRzqu37Ak87fh7XT6ifJN2xUbYntBuNwKiayyWh0FIkSHZMMbvQGBSOuUN57O4 X-Received: by 2002:a63:2c4a:: with SMTP id s71mr4138493pgs.343.1559228949780; Thu, 30 May 2019 08:09:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559228949; cv=none; d=google.com; s=arc-20160816; b=Fwm78+8parFJoa6zcqB+DmhH70mazGtlKi0g75Uk998k33fkzB+GRD/DH3dHTM+lZ9 Yvy5/4qSi45Q6TZRzhZpIYC2nJiIaeeRpZF2PEUO8y1DBYJwMuhMXyHCxhaZ+VN96Z+u ioFf/wP8X4Bt7O4YKKcWbTVVO6NKZhi5QC517WXIQdfshuPeDGXdcxpvypsU1j5er9+j PFbs6VT1ppj7nkwAadGS8T8j7KZmCAtII5zy12HfoqfXtROFAho0kTlS0rW1mwBCbzNH 2YQCRfuz6BolwXVqY89tBzZRNY/RVoMe57pbdR7sdD1DJ/J4KO0WwdRg3OLaJQ5BGARl u1Qg== 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-phdr :dkim-signature; bh=Gx/Na3NMPNgR6X0ozLsN6rip3MeDz+5aRP/AalAyVLs=; b=e53//lHpfqz7Rr8Awb6SI42EY2/Ubv2XrN0uGWDUe/yA66S0iUjhJCPJyxs7Vwx1D7 AFDxvq4cFFNrL1EjKdx2idAbLo6r/D+ksu2CGYFzsT0qj215kYXRINQN/FP1us2Y13KX aTMbcn2F0ailw+OT6u2eckxYIMixdxmh0ejzr1nF17PVCv73GzKASonnU8EIM3mo8SaC d3WXwAsK1k4vxcdbUrEd0cV2D087BGn/mEcAHqsTHN27w47tRiBt1ZUgjbjIfuJ11sd+ K/Munh8R4DuGNjrb1UDPwsluFNXb6FL1vlpGYOfjFIJicd+8hNwJ8p1Ek3aFJE9zbql2 HANQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tycho.nsa.gov header.s=tycho.nsa.gov header.b=qXS+JXcJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=tycho.nsa.gov Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f20si3080438pgv.448.2019.05.30.08.08.43; Thu, 30 May 2019 08:09:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@tycho.nsa.gov header.s=tycho.nsa.gov header.b=qXS+JXcJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=tycho.nsa.gov Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727343AbfE3PEd (ORCPT + 99 others); Thu, 30 May 2019 11:04:33 -0400 Received: from usfb19pa16.eemsg.mail.mil ([214.24.26.87]:17970 "EHLO usfb19pa16.eemsg.mail.mil" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726045AbfE3PEd (ORCPT ); Thu, 30 May 2019 11:04:33 -0400 X-EEMSG-check-017: 199864528|USFB19PA16_EEMSG_MP12.csd.disa.mil Received: from emsm-gh1-uea10.ncsc.mil ([214.29.60.2]) by usfb19pa16.eemsg.mail.mil with ESMTP/TLS/DHE-RSA-AES256-SHA256; 30 May 2019 15:04:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tycho.nsa.gov; i=@tycho.nsa.gov; q=dns/txt; s=tycho.nsa.gov; t=1559228671; x=1590764671; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=Gx/Na3NMPNgR6X0ozLsN6rip3MeDz+5aRP/AalAyVLs=; b=qXS+JXcJhypwvQl8jqmPWuZGkpax6bjF9ZnTHHLwQNY3i5sY95e1NmhQ Yt6QJnPuNEcROTrMd/3aLzArXIhWc2q46KFWJ3I9J9muL+mj3whH9DT2a B4pVL6mNbxoSQOxXO4Fs4nNIjSl7rlDkSHGtWin0TCrPz5R9Xt07yJnv2 yJxzCl0zOouc500mNIJHBOimtSfLMm0kpoyNK2FVB50WJQ7pRQq/gH3NG r6agZm9D/LVuo4duVG58HDeZH1viVOOmXGq8ZX/JJUri//bjQSBHVQW6E UezS3cGFIHurVqsKVU9N7jmR4X0bFCrKB6ssJna14kbYjpX0j4hCW50Da g==; X-IronPort-AV: E=Sophos;i="5.60,531,1549929600"; d="scan'208";a="24226989" IronPort-PHdr: =?us-ascii?q?9a23=3AOn0ODR0hIG1YJyqQsmDT+DRfVm0co7zxezQtwd?= =?us-ascii?q?8ZsegQKv7xwZ3uMQTl6Ol3ixeRBMOHsqsC0rCH+PC4EUU7or+5+EgYd5JNUx?= =?us-ascii?q?JXwe43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6arXK99yMdFQ?= =?us-ascii?q?viPgRpOOv1BpTSj8Oq3Oyu5pHfeQpFiCegbb9oMRm6swHcusYVjId+N6081g?= =?us-ascii?q?bHrnxUdupM2GhmP0iTnxHy5sex+J5s7SFdsO8/+sBDTKv3Yb02QaRXAzo6PW?= =?us-ascii?q?814tbrtQTYQguU+nQcSGQWnQFWDAXD8Rr3Q43+sir+tup6xSmaIcj7Rq06VD?= =?us-ascii?q?i+86tmTgLjhTwZPDAl7m7Yls1wjLpaoB2/oRx/35XUa5yROPZnY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Tz/Z5C9DxXQLNZMyJR0ylQtWlADExSMw+w9kVbk?= =?us-ascii?q?Z5GtWiiA3D3iWwD78UkbyLGII78qbG03ftIMZ9zm7M1LM9gFk+XstPKWqmi7?= =?us-ascii?q?Z99wjWAI7JiV+Zl6exdakH2i7C7mKDwnSPvE1CVw5wS6rFV2gFZkTKtdT5+l?= =?us-ascii?q?/CT7i2BLQ8LARB08GCJbVRZ93pl1pGQPPjOdTYY26rh2iwAhOIzKuWbIX2Y2?= =?us-ascii?q?UdwDndCE8cngAX/HaGMxU+Byi4r2LFEjNhCU/vY1nt8eliqHK3V0o0zwaXYE?= =?us-ascii?q?1807q65AUYheKTS/wNxLIIoiQhpCtuHFa7wd3WD8CMpw17fKVTedk9+ktI1X?= =?us-ascii?q?rFtwxhOZytN7hiiUQDcwRzpE7uzw94CphEkcQzqXMqyw1yKbiG319bazyY2p?= =?us-ascii?q?XwMKXNKmbu5BCvd7LW2lbG3dmI4qcA8u44q1T4vAyyDkot6W9n09hO03uE4p?= =?us-ascii?q?XFFhYdXozrXkYw7Rh6qKnQYjMh6IPMyX1sLa60vyfZ2903AOslyxCgf8pQMa?= =?us-ascii?q?6fCg/yHNMVB9K0JOwphVepdBQEM/5W9KIuOMOmbfSG0raxPOl8hDKmkXhH4I?= =?us-ascii?q?dl30KO6SV8Vu7I34wCw/yD0AuHUC38jEu7vcDxmIBFaiseEXa4ySjhHIRRfL?= =?us-ascii?q?F9fZ4XCWeyJM263shxiITzW3FG7lKjB0kJ2MmyeRWMaVzwxgxQ1UILoXO5nS?= =?us-ascii?q?u01SB7kzYsrqCHxizB3/zidAYbOm5MXGRikVjsIYy7jt0BWEiobg4plAa55U?= =?us-ascii?q?bgwKhboqV/LmbJTUhVYSf8N3tiXbeotrqef85P74slsSpNUOuiblCXUaDyox?= =?us-ascii?q?0Y0yz9G2tewDE7eC2wtprlmBx6jXqXLGxvo3rBZcFw2RDf6cTARf5WxDoGWj?= =?us-ascii?q?N3iT3KCVinJNSp+dSUl5HesuGxTm6hWJpTcTTtzYydriS7+WxqARq5n/ypnd?= =?us-ascii?q?3nCwc62zfh19Z2TSXIsAr8Yo7z2qS+MOJneFRoBVDl58p5BI5+iI0wi48U2X?= =?us-ascii?q?UBmJWV8mQIkX3pPdVYx63+dnwNSiAPw9LP5wjlwkJjJGqTx43lTnWd3tdhZ9?= =?us-ascii?q?6ib2IZ2S8w7ttHCKSK47xemyt6vF64oRjWYfhnkTcX0eEu52ICg+EVpAotyT?= =?us-ascii?q?2QArQTHUleICztmA2E78uxrKRYf2uvb7ew21Rkndy7D7GNvBtcWHDndZcmBy?= =?us-ascii?q?Nw6d9/MF3U2n3p9o7kYMXQbc4UthCMiRjAjPBVKJcqm/oOhCpnP3/9vHI8x+?= =?us-ascii?q?41ihxuwJe6s5WdJGVx/aK5BRhYOifyZ8MJ9THnlbxekdqO34CzApVhHS0GXJ?= =?us-ascii?q?3oTfKvCjISsO7oNwCVHT0mtHiUBLrfEhWD6Et8s33PFJWrPWmNJHYF1dViWA?= =?us-ascii?q?WdJEtHjQASRDU6m4I2GRywy8zldEd5+zUR60XiqhRS1+1oNwPwUnvFqAi0bT?= =?us-ascii?q?c0TYCVLABK4QFa+0fVLcue4/poHy5G5J2hoxKCJnaBaAVICmEJR0qECkviPr?= =?us-ascii?q?mo+dnP7eyYCvCiIPvJZLWEsfZeWOuQxZKzzotm+C6BNt6PPnZ4D/w3wElDUm?= =?us-ascii?q?plG8XYgjkOSjYYlyfMb86Bvxq8+yt3rtyh//TvQg7g+YyPC75KO9V15x+2mb?= =?us-ascii?q?uDN/KXhCthKTZXzJIMxWPSx7gYxlISizxueCOrEbQPriPNTaTQmrNJAB4fcS?= =?us-ascii?q?98KMxI76ck1AlXJcHbks/11qJ/jvMtEVhFU0HumtuoZc0KOW29L1PHC1iVNL?= =?us-ascii?q?uaJT3E3cf3YaC7SbBLiOVUthuwuSuUEkP5PzSDkSXpWA6rMe1WkC6bOxlesp?= =?us-ascii?q?mnchlxEWjjUM7mahqjPd90lzI2wKc4hmjUNWEGMTh8dVhArryW7SNEnPp/H3?= =?us-ascii?q?ZN4WZiLemBgyyZ9fXXKo4Ksft3BSR5j/lV4GwhxrRP6CFEReJ6mC3Ro9J0vl?= =?us-ascii?q?6pjPGFyiB7XxpWtjZLmIWLsF1gOaXe7ZlAWW3J/BAK7WWLCxQKu8FlCtz3u6?= =?us-ascii?q?BU1NfPiL7zJC1F89LO8ssWH9LUJ96fMHo9LRrpHybZDAgfQj6qL23fh1Fdn+?= =?us-ascii?q?uU9n2atZU6q57smIYQRb9fTlA6CvQaCkF9FtwYPJh3Ri8kkaKcjMMQ/3q+rQ?= =?us-ascii?q?feRMNGvpDFSP2SGu7iKDmejblDaBsIxa33IZ4POY383kwxImV9ya3MF1uYec?= =?us-ascii?q?1RpShgdBQ3oQ0Z9GViSUUw1ljjZwfr52UcQ62ahBkz3zBibPwt+TGk2FI+Il?= =?us-ascii?q?7HtWNki0Uqscn0ijCWNjjqJeG/Wp8AWHm8jFQ4Lp6uG1U9Vga1h0ExcW6ZFr?= =?us-ascii?q?8=3D?= X-IPAS-Result: =?us-ascii?q?A2DoAQCg8O9c/wHyM5BlHAEBAQQBAQcEAQGBVAQBAQsBg?= =?us-ascii?q?WYqgW2EPJMCTwEBAQaBECV+iFKRBwkBAQEBAQEBAQE0AQIBAYRAAoJ9IzcGD?= =?us-ascii?q?gEDAQEBBAEBAQEDAQFsKII6KQGCZgEBAQECASMEEUEFCwsOCgICJgICVwYNC?= =?us-ascii?q?AEBgl8/gXcFD6oyfDOFR4MpgUaBDCgBi1UXeIEHgREnDIIqNT6HToJYBI1jh?= =?us-ascii?q?giVAQmCD4IWkQcGG4IhlDeOIJZtIoFYKwgCGAghD4MokG0jA4E2AQGNfQEB?= Received: from tarius.tycho.ncsc.mil ([144.51.242.1]) by EMSM-GH1-UEA10.NCSC.MIL with ESMTP; 30 May 2019 15:04:28 +0000 Received: from moss-pluto.infosec.tycho.ncsc.mil (moss-pluto [192.168.25.131]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id x4UF4O2M030622; Thu, 30 May 2019 11:04:24 -0400 Subject: Re: SGX vs LSM (Re: [PATCH v20 00/28] Intel SGX1 support) To: Andy Lutomirski Cc: "Xing, Cedric" , "Christopherson, Sean J" , William Roberts , Jarkko Sakkinen , James Morris , "Serge E. Hallyn" , LSM List , Paul Moore , Eric Paris , "selinux@vger.kernel.org" , Jethro Beekman , "Hansen, Dave" , Thomas Gleixner , "Dr. Greg" , Linus Torvalds , LKML , X86 ML , "linux-sgx@vger.kernel.org" , Andrew Morton , "nhorman@redhat.com" , "npmccallum@redhat.com" , "Ayoun, Serge" , "Katz-zamir, Shay" , "Huang, Haitao" , Andy Shevchenko , "Svahn, Kai" , Borislav Petkov , Josh Triplett , "Huang, Kai" , David Rientjes References: <20190524175458.GB365@linux.intel.com> <960B34DE67B9E140824F1DCDEC400C0F654E8E1D@ORSMSX116.amr.corp.intel.com> <20190524200333.GF365@linux.intel.com> <20190524224107.GJ365@linux.intel.com> <683B5E3D-AFB6-4B45-8D39-B00847312209@amacapital.net> <960B34DE67B9E140824F1DCDEC400C0F654E965F@ORSMSX116.amr.corp.intel.com> <960B34DE67B9E140824F1DCDEC400C0F654E9824@ORSMSX116.amr.corp.intel.com> <20190528202407.GB13158@linux.intel.com> <285f279f-b500-27f0-ab42-fb1dbcc5ab18@tycho.nsa.gov> <960B34DE67B9E140824F1DCDEC400C0F654EB487@ORSMSX116.amr.corp.intel.com> <678a37af-797d-7bd5-a406-32548a270e3d@tycho.nsa.gov> From: Stephen Smalley Message-ID: Date: Thu, 30 May 2019 11:04:24 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/30/19 10:31 AM, Andy Lutomirski wrote: > Hi all- > > After an offline discussion with Sean yesterday, here are some updates > to the user API parts of my proposal. > > Unfortunately, Sean convinced me that MAXPERM doesn't work the way I > described it because, for SGX2, the enclave loader won't know at load > time whether a given EAUG-ed page will ever be executed. So here's an > update. > > First, here are the requrements as I see them, where EXECUTE, EXECMOD, > and EXECMEM could be substituted with other rules at the LSM's > discretion: > > - You can create a WX or RWX mapping if and only if you have EXECMEM. > > - To create an X mapping of an enclave page that has ever been W, you > need EXECMOD. EXECMOD to what file? The enclave file from which the page's content originated, the sigstruct file, or /dev/sgx/enclave? > - To create an X mapping of an enclave page that came from EADD, you > need EXECUTE on the source file. Optionally, we could also permit > this if you have EXECMOD. What is the "source file" i.e. the target of the check? Enclave file, sigstruct file, or /dev/sgx/enclave? > > And I have two design proposals. One is static and one is dynamic. > To implement either one, we will probably need a new .may_mprotect vm > operation, and that operation can call an LSM hook. Or we can give > LSMs a way to detect that a given vm_area_struct is an enclave. As I > see it, this is an implementation detail that is certainly solveable. > > > Static proposal: > > > EADD takes an execute_intent flag. It calls a new hook: > > int security_enclave_load(struct vm_area_struct *source, bool execute_intent); > > This hook will fail if execute_intent==true and the caller has neither > EXECUTE, EXECMOD, nor EXECMEM. EADD execute_intent flag is originally provided by whom (userspace or driver) on what basis? Which file is referenced by source->vm_file? Why trigger all three checks up front versus only checking if needed? Won't this trigger a lot of unnecessary EXECMOD and EXECMEM denials that will need to be dontaudit'd? What if there is a mismatch between execute_intent and the initial permissions? > > EAUG sets execute_intent = false. > > EINIT takes a sigstruct pointer. SGX can (when initially upstreamed > or later on once there's demand) call a new hook: > > security_enclave_init(struct sigstruct *sigstruct, struct > vm_area_struct *source); Is struct sigstruct the same as struct sgx_sigstruct in the current patches (i.e. just the sigstruct data, no file)? What file is referenced by source->vm_file (the sigstruct or the enclave or /dev/sgx/enclave)? Is this hook only for enforcing a whitelist on what enclaves can be loaded? What is the target of the check? > mmap() and mprotect() will require EXECMEM to create WX or RWX > mappings. They will require EXECMOD to create RX or X mappings of an > execute_intent==false page. They require no permissions in the other > cases. Does this occur for both setting initial permissions and runtime permissions or just runtime? Both userspace- and driver-initiated mmap/mprotect operations or just userspace-initiated ones? Does the driver use interfaces that call the mmap/mprotect hooks or lower level functions? > > > Dynamic proposal: > > > EADD does not take any special flags. It does something like this internally: > > bool execute_intent = true; > int security_enclave_load(struct vm_area_struct *source, bool > *execute_intent); > > The implementation of security_enclave_load() may set *execute_intent to false. > The driver records execute_intent after the LSM is done. On what basis does LSM decide whether to set *execute_intent? If the process lacks all three permissions? What if there is a mismatch with the initial permissions? > > mmap() and mprotect() will require EXECMEM to create WX or RWX > mappings. They will require EXECMOD to create RX or X mappings of an > execute_intent==false page. They require no permissions in the other > cases. > > > > A benefit of the static proposal is that audit failures due to a lack > of EXECUTE permission are easy to implement and to understand in the > lods. With the dynamic model, we can only really audit the lack of > EXECMOD or EXECMEM. A benefit of the dynamic model is that we hide > what is arguably a decently large wart from the API. >