Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp272604yba; Thu, 16 May 2019 00:04:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqwa815U33iS3FPQ0XIJaIY6J9l5hCjrM+jNuxjr3GfSRTcCDhsG6rcIKSZfYwBODOachkxN X-Received: by 2002:a63:f146:: with SMTP id o6mr49140839pgk.179.1557990261750; Thu, 16 May 2019 00:04:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557990261; cv=none; d=google.com; s=arc-20160816; b=LxfCpokpWjrm83y+9SVgtJq9YWE3upfx+Gv3qVk+gJThttRTFXaWm6o0BuXusIYcWk +BvOj9UzrP0XJENJl1JStx0We9h0y/XfRcnCxxjUMwrFDdJJL3+Abt8TgvQfqQvMo3Mz cXO73SdixRHUsfo4WDTAJ8atWtnaaeVWVuxDFhXwyxphhyo3XHpyGYP9WK20VKxrXK0V 9uV3yCGt5+veppWubP6WlaaqsVDM9MGreUOibSg5tG4z1cwm+Psfb1RjcpGmgAPKFJgG JckocnbfiPm1oWAgvcIn9ASlTFrg3ASy3yCPbczENZfwbTqOD9PGBlbfos418JNONkyh 1MdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=i7xGeGzsWjtNGj+DFpgiJpUDxvj7oX48/rRoCJJMeq4=; b=XR2CqsgxPfiZe3fGKywIboFSshY3pnN3A7asIIJH6qx0GAyhqYDlK63t2MzRdsGWvO Cg6ftpXNajft2hhYplLSLYBFI4Ol/htD6VA2HvJ7WbGqSr5pFkN1bZEhR25X4/dB9Vg+ RInqcW47QmKpMowXvGw876aHJvjOjlRcTcoQFGkufmrxrR8eVYzW8lWFmb++C2f3SPSx w1bweUyfIp9VvlAilmSxksI5SI+BaC0SVqk18e2lCSCIpJw9cnW+CnjgvSA1L2JEZAhQ RCiArC2Ps9VcsKf9Z5gMy23vSMA47h8WIE2jGdErrB04B+XIlfqGWXVumYiHG2Kpr3jk BFHQ== 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 w12si3952835plq.387.2019.05.16.00.04.03; Thu, 16 May 2019 00:04: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 S1726613AbfEPHCt (ORCPT + 99 others); Thu, 16 May 2019 03:02:49 -0400 Received: from mga07.intel.com ([134.134.136.100]:16965 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726319AbfEPHCt (ORCPT ); Thu, 16 May 2019 03:02:49 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 May 2019 00:02:47 -0700 X-ExtLoop1: 1 Received: from odonnabh-mobl.ger.corp.intel.com (HELO localhost) ([10.252.32.47]) by fmsmga007.fm.intel.com with ESMTP; 16 May 2019 00:02:38 -0700 Date: Thu, 16 May 2019 10:02:36 +0300 From: Jarkko Sakkinen To: Andy Lutomirski Cc: Sean Christopherson , Andy Lutomirski , 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: [PATCH v20 00/28] Intel SGX1 support Message-ID: <20190516070236.GA5589@linux.intel.com> References: <20190513102926.GD8743@linux.intel.com> <20190514104323.GA7591@linux.intel.com> <20190514204527.GC1977@linux.intel.com> <20190515103531.GB10917@linux.intel.com> <20190515110005.GA14718@linux.intel.com> <20190516050705.GB6388@linux.intel.com> <20190516065103.GA4642@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190516065103.GA4642@linux.intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.10.1 (2018-07-13) 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 09:51:03AM +0300, Jarkko Sakkinen wrote: > On Thu, May 16, 2019 at 08:07:05AM +0300, Jarkko Sakkinen wrote: > > On Wed, May 15, 2019 at 07:27:02AM -0700, Andy Lutomirski wrote: > > > > > > > On May 15, 2019, at 4:00 AM, Jarkko Sakkinen wrote: > > > > > > > >> On Wed, May 15, 2019 at 01:35:31PM +0300, Jarkko Sakkinen wrote: > > > >> This brings me to an open question in Andy's model: lets say that we > > > >> change the source for SIGSTRUCT from memory address to fd. How can the > > > >> policy prevent the use not creating a file containing a SIGSTRUCT and > > > >> passing fd of that to the EINIT ioctl? > > > > > > > > > > The policy will presumably check the label on the file that the fd points to. > > > > Right (checked SELinux documentation). > > > > Got one idea from this. Right now creation and initialization does not > > require any VMAs to be created (since v20). Requiring to map a VMA for > > copying the data would bring in my opinion a glitch to this model that > > we have done effort to build up. > > > > What if we similarly change EADD ioctl in a way that it'd take an fd > > and an offset? This way we can enforce policy to the source where the > > enclave data is loaded from. On the other hand, loading SIGSTRUCT from > > fd enforces a legit structure for the enclave. > > > > This would still allow to construct enclaves in VMA independent way. > > The API would turn into this: > > /** > * struct sgx_enclave_add_page - parameter structure for the > * %SGX_IOC_ENCLAVE_ADD_PAGE ioctl > * @fd: file containing the page data > * @offset: offset in the file containing the page data > * @secinfo: address for the SECINFO data > * @mrmask: bitmask for the measured 256 byte chunks > */ > struct sgx_enclave_add_page { > __u64 fd; > __u64 offset; > __u64 secinfo; > __u16 mrmask; > } __attribute__((__packed__)); > > > /** > * struct sgx_enclave_init - parameter structure for the > * %SGX_IOC_ENCLAVE_INIT ioctl > * @fd: file containing the sigstruct > * @offset: offset in the file containing the sigstruct > */ > struct sgx_enclave_init { > __u64 fd; > __u64 offset; > }; The change to EADD/EINIT ioctl's would be simply fget/kernel_read/fput sequence replacing copy_from_user(). /Jarkko