Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp55244yba; Wed, 15 May 2019 18:50:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqxL+uuT+ecScWaUsFoMrMwTqb4JgNWeNE9XDbvqmqIxgzzfevg52OC57HKuvPU+5sLtG1wf X-Received: by 2002:a17:902:e086:: with SMTP id cb6mr47531586plb.237.1557971415553; Wed, 15 May 2019 18:50:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557971415; cv=none; d=google.com; s=arc-20160816; b=VP5iWf1IygvIdnVQzvF2fHiKI7JdkbgrJuy5U8LwUUIct3skNYbXs9bZYXsVPE/v/o z40H9aJNM24DAZw+m6vJCRoKEwOU7ekIhON01MPp6h1O1M1uEQHDeVdnb6AUHOus6YND WR6+/pjiLTUEIKvnGVGCTvDvjhazH3TCjYLqZAQZTMJjvSDvXIP1Oo7N0HWRrN5v3er9 F7bHH22X/JAlbqNAJdkIBsjNoP4AXBSSK5ZBEGh6eQcYB/DdotO0yYwLjTt0gT6FomvO VyGuJOmWz4LwPwMJCvqOpK1XtQc0/TbwDEaNFk0G6g/dDA5D0Xs3GN+xsEVjX5KqsZZM kHAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to:message-id :organization:from:content-transfer-encoding:mime-version:date :references:reply-to:subject:cc:to; bh=HzQ1zcCcxzs1F2acdqvFLjI9Q65oOi1Y4ldgrFiOaFo=; b=KF2gLEUZpJ5CAkblXVzqSMh0Le1XZJWl7x1FOJz28GqLchORdwdnCtUMVEww7Sl4Ek Y6lQaAglwZfIdbDtgHdA9e0V0wB2IMmFnsVPgZBwSwpeQyTNqltZSyBj4BNK+iYMoz87 sOr+U/HNOjRfsp+T8G+A6OzyD3AMY2a1RnhxRMi7VXQzh5yFZmStZxYC9RHdWM5MGXr8 6DeaVD5YboEAhj9S7tb0M00w+J38cxRfEVki5puT21/YXYpJIqqCPKQhgEs1q5WKF9rv Fvwc+YyXuOrx1fpu7InRFo+a0NKK5YDCGRwydQIJpdvOHIZwjcOJHIGsoExyXEz4zbCH OFEg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i18si3959950pfd.64.2019.05.15.18.49.41; Wed, 15 May 2019 18:50:15 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727874AbfEPBrV (ORCPT + 99 others); Wed, 15 May 2019 21:47:21 -0400 Received: from mga06.intel.com ([134.134.136.31]:62043 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726990AbfEPBTK (ORCPT ); Wed, 15 May 2019 21:19:10 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 May 2019 18:19:09 -0700 X-ExtLoop1: 1 Received: from hhuan26-mobl.amr.corp.intel.com ([10.255.34.16]) by orsmga006.jf.intel.com with ESMTP; 15 May 2019 18:19:04 -0700 Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes To: "Andy Lutomirski" , "Sean Christopherson" Cc: "James Morris" , "Serge E. Hallyn" , "LSM List" , "Paul Moore" , "Stephen Smalley" , "Eric Paris" , selinux@vger.kernel.org, "Jarkko Sakkinen" , "Jethro Beekman" , "Xing, Cedric" , "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" Subject: Re: SGX vs LSM (Re: [PATCH v20 00/28] Intel SGX1 support) Reply-To: haitao.huang@linux.intel.com References: <960B34DE67B9E140824F1DCDEC400C0F4E886094@ORSMSX116.amr.corp.intel.com> <6da269d8-7ebb-4177-b6a7-50cc5b435cf4@fortanix.com> <20190513102926.GD8743@linux.intel.com> <20190514104323.GA7591@linux.intel.com> <20190514204527.GC1977@linux.intel.com> <20190515013031.GF1977@linux.intel.com> <20190515213858.GG5875@linux.intel.com> Date: Wed, 15 May 2019 20:19:04 -0500 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: "Haitao Huang" Organization: Intel Message-ID: In-Reply-To: <20190515213858.GG5875@linux.intel.com> User-Agent: Opera Mail/1.0 (Win32) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 15 May 2019 16:38:58 -0500, Sean Christopherson wrote: > On Wed, May 15, 2019 at 11:27:04AM -0700, Andy Lutomirski wrote: >> 2) Just like any other DSO, there are potential issues with how >> enclaves deal with writable vs executable memory. This takes two >> forms. First, a task should probably require EXECMEM, EXECMOD, or >> similar permission to run an enclave that can modify its own text. >> Second, it would be nice if a task that did *not* have EXECMEM, >> EXECMOD, or similar could still run the enclave if it had EXECUTE >> permission on the file containing the enclave. >> >> Currently, this all works because DSOs are run by mmapping the file to >> create multiple VMAs, some of which are executable, non-writable, and >> non-CoWed, and some of which are writable but not executable. With >> SGX, there's only really one inode per enclave (the anon_inode that >> comes form /dev/sgx/enclave), and it can only be sensibly mapped >> MAP_SHARED. > > I was wrong when I said /dev/sgx/enclave creates and returns an anon > inode. I was thinking of the KVM model for creating VMs. SGX creates > an enclave when /dev/sgx/enclave is opened and associates the enclave > with the newly opened /dev/sgx/enclave fd. > > Regardless, the fundamental problem remains, mmap() of EPC works on a > single inode. If I read code in file_map_prot_check() correctly, only when you request W+X at the same time that EXECMEM would be required for MAP_SHARED, right? If so, I believe SGX enclaves would never need that.