Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp1118022ybm; Tue, 21 May 2019 08:54:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqwiCU0Aae0zTzVwedZe/6ulwk88DdlH63sT4ZsyvfRi4OdmmvgVHOM9R6dMbsOEyEy37mYX X-Received: by 2002:aa7:8ec6:: with SMTP id b6mr88442839pfr.234.1558454094839; Tue, 21 May 2019 08:54:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558454094; cv=none; d=google.com; s=arc-20160816; b=BsgeMFm9Sjo/4wxkxuN3WrxN4nxYUO+JR3UQakNNrW+PDfSUT/UOQ748CZfJVO4M2K x9mWfiq+Bpt9N1zfR9fFcHRqdPx+NfxXg5mFUM2qZuSZlh1WDCVwQBu9Mv82LzT+31xJ 20un7vWp8YzVPlPufy+sKoVc0JKNkSaMg1wIiM74VhmwuTDSZUtTOuyGrLHxbb3IMvcS xE/iU+5ziHQZT7AdQLZ025PDYZ6Q3VbuyfGLhwzrAdBa5RihgdgYBRCWKdqyU6wrH8bB 0GkZPD3/fw1vekohUaLq6Eb/Yj5DtsmhkD/HstN+HwMlZCoT+htpwSHkqwm5SGtzyRdT DJaw== 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=NLZdGO1sM1DlNA910Yl5c08q0uzmHJWnokEgM5jlj7A=; b=jxfkJzQDCNjKVVKAw09hArlTagnSlm8t0Gf1EVRve3bWheCph18x7i7oIJ5wqdCMWK lk9hP67yI5RDcjdg+W+kz9bIYA8hx8t6HSOXb2ctUItQa7avKqcmkZlCjl3GXz8GduVU iR3Jlag5OhD3F1QQgVVQY9e0Qtjz/ttGe2kEWceXYhAj2tz+RrYms2zFOgkLt60FoUj6 bruLSJSaGGeJwETINBDzwo1v4lrz5irOI0qFkahBJ2iJK+U4avtIIHunPy0KHh/M194s T4HxVscogr4GelW9CVPVdWuvheiapT+8bpANrx3Fr9HtLll/BDj2PwQv1m6beatNHTm6 4eRw== 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 e3si812635pld.129.2019.05.21.08.54.39; Tue, 21 May 2019 08:54:54 -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 S1728316AbfEUPvl (ORCPT + 99 others); Tue, 21 May 2019 11:51:41 -0400 Received: from mga02.intel.com ([134.134.136.20]:55893 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727941AbfEUPvl (ORCPT ); Tue, 21 May 2019 11:51:41 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 May 2019 08:51:40 -0700 X-ExtLoop1: 1 Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.36]) by orsmga005.jf.intel.com with ESMTP; 21 May 2019 08:51:40 -0700 Date: Tue, 21 May 2019 08:51:40 -0700 From: Sean Christopherson To: Jarkko Sakkinen Cc: Andy Lutomirski , James Morris , "Serge E. Hallyn" , LSM List , Paul Moore , Stephen Smalley , 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: <20190521155140.GE22089@linux.intel.com> References: <20190514104323.GA7591@linux.intel.com> <20190514204527.GC1977@linux.intel.com> <20190515013031.GF1977@linux.intel.com> <20190517000331.GD11204@linux.intel.com> <20190520114105.GD27805@linux.intel.com> <20190521151836.GA4843@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190521151836.GA4843@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 Tue, May 21, 2019 at 06:19:37PM +0300, Jarkko Sakkinen wrote: > On Mon, May 20, 2019 at 02:41:05PM +0300, Jarkko Sakkinen wrote: > > On Thu, May 16, 2019 at 05:26:15PM -0700, Andy Lutomirski wrote: > > > Is userspace actually requred to mmap() the enclave prior to EADDing things? > > > > Nope, not since v20. Here is what I wrote about API to the kernel > > documentation: > > > > "The enclave life-cycle starts by opening `/dev/sgx/enclave`. After this > > there is already a data structure inside kernel tracking the enclave > > that is initially uncreated. After this a set of ioctl's can be used to > > create, populate and initialize the enclave. > > > > You can close (if you want) the fd after you've mmap()'d. As long as the > > file is open the enclave stays alive so you might want to do that after > > you don't need it anymore. Even munmap() won't destruct the enclave if > > the file is open. Neither will closing the fd as long as you have > > mmap() done over the fd (even if it does not across the range defined in > > SECS)." > > > > Enclave can be created and initialized without doing a single mmap() > > call. > > We could even disallow mmap() before EINIT done. The way enclave > management internally works right now is quite robust and completely > detached from requiring process address space for anything. Except that mmap() is more or less required to guarantee that ELRANGE established by ECREATE is available. And we want to disallow mmap() as soon as the first EADD is done so that userspace can't remap the enclave's VMAs via munmap()->mmap() and gain execute permissions to pages that were EADD'd as NX. Actually, conceptually it's probably more intuitive to disallow mmap() at ECREATE, i.e. the act of creating an enclave pins the associated virtual address range until the enclave is destroyed.