Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1041782yba; Wed, 15 May 2019 14:41:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqwVpsDx68RI+5HV1Fy6bJZ1hwTQJgAWRsn3sfwepDTVbeoWnRDe284XFA1wsGXsg/3bUU+a X-Received: by 2002:a65:450b:: with SMTP id n11mr5243329pgq.174.1557956489544; Wed, 15 May 2019 14:41:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557956489; cv=none; d=google.com; s=arc-20160816; b=JOAgOoXoMpHTSgUWsqNSdUd2C8w2vjmhAxisWvFNyLNhnPLcwliuqxj/IW09/tjq5J kJ1lJNtVr0hRIvvrtx2vJNkcGgMHes7PqoWNnQleV64merVW9DVbe9EpRfWxsPUVqkTT zyf5l2NzfqpThs0q9emtmG8wUX1NaVDfWQZUBcLEFGztA3WjyvrtlauazL/JhS7OTsBY Nru9lJT0mjm0Td9wHiPoO85OYNNHpyFWGZHBzwD0BJCjRdZ1/EU2uvqcF8bJPIS6I1yh rB61k/wNoO3pQEisnRMYMIb2MUs2iQiYhXk560CbJNLzhMIpk+TR4O6Tn+iEFihVRBCd Z6RA== 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 :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=m9hGIH7prE15Qhf9oFJC2aesHgaT0jPCDwUgwG2qDRs=; b=suTqsD5oGHn53kzvM4L1lh75cQoI5vfAfDP89h9xc1hw8SkZAn7MEAkLXJMNZvgedV 5eGcEX191mqkrBMOsoiZUNZRo00k3SvAtO/b9Pp9s17PgDu5pRe8ubR8UvxQk9Crcbop t0J0U+cNOEhLd7VuF478rWiR+cOvvl29G8TfrR+yUlM5MePIgYzabM3AFhps/yhstHHa NH9qUqq1QLN8vMZESZQWioJXNFr/P1GK/QPH/LIIW+iNCazpg84DGm4B3Lp+fEynfNfl EWi8/gIG4zc2Q0c97t19y9nOEo0anOTB5uZOod2IQfqV1WVxalMrbdTPmpFhFxjcaQk2 QcFg== 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 n1si991180pgh.584.2019.05.15.14.41.14; Wed, 15 May 2019 14:41:29 -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 S1727136AbfEOVjA (ORCPT + 99 others); Wed, 15 May 2019 17:39:00 -0400 Received: from mga07.intel.com ([134.134.136.100]:48585 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726441AbfEOVjA (ORCPT ); Wed, 15 May 2019 17:39:00 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 May 2019 14:38:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,474,1549958400"; d="scan'208";a="172102692" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.36]) by fmsmga002.fm.intel.com with ESMTP; 15 May 2019 14:38:58 -0700 Date: Wed, 15 May 2019 14:38:58 -0700 From: Sean Christopherson To: Andy Lutomirski 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) Message-ID: <20190515213858.GG5875@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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.