From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_MUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 723A0C46460 for ; Thu, 6 Jun 2019 01:01:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 55E5F20872 for ; Thu, 6 Jun 2019 01:01:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726642AbfFFBBg (ORCPT ); Wed, 5 Jun 2019 21:01:36 -0400 Received: from mga04.intel.com ([192.55.52.120]:55823 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726573AbfFFBBg (ORCPT ); Wed, 5 Jun 2019 21:01:36 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Jun 2019 18:01:35 -0700 X-ExtLoop1: 1 Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.36]) by orsmga006.jf.intel.com with ESMTP; 05 Jun 2019 18:01:34 -0700 Date: Wed, 5 Jun 2019 18:01:34 -0700 From: Sean Christopherson To: Jarkko Sakkinen Cc: Andy Lutomirski , Cedric Xing , Stephen Smalley , James Morris , "Serge E . Hallyn" , LSM List , Paul Moore , Eric Paris , selinux@vger.kernel.org, Jethro Beekman , Dave Hansen , Thomas Gleixner , Linus Torvalds , LKML , X86 ML , linux-sgx@vger.kernel.org, Andrew Morton , nhorman@redhat.com, npmccallum@redhat.com, Serge Ayoun , Shay Katz-zamir , Haitao Huang , Andy Shevchenko , Kai Svahn , Borislav Petkov , Josh Triplett , Kai Huang , David Rientjes , William Roberts , Philip Tricca Subject: Re: [RFC PATCH 7/9] x86/sgx: Enforce noexec filesystem restriction for enclaves Message-ID: <20190606010134.GJ26328@linux.intel.com> References: <20190531233159.30992-1-sean.j.christopherson@intel.com> <20190531233159.30992-8-sean.j.christopherson@intel.com> <20190604162555.GC3811@linux.intel.com> <20190605151006.GI11331@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190605151006.GI11331@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 Wed, Jun 05, 2019 at 06:10:18PM +0300, Jarkko Sakkinen wrote: > On Tue, Jun 04, 2019 at 01:25:10PM -0700, Andy Lutomirski wrote: > > On Tue, Jun 4, 2019 at 9:26 AM Jarkko Sakkinen > > wrote: > > > > > > On Fri, May 31, 2019 at 04:31:57PM -0700, Sean Christopherson wrote: > > > > Do not allow an enclave page to be mapped with PROT_EXEC if the source > > > > page is backed by a file on a noexec file system. > > > > > > > > Signed-off-by: Sean Christopherson > > > > > > Why don't you just check in sgx_encl_add_page() that whether the path > > > comes from noexec and deny if SECINFO contains X? > > > > > > > SECINFO seems almost entirely useless for this kind of thing because > > of SGX2. I'm thinking that SECINFO should be completely ignored for > > anything other than its required architectural purpose. > > Not exactly sure why using it to pass the RWX bits to EADD ioctl would > cause anything to SGX2 support. Andy was pointing out that with SGX2 the enclave can do ENCLU[EMODPE] to make the page executable, e.g. add the page with SECINFO.R and then mprotect() the enclave VMA (whose vm_file == /dev/sgx/enclave) PROT_EXEC. We could hard enforce SECINFO, i.e. set the enclave page's protection bits directly from SECINFO, but that would neuter SGX2, e.g. would break converting RW to RX.