Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1004913ybv; Thu, 20 Feb 2020 11:15:44 -0800 (PST) X-Google-Smtp-Source: APXvYqyJzMsIBvbBHYs8GSiWukL7b7vvt6DWGSXVtIIOHhbBEW6DHZODt/gEhBSYyFDBEp9FnLYe X-Received: by 2002:aca:d4ca:: with SMTP id l193mr3369931oig.133.1582226144473; Thu, 20 Feb 2020 11:15:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582226144; cv=none; d=google.com; s=arc-20160816; b=CgNQpHmqhyFBCCJTMgwcCnzA0YjdNv2vUjfitAIhht6ktV1htO6wfiRr27orl4+7Qz CeUP3QWWMQY5zRCWDKlwAnPvQfxNfhTAuZluux1VYretyOkKwo8bBNffWPETJp5s3GrG 6WaRp/YJWHV+P76AoeSIOPoMRwdOh+QozinrFT+IRZ+sQMC/T2BF/9G5lhL8RtOVX1AB kSCibOpJ88JS08SXuK3IeLohdftySPtBObXeE3BfAFhqiW0buJR2ePUgMSMoSEJbmNoP RTVBI1e6cWlNQgFWgoOICKIjTU5qnFJL6DLywTrG+6BAPZVtBV0Ggif6WPLUmx/FGVpu dh6Q== 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=uhSITuP8j1iaxnsClk9UCicwjc9K98r42PUVUJcJGQE=; b=m0ZJk07aogKUQ5wrqDcoA9qYhS7Eum0w/TRLp7P921Dyv/fX3ZPUwPzABci3cw5WjP 4nL/x/rokqny6oj03bwgTyS9TO36+PGL6vGj8m7oKzqpZK/WvGrGCqyMUPQYCH7T4j6L FHI3jPGUxLVKSn6ZGpZ6dhBhSXrTYQYVQs26NqNNAwOlQePa0aQzXMmkgx5SZRvGlbd+ ANzCQ3UUm9OVhejH3zj7r84/LEibMe+9HMzyLYZCRYfAo9yGnGzi4I4opIJltX29Efsg Eif0UOpgJx6GMT/ZnjYfQnt3C4FItX8TTHsqhJJXVnk5+q9W9I2Hxdp2L8v9kzgt5kR4 9Jag== 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 z26si164555oti.215.2020.02.20.11.15.27; Thu, 20 Feb 2020 11:15:44 -0800 (PST) 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 S1728618AbgBTTPM (ORCPT + 99 others); Thu, 20 Feb 2020 14:15:12 -0500 Received: from mga05.intel.com ([192.55.52.43]:49172 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728111AbgBTTPM (ORCPT ); Thu, 20 Feb 2020 14:15:12 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Feb 2020 11:15:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,465,1574150400"; d="scan'208";a="434935036" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.202]) by fmsmga005.fm.intel.com with ESMTP; 20 Feb 2020 11:15:10 -0800 Date: Thu, 20 Feb 2020 11:15:10 -0800 From: Sean Christopherson To: Andy Lutomirski Cc: Jordan Hand , Jarkko Sakkinen , LKML , X86 ML , linux-sgx@vger.kernel.org, Andrew Morton , Dave Hansen , Neil Horman , npmccallum@redhat.com, "Huang, Haitao" , Andy Shevchenko , Thomas Gleixner , "Svahn, Kai" , Borislav Petkov , Josh Triplett , "Huang, Kai" , David Rientjes , "Xing, Cedric" , puiterwijk@redhat.com, LSM List , Suresh Siddha , Haitao Huang Subject: Re: [PATCH v26 10/22] x86/sgx: Linux Enclave Driver Message-ID: <20200220191510.GF3972@linux.intel.com> References: <20200209212609.7928-1-jarkko.sakkinen@linux.intel.com> <20200209212609.7928-11-jarkko.sakkinen@linux.intel.com> <15074c16-4832-456d-dd12-af8548e46d6d@linux.microsoft.com> <20200220181345.GD3972@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Thu, Feb 20, 2020 at 10:51:37AM -0800, Andy Lutomirski wrote: > On Thu, Feb 20, 2020 at 10:13 AM Sean Christopherson > wrote: > > More than likely, the READ_IMPLIES_EXECUTE (RIE) crud rears its head > > because part of the enclave loader is written in assembly. Unless > > explicitly told otherwise, the linker assumes that any program with > > assembly code may need an executable stack, which leads to the RIE > > personality being set for the process. Here's a fantastic write up for > > more details: https://www.airs.com/blog/archives/518 > > > > There are essentially two paths we can take: > > > > 1) Exempt EPC pages from RIE during mmap()/mprotect(), i.e. don't add > > PROT_EXEC for enclaves. > > Seems reasonable. > > Honestly, it probably makes sense to try to exempt almost everything > from RIE. I'd be a bit surprised if RIE is actually useful for > anything other than plain anonymous pages and private file mappings. Hmm, last I looked at this I was focused on adding a generic protections manipulator, e.g. vm_ops->mprotect_adjust() and f_op->???, and I thought those options were too ugly to pursue. But if we want to start killing RIE specifically, adding a boolean flag to and f_op wouldn't be _that_ heinous, e.g. static int do_mprotect_pkey(...) { ... /* Does the application expect PROT_READ to imply PROT_EXEC */ if (rier && (vma->vm_flags & VM_MAYEXEC) && (!vma->vm_file || !vma->vm_file->f_op->no_read_implies_exec)) prot |= PROT_EXEC; } unsigned long do_mmap(...) { if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC)) if (!file || (!path_noexec(&file->f_path) && !file->f_op->no_read_implies_exec)) prot |= PROT_EXEC; }