Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2091524yba; Fri, 17 May 2019 10:15:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqzNW/jDt9wXkLonlrqiRsrnYyTRKO2xoFolOF53SxIHqGo101eYzgJzvTLRXDDTlS02uU2H X-Received: by 2002:a17:902:8f8d:: with SMTP id z13mr51608473plo.166.1558113347431; Fri, 17 May 2019 10:15:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558113347; cv=none; d=google.com; s=arc-20160816; b=l9LtLDZA3HbYyprNXax2GyieYi3plT+NwUzOJX+00VQOjhw75b9PmsXlC7zoreze4b 3DhfGRJknllzZeKh/H9ClbDhjy0/MZ7+4umO1Dpu+gO+TfMLbx4X2zuzeN0OPt77x666 0fehr0vsLdaTkRgwCqYr/7rMbllb5JNPjIxXcJaI9mf0xSkQGC8vM9SAeHDRHsUbxVLt 5QUoA7Ti8A57WSwBn6tw5CVbpnXw77NfPByRSplrso9A4VBkmehgSnWVNu7uOi3Cj38I dqsq5a/m57Rf2IG9RLh5b1l5K6kskjh0sQCMu0NpSvhZiY6IMHVoW4yzKDY52PDwNz2I 5QsQ== 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=4Zm4/oCzP4wwhoXK+OO4vpRAy0iD5CnVAhPssySA1Gk=; b=NAP0k+VbgK8JtnITPvCbwo0ux6StzlkKWW20szImIAgLM7lnPk3h5GONsV3rSgxlRi m/5yh/WqKMGHtnXHO65PoVUM4nQiDwh2Hwf4w9KTutajtmgqYL5WN1yv9Yz/X/a7f9Nf 2XIIUke4ODFq5VL7LSsTwZsJ+gb5NZLNBJGxm3KvcCIfw3OzdrQeDJXkKyy7Vg4EpwNK /CVImz5/629I1uh8k8j3ieDySy6JNMsPvL4LdopwSrzDJvJSKppay2mWGVPnpUfnrG49 tOvstiszYdQPWtFS+rpwlg9dw6sSf/GdQUpkRhVXc9bqYcjPVizDt71i2f8KX50NHswi 0n9g== 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 3si6424164pli.78.2019.05.17.10.15.32; Fri, 17 May 2019 10:15:47 -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 S1729220AbfEQQFH (ORCPT + 99 others); Fri, 17 May 2019 12:05:07 -0400 Received: from mga09.intel.com ([134.134.136.24]:10643 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728482AbfEQQFG (ORCPT ); Fri, 17 May 2019 12:05:06 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 May 2019 09:05:05 -0700 X-ExtLoop1: 1 Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.36]) by orsmga006.jf.intel.com with ESMTP; 17 May 2019 09:05:05 -0700 Date: Fri, 17 May 2019 09:05:05 -0700 From: Sean Christopherson To: Andy Lutomirski Cc: "Xing, Cedric" , James Morris , "Serge E. Hallyn" , LSM List , Paul Moore , Stephen Smalley , Eric Paris , "selinux@vger.kernel.org" , Jarkko Sakkinen , 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: <20190517160505.GB15006@linux.intel.com> References: <20190515013031.GF1977@linux.intel.com> <960B34DE67B9E140824F1DCDEC400C0F654E38CD@ORSMSX116.amr.corp.intel.com> <960B34DE67B9E140824F1DCDEC400C0F654E3FB9@ORSMSX116.amr.corp.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 Thu, May 16, 2019 at 05:35:16PM -0700, Andy Lutomirski wrote: > On Thu, May 16, 2019 at 3:23 PM Xing, Cedric wrote: > > And if you are with me on that bigger picture, the next question is: what > > should be the default behavior of security_sgx_mprot() for > > existing/non-SGX-aware LSM modules/policies? I'd say a reasonable default > > is to allow R, RW and RX, but not anything else. It'd suffice to get rid of > > EXECMEM/EXECMOD requirements on enclave applications. For SGX1, EPCM > > permissions are immutable so it really doesn't matter what > > security_sgx_mprot() does. For SGX2 and beyond, there's still time and new > > SGX-aware LSM modules/policies will probably have emerged by then. > > I hadn't thought about the SGX1 vs SGX2 difference. If the driver > initially only wants to support SGX1, then I guess we really could get > away with constraining the EPC flags based on the source page > permission and not restricting mprotect() and mmap() permissions on > /dev/sgx/enclave at all. No, SGX1 vs SGX2 support in the kernel is irrelevant. Well, unless the driver simply refuses to load on SGX2 hardware, but I don't think anyone wants to go that route. There is no enabling or attribute bit required to execute ENCLU[EMODPE], e.g. an enclave can effect RW->RWX in the EPCM on SGX2 hardware regardless of what the kernel is doing. IMO the kernel should ignore the EPCM from an LSM perspective.