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 D17C4C28CC6 for ; Tue, 4 Jun 2019 20:34:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B56F22070B for ; Tue, 4 Jun 2019 20:34:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726613AbfFDUer (ORCPT ); Tue, 4 Jun 2019 16:34:47 -0400 Received: from mga14.intel.com ([192.55.52.115]:52259 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726530AbfFDUeq (ORCPT ); Tue, 4 Jun 2019 16:34:46 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Jun 2019 13:34:45 -0700 X-ExtLoop1: 1 Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.36]) by orsmga008.jf.intel.com with ESMTP; 04 Jun 2019 13:34:45 -0700 Date: Tue, 4 Jun 2019 13:34:45 -0700 From: Sean Christopherson To: Andy Lutomirski Cc: Jarkko Sakkinen , 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: <20190604203445.GB7775@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> 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 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. Agreed. I've already (somewhat unknowingly) reworked the SELinux patch such that it ignores @prot (the SECINFO protections) and only looks at @allowed_prot (the declared protections). If the kernel ignores SECINFO protections entirely then the LSM hook can simply be: int selinux_enclave_load(struct vm_area_struct *vma, unsigned long prot) I.e. LSMs can be blissfully unaware that @prot isn't technically what's going into the PTEs *now*.