Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp2197806ybm; Thu, 23 May 2019 13:00:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqw7Hdl+jUD/CvZ8vCKGk+WubzWqE2yDVZMhvi5hL+SuhvbM9Uhu+ED+o45gzitGBE8jy9Rh X-Received: by 2002:a62:2f87:: with SMTP id v129mr33673978pfv.9.1558641605426; Thu, 23 May 2019 13:00:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558641605; cv=none; d=google.com; s=arc-20160816; b=xRVTSEzi8MM0Oac+lPiifrqAxnHI/Zfcs/KQR3ujOs07ECtBFrlm3ygiA/EwEg5CZp P20cEGui1N2nd6YliA2OXaqa+h/GDab7FS0G3fiuogZAQrzc8t9Szdy56XOhRo7Oh9MY SInGpqoEye7DfDXQ2dTt0/wGvWU2jW0Y1secses9TRui0tO03FCSO++n2+shn9MIWfvE TdFq8xiGVNwhwDyoifUf8X//1J1VH1gEylyxR21ElOGeeC9s1CkCMxgQ8pcwLxyTshNX MCmKMHduesDZM51nw5mKqsmJPVRhcQHOG1+1g7diJJENipX9HpCXQgGWhWyu+0KwKcMz eRDQ== 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=uLuCQzqqbP2iEkMGOTQnVy5y3guZcv5AWpHt+jRQX3U=; b=nOPa2fxbqnCDr9xGwMf5iADb7PSO56srutAB29owr1eBmvFha4j3t+mhXw8HQWTCQS q4BO9bxCcaNI9yNLLxnwNd34Vx0d/3AkxdDeCDUef4lbrMejrDw3UkUL3EtcUL9/V9q5 H09khoVHgn0dFQfvoKu1gTYC0Nf8AvBGLRhqsdqMZtB8Bs2cqWiY06m2TTX3XvH+TVU4 4LSHGQzP6vo+vbjgV4zGlMlVso2iob9s4/ENmIZgb50YjTNkXXA4134qBNyChhIJzF07 iYgS8QX770QW7jy0guYShyH2LUX/smnqK4nnJJaOGCbAVk8WMgdJMVJBDSQBAgALl12E 1LFA== 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 l21si502709pjt.70.2019.05.23.12.59.49; Thu, 23 May 2019 13:00:05 -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 S2387566AbfEWT6m (ORCPT + 99 others); Thu, 23 May 2019 15:58:42 -0400 Received: from mga14.intel.com ([192.55.52.115]:6299 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726451AbfEWT6m (ORCPT ); Thu, 23 May 2019 15:58:42 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 May 2019 12:58:41 -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; 23 May 2019 12:58:41 -0700 Date: Thu, 23 May 2019 12:58:41 -0700 From: Sean Christopherson To: Jarkko Sakkinen Cc: Andy Lutomirski , Stephen Smalley , James Morris , "Serge E. Hallyn" , LSM List , Paul Moore , Eric Paris , selinux@vger.kernel.org, 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: <20190523195840.GA17370@linux.intel.com> References: <20190521151836.GA4843@linux.intel.com> <20190521155140.GE22089@linux.intel.com> <20190522132022.GC31176@linux.intel.com> <20190522132227.GD31176@linux.intel.com> <0e183cce-c4b4-0e10-dbb6-bd81bea58b66@tycho.nsa.gov> <20190522153836.GA24833@linux.intel.com> <20190523023517.GA31950@linux.intel.com> <20190523102628.GC10955@linux.intel.com> <20190523141752.GA12078@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190523141752.GA12078@linux.intel.com> 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 23, 2019 at 07:17:52AM -0700, Sean Christopherson wrote: > On Thu, May 23, 2019 at 01:26:28PM +0300, Jarkko Sakkinen wrote: > > On Wed, May 22, 2019 at 07:35:17PM -0700, Sean Christopherson wrote: > > > But actually, there's no need to disallow mmap() after ECREATE since the > > > LSM checks also apply to mmap(), e.g. FILE__EXECUTE would be needed to > > > mmap() any enclave pages PROT_EXEC. I guess my past self thought mmap() > > > bypassed LSM checks? The real problem is that mmap()'ng an existing > > > enclave would require FILE__WRITE and FILE__EXECUTE, which puts us back > > > at square one. > > > > I'm lost with the constraints we want to set. > > As is today, SELinux policies would require enclave loaders to have > FILE__WRITE and FILE__EXECUTE permissions on /dev/sgx/enclave. Presumably > other LSMs have similar requirements. Requiring all processes to have > FILE__{WRITE,EXECUTE} permissions means the permissions don't add much > value, e.g. they can't be used to distinguish between an enclave that is > being loaded from an unmodified file and an enclave that is being > generated on the fly, e.g. Graphene. > > Looking back at Andy's mail, he was talking about requiring FILE__EXECUTE > to run an enclave, so perhaps it's only FILE__WRITE that we're trying to > special case. Argh, as I was working through Andy's latest proposal I realized that I was subconciously making FILE__READ imply FILE__EXECUTE. The idea behind inheriting permissions from the source VMA is to exempt "standard" enclaves from needing FILE__WRITE. But if we don't add an exemption for FILE__EXECUTE as well, then all enclaves need FILE__EXECUTE, which means FILE__EXECUTE can't be used to identify the case where userspace is mapping an inherited PROT_WRITE page as PROT_EXEC. And if the SGX magic exempts FILE__EXECUTE, then FILE__READ implies FILE__EXECUTE. Yuck.