Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4682307ybi; Mon, 3 Jun 2019 15:28:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqzKc2CQla98tw+6YL/IF2tlZ2LOI/+RYsNsrt+8Inuzog0y4s7edMSfmhvLx9RRVXnPq3RU X-Received: by 2002:a63:f402:: with SMTP id g2mr27296604pgi.197.1559600928870; Mon, 03 Jun 2019 15:28:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559600928; cv=none; d=google.com; s=arc-20160816; b=PScWCEhLz3we4UZIGgWmPfiETSP9UdeZ4pQRUorMyIiraSVgQUm+1cp5i+peAdPvs4 i8BRvKvjEgnW2vjiVgsyUm1UoeOTRVwlX5b0p7Gi2iEwq5IFufcuN+Igk4aTjeb9giil pW5/6YtvPJbMcxk2ALUiJ8Gwc5OwsE3EwnblGu99rxV2h9WkxCRqtTjw8Nf1wekxrMMC Df5HNExifViNvA4YIShitYruVwP4BBa3txnsT/DhR087P1AkiSTb5is7UZW22USNip0l HSw0JJWpD9w5ouoZnFY2MwzwXTk1z7J5oanremEtTEGFlVBXwzqT4IOTRcWReJBkHf0p fTEg== 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=c8IY9OCZhJ8D6N6mcpIGXo0xXDawlqgVPtqQcJcYdI4=; b=DDW/DeLwOM+K/zuJalibkhR0+h4GFP5J0uEbgKbG0Esc4SR0wHa8xzpPawxE0Yhm85 zFtGOnn2azHXtPXtYFUJtYyAwSawVWF6GuczyebDx9M5pfRMzksf35tAB9Q2hVOckZ28 FwgUb7AG2GC0QnadZcLG4AvfDmbOGbUwPakrOOUkyuVp7UiHNr9ffjjumopFCggB5uXt HYuEka0LSxafrrKEEwgVsu7ntzsAAQyAlAVANt2ZuEP2unqTeGdHvuXgqFOJKRZtqFpC up33flWGQauJi3JU3T9YUJKdZ6OgHj13TMWfWNOFH/qkSRxfk44ySiRAuLR/W6rgLZe7 qqWw== 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 f9si19024715pgs.115.2019.06.03.15.28.33; Mon, 03 Jun 2019 15:28:48 -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 S1726465AbfFCW1Z (ORCPT + 99 others); Mon, 3 Jun 2019 18:27:25 -0400 Received: from mga18.intel.com ([134.134.136.126]:27917 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726025AbfFCW1Z (ORCPT ); Mon, 3 Jun 2019 18:27:25 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Jun 2019 14:05:46 -0700 X-ExtLoop1: 1 Received: from jgaire-mobl.ger.corp.intel.com (HELO localhost) ([10.252.20.169]) by fmsmga005.fm.intel.com with ESMTP; 03 Jun 2019 14:05:35 -0700 Date: Tue, 4 Jun 2019 00:05:34 +0300 From: Jarkko Sakkinen To: Sean Christopherson 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: <20190603210534.GF4894@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> <20190530180110.GB23930@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190530180110.GB23930@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 30, 2019 at 11:01:10AM -0700, Sean Christopherson wrote: > - Requires enclave builder to mark enclave pages executable in the > non-enclave VMAs, which may unnecessarily require EXECMOD on the > source file, or even worse, EXECMEM, and potentially increases the > attack surface since the file must be executable. Enclave builder marks *non-enclave pages*? Not following. > W^X handling: > - mmap() to /dev/sgx/enclave only allowed with PROT_NONE, i.e. force > userspace through mprotect() to simplify the kernel implementation. > - Add vm_ops mprotect() ops hook (I'll refer to SGX's implementation > as SGX.mprotect()) > - Take explicit ALLOW_WRITE at ADD_REGION, a.k.a. EADD > - ADD_REGION also used to describe EAUG region (tentatively for SGX2). > - Track "can be written at some point in time (past or future)" as > ALLOW_WRITE (to avoid confusiong with MAY_WRITE). A priori knowledge > of writability avoids having to track/coordinate PROT_WRITE across > VMAs and MMs. Still not sure why you want to use vm_ops instead of file_operations. The approach I've been proposing earlier in this email thread before these new proposals can be summarized from hook perspective as: - Allow mmap() only before ECREATE and require it to be size of the ELRANGE (ECREATE ioctl would check this). This would be with PROT_NONE. - Disallow mprotect() before EINIT. Requires a new callback to file_operations like mmap() has. - After EINIT check for each mprotect() that it matches the permissions of underlying enclave pages. Disallow mmap() after EINIT. /Jarkko