Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4653908ybi; Mon, 3 Jun 2019 14:52:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqw+04pcOTXMhho89PupUJgnIPe0Q5crr6lyEQKpJXMa+WuZK1acsUOcDOMdBdsA/0II4xbG X-Received: by 2002:a17:90a:342:: with SMTP id 2mr32124679pjf.128.1559598779288; Mon, 03 Jun 2019 14:52:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559598779; cv=none; d=google.com; s=arc-20160816; b=hSeOQJcYHDS36tlj6Imfn2QWZ5qmzbl9RshH3Bzfs6gdVGJG+NIGUZuqWfaY7iFAII HcVp0ZIY/Zr4dyAG6IXSf+cH+CqdeO5CXvBTHgefn3eXaba2JV4haRwC6rEoOY/7Joc4 6RI+lGhLAGz/uvMfVENRTXLlVmDty2N66jDqTzx0e9Hr2VCHkuNxb1dFX7F+TTHlrCbi weMznBjJR0I2drg5wVazh73xe1ko7wuQeCSpJ9gte1ycm5EROH6MhvMvPVPE2MfzO7Q9 OfPEcxTGCuxuZKgbWlOkCK/w9otZuDPzeMXRPUGIscXKB058RdMFP5YTTWQr5Md0ShCC Okcg== 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=nkGrzc9amvpf7U/VE2DFbTckoRYzMWqHmh/0U3kZatk=; b=Atf5Fjl/j/ugprd5/wb8db5fOC55AhGomKva+0Wi2FLcgnNJJXCnAuIjqmrS1jKf3d mXVqd8KC2Vivp02Qr3w5p9rE++eFEXMe/cXNcRYIOtMeOGREZK0Fb7lh83ykaxzi97sb rjOl/HDPjrB5pwKZgOGmb/1OAQIEHW8g4dK0H36BR5/yG886TKSqBkg+03Uo3wt6YxQU wlFkd6aB6O+BJjrbjyO7i6pUgv63TbCGvdE0HRFGeOSM6xzGL0F2QY3XnJj3w4Nw+nc/ m2U+deVk1lNRHiDK8R3/PGtFSHE/0lBAhKT/CT4Oy6McSXZ8jTz6Y0ElJbtgGL6dQFY/ tvUA== 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 t8si21320269pgh.235.2019.06.03.14.52.43; Mon, 03 Jun 2019 14:52:59 -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 S1726658AbfFCVvI (ORCPT + 99 others); Mon, 3 Jun 2019 17:51:08 -0400 Received: from mga03.intel.com ([134.134.136.65]:38696 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726317AbfFCVvH (ORCPT ); Mon, 3 Jun 2019 17:51:07 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Jun 2019 14:23:38 -0700 X-ExtLoop1: 1 Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.36]) by fmsmga007.fm.intel.com with ESMTP; 03 Jun 2019 14:23:36 -0700 Date: Mon, 3 Jun 2019 14:23:36 -0700 From: Sean Christopherson To: Jarkko Sakkinen Cc: Andy Lutomirski , Stephen Smalley , "Xing, Cedric" , William Roberts , 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: <20190603212336.GM13384@linux.intel.com> References: <960B34DE67B9E140824F1DCDEC400C0F654E9824@ORSMSX116.amr.corp.intel.com> <20190528202407.GB13158@linux.intel.com> <285f279f-b500-27f0-ab42-fb1dbcc5ab18@tycho.nsa.gov> <960B34DE67B9E140824F1DCDEC400C0F654EB487@ORSMSX116.amr.corp.intel.com> <678a37af-797d-7bd5-a406-32548a270e3d@tycho.nsa.gov> <20190603205405.GE4894@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190603205405.GE4894@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 Mon, Jun 03, 2019 at 11:54:05PM +0300, Jarkko Sakkinen wrote: > On Thu, May 30, 2019 at 09:14:10AM -0700, Andy Lutomirski wrote: > > > What is the "source file" i.e. the target of the check? Enclave file, > > > sigstruct file, or /dev/sgx/enclave? > > > > Enclave file -- that is, the file backing the vma from which the data > > is loaded. > > Wonder why KVM gets away without having this given that enclaves are > lot alike VMs. From a memory management perspective, VMs are not at all like enclaves. An enclave is an extension of its host, i.e. runs in the same address. This isn't strictly necessary, e.g. an enclave could run in a sandbox process, but even then the enclave will be running with the kernel's standard page tables. A VM is a essentially an opaque blob of data that gets loaded into memory. KVM builds a completely different set of page tables for the VM, the VM has it's own file system (or perhaps doesn't have a file system at all), etc... Ignoring Spectre and L1TF, the VM is contained to its own world. There are a lot of ways for a userspace VMM to expose things beyond raw memory, but doing so requires the appropriate permissions. And practically speaking, all traditional VMs will effectively need RWX memory, i.e. Qemu (or any other userspace VMM) would be required to have EXECMEM permissions, which would be a net negative for security. > > It's provided by userspace based on whether it thinks the data in > > question is enclave code. source->vm_file is the file from which the > > code is being loaded. I'm assuming that the user code will only set > > excute_intent ==true if it actually wants to execute the code, so, if > > there's a denial, it will be fatal. The normal case will be that the > > request will be granted on the basis of EXECUTE. > > AFAIK user spaces tells that already with the SECINFO flags. I don't > get why we need a duplicate parameter. Please read through the RFC, I think it address a lot of your questions. Hopefully that will help us avoid some thrash.