Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp759190ybi; Fri, 24 May 2019 10:59:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqw/0U7Kma3o4fkWtj4Hg9D3flvhShstuGitWN+eqieBYVlzRPoQ0mV7UIDpsjQzbFpVRclk X-Received: by 2002:a63:364f:: with SMTP id d76mr50455292pga.100.1558720761475; Fri, 24 May 2019 10:59:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558720761; cv=none; d=google.com; s=arc-20160816; b=oGBFIOS+Kr4b+aa4PTxg6Mxyr+5GIOviesHBDouq0fc7+MKm0S8flsr8G/ox/RrXQv F01EYocf03XDIWydQoLYBDYf5a8ux8omPaqs8ut5kFVQZe13DoqKcNMJZ1qMia0TMBrU 4EzOklhtLCN3PLxTV66UYXJ1avmt3JD7v4Xv4WrnqJsy7c1LDqulqBngQ9cfPpRTX8kg eRAlBrXm6uKWIm6cLl0hDVjn8cEDCl8IqoXo8A/YBP+bGCPQ7GdqRtj58igP3LahIsf+ VWaFLAhBtsRHE1xz5qm4XPTFybeSkAQbL4ya9Ju5C+PK5ayKabATpyz6zgVBr6Z4GK03 N0rQ== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=XTBHNzSvU36YaJmeF/BZ/Nyg9fEvqi9rQar/ogIeV9g=; b=RjX4CI7I1dNQmmwjOt+rqMcm8JlJHMaDb56NY3RCJZFtHxpeSTEkrcIOoNsEAq0MvP oTQ6ITDTQ611qnVzzoI01Iomb4r+ukfirPwGSWwGpztIhtc4MpwSEr7004fLTYrNBaNZ pqOWOIYZ2uNBNu9Wdo+S3rwmknE5tw/eBI1inEK9NpWHgV5gz5PBDKn1CLELVBmRT7dd gv+/2KGdlbIcVoqYW1MnYyttvz3emATqSC8+YE7tkOelqHSazoAvn5oB9kKDe1zpV+PR q9oaZPR7QcY1TGcChItLie+BAwg1QMSVQs9ZrLAk1cwMMpdqg1NFtE+gS50wDNkoBfK5 rAVA== 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 h21si4946698pgv.266.2019.05.24.10.59.05; Fri, 24 May 2019 10:59:21 -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 S1728995AbfEXR4t (ORCPT + 99 others); Fri, 24 May 2019 13:56:49 -0400 Received: from mga14.intel.com ([192.55.52.115]:33046 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728222AbfEXR4s (ORCPT ); Fri, 24 May 2019 13:56:48 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 May 2019 10:56:48 -0700 X-ExtLoop1: 1 Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.36]) by orsmga001.jf.intel.com with ESMTP; 24 May 2019 10:56:45 -0700 Date: Fri, 24 May 2019 10:56:47 -0700 From: Sean Christopherson To: Andy Lutomirski Cc: Stephen Smalley , "Xing, Cedric" , Andy Lutomirski , 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 Subject: Re: SGX vs LSM (Re: [PATCH v20 00/28] Intel SGX1 support) Message-ID: <20190524175647.GC365@linux.intel.com> References: <20190523023517.GA31950@linux.intel.com> <20190523102628.GC10955@linux.intel.com> <20190523141752.GA12078@linux.intel.com> <20190523234044.GC12078@linux.intel.com> <960B34DE67B9E140824F1DCDEC400C0F654E8956@ORSMSX116.amr.corp.intel.com> <20190524174243.GA365@linux.intel.com> <56EA6C7C-F69E-42EB-9CFB-CD0300549298@amacapital.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <56EA6C7C-F69E-42EB-9CFB-CD0300549298@amacapital.net> 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 Fri, May 24, 2019 at 10:54:34AM -0700, Andy Lutomirski wrote: > > > On May 24, 2019, at 10:42 AM, Sean Christopherson wrote: > > > > Hmm, I've been thinking more about pulling permissions from the source > > page. Conceptually I'm not sure we need to meet the same requirements as > > non-enclave DSOs while the enclave is being built, i.e. do we really need > > to force userspace to fully map the enclave in normal memory? > > > > Consider the Graphene scenario where it's building an enclave on the fly. > > Pulling permissions from the source VMAs means Graphene has to map the > > code pages of the enclave with X. This means Graphene will need EXEDMOD > > (or EXECMEM if Graphene isn't careful). In a non-SGX scenario this makes > > perfect sense since there is no way to verify the end result of RW->RX. > > > > But for SGX, assuming enclaves are whitelisted by their sigstruct (checked > > at EINIT) and because page permissions affect sigstruct.MRENCLAVE, it *is* > > possible to verify the resulting RX contents. E.g. for the purposes of > > LSMs, can't we use the .sigstruct file as a proxy for the enclave and > > require FILE__EXECUTE on the .sigstruct inode to map/run the enclave? > > I think it’s sound for some but not all use cases. I would imagine that a lot > of users won’t restrict sigstruct at all — the “use this as a sigstruct” > permission will be granted to everything and maybe even to memfd. But even > users like that might want to force their enclaves to be hardened such that > writable pages are never executable, in which case Graphene may need an > exception to run. Heh, I belatedly had the same thought. See my follow-up about EXECMEM. > But maybe I’m nuts.