Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp375597yba; Wed, 15 May 2019 03:01:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqzYuO63TGavYRf2xnKI2KH6ubBJOwdygtiBtVY1VUDCKhqVuUINmB0cQu8acicCSg+xz510 X-Received: by 2002:a63:ee10:: with SMTP id e16mr36983143pgi.207.1557914494712; Wed, 15 May 2019 03:01:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557914494; cv=none; d=google.com; s=arc-20160816; b=XNF2F7LRRPZ+jViulV5fRH7n08Zff/NCTlhAGZJlgFd2//16BY1HP8o5gWgVNoso55 Ro1mnIAY0twkG4NfQhGw1937YC/qElsEQeewjN8SgHKy4amtHrg83jctR4nIYsdD+UrZ rczUd+Un8DEDczhnsV/N4cRYixA1bss0+gIjIl/YiNH4PoY4Qo7y+1BjJQZkzOQsJZov r3wLdx3VNTHQZzaoeS3eiTnsgwXPfJGqEiVyM74HC0VCr4Sb3qojtbAYLkQJWJLJanAz 2jklD0BM2QRChQOalT1UWJ5VhItNr4TL4mFkgY/zLffERlWoO5msQj13yszQz45bcyUb M7Kg== 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=uZv61dQsoZ/SYmHW20c5L3HIlUamAQ0lUDeqIFw5vGo=; b=AeC9A9FtGBHB8Gx4mPHvO8t7ERX/NEccBEpg9zyPvT8JmRiJbSe9QmMnCIXx6EBP5a Viy4Web2ciZRxxF4L7WFjmDi+qKSctBChiHt8Gu7pWeR0H6Fa7C7KdfIaVMudtTuIWYE 6ya0depbksqbUvnjekaOdW9OgdOQalhdRl7pdUULXqFz7UKCVkICXFF6TGZ0HCAFJM+q V0DgeC4SPcrnPs02OKUx52d8cP/dpNIV6ncODv1ZWMSRvH63KecURNidN0ZYQC8bcU04 jpWdM2OgWNLSIV4nUvrAuF0otTW+WStqYCvE+dhhliX/NJT6FAfoalWmEAT3NDHK9jen aCRg== 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 d23si1481526pgv.513.2019.05.15.03.01.17; Wed, 15 May 2019 03:01:34 -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 S1726475AbfEOJ6i (ORCPT + 99 others); Wed, 15 May 2019 05:58:38 -0400 Received: from mga09.intel.com ([134.134.136.24]:11059 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725977AbfEOJ6h (ORCPT ); Wed, 15 May 2019 05:58:37 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 May 2019 02:58:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,472,1549958400"; d="scan'208";a="171908010" Received: from jsakkine-mobl1.tm.intel.com (HELO localhost) ([10.237.50.189]) by fmsmga002.fm.intel.com with ESMTP; 15 May 2019 02:58:31 -0700 Date: Wed, 15 May 2019 12:58:40 +0300 From: Jarkko Sakkinen To: Andy Lutomirski Cc: Jethro Beekman , "Xing, Cedric" , "Hansen, Dave" , Thomas Gleixner , "Dr. Greg" , Linus Torvalds , LKML , X86 ML , "linux-sgx@vger.kernel.org" , Andrew Morton , "Christopherson, Sean J" , "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: <20190515095840.GA10917@linux.intel.com> References: <979615a8-fd03-e3fd-fbdb-65c1e51afd93@fortanix.com> <8fe520bb-30bd-f246-a3d8-c5443e47a014@intel.com> <358e9b36-230f-eb18-efdb-b472be8438b4@fortanix.com> <960B34DE67B9E140824F1DCDEC400C0F4E886094@ORSMSX116.amr.corp.intel.com> <6da269d8-7ebb-4177-b6a7-50cc5b435cf4@fortanix.com> <20190513102926.GD8743@linux.intel.com> <20190514104323.GA7591@linux.intel.com> <20190515084909.GA10043@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190515084909.GA10043@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 Wed, May 15, 2019 at 11:49:09AM +0300, Jarkko Sakkinen wrote: > On Tue, May 14, 2019 at 08:13:36AM -0700, Andy Lutomirski wrote: > > On Tue, May 14, 2019 at 3:43 AM Jarkko Sakkinen > > wrote: > > > > > > On Mon, May 13, 2019 at 01:29:26PM +0300, Jarkko Sakkinen wrote: > > > > I did study through SDK's file format and realized that it does not > > > > does make sense after all to embed one. > > > > > > > > To implement it properly you would probably need a new syscall (lets say > > > > sgx_load_enclave) and also that enclaves are not just executables > > > > binaries. It is hard to find a generic format for them as applications > > > > range from simply protecting part of an application to running a > > > > containter inside enclave. > > > > > > I'm still puzzling what kind of changes you were discussing considering > > > SGX_IOC_ENCLAVE_ADD_PAGE. > > > > I think it's as simple as requiring that, if SECINFO.X is set, then > > the src pointer points to the appropriate number of bytes of > > executable memory. (Unless there's some way for an enclave to change > > SECINFO after the fact -- is there?) Sadly, we don't really have the > > a nice in-kernel API for that right now. You could do > > down_read(mmap_sem) and find_vma(). Arguably there is no value to > > checking that PKRU allows execute to the data. > > OK, so you would actually go on to check whether the VMA where the data > is copied contains executable data? > > What if SECINFO.X is not set and you EADD to region that is executable > in the enclave VMA? E.g. have RWX VMA for the enclave just to give a > simple example. Then you could carry executable code in the data > sections of the binary. This would require to be done after the enclave is initialized of course with EMODPR, which requires the enclave to accept the permission change with EACCEPT, which limits somewhat. This means that the static enclave would be fully covered. /Jarkko