[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200220191510.GF3972@linux.intel.com>
Date: Thu, 20 Feb 2020 11:15:10 -0800
From: Sean Christopherson <sean.j.christopherson@...el.com>
To: Andy Lutomirski <luto@...nel.org>
Cc: Jordan Hand <jorhand@...ux.microsoft.com>,
Jarkko Sakkinen <jarkko.sakkinen@...ux.intel.com>,
LKML <linux-kernel@...r.kernel.org>, X86 ML <x86@...nel.org>,
linux-sgx@...r.kernel.org,
Andrew Morton <akpm@...ux-foundation.org>,
Dave Hansen <dave.hansen@...el.com>,
Neil Horman <nhorman@...hat.com>, npmccallum@...hat.com,
"Huang, Haitao" <haitao.huang@...el.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Thomas Gleixner <tglx@...utronix.de>,
"Svahn, Kai" <kai.svahn@...el.com>, Borislav Petkov <bp@...en8.de>,
Josh Triplett <josh@...htriplett.org>,
"Huang, Kai" <kai.huang@...el.com>,
David Rientjes <rientjes@...gle.com>,
"Xing, Cedric" <cedric.xing@...el.com>, puiterwijk@...hat.com,
LSM List <linux-security-module@...r.kernel.org>,
Suresh Siddha <suresh.b.siddha@...el.com>,
Haitao Huang <haitao.huang@...ux.intel.com>
Subject: Re: [PATCH v26 10/22] x86/sgx: Linux Enclave Driver
On Thu, Feb 20, 2020 at 10:51:37AM -0800, Andy Lutomirski wrote:
> On Thu, Feb 20, 2020 at 10:13 AM Sean Christopherson
> <sean.j.christopherson@...el.com> 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;
}
Powered by blists - more mailing lists