Re: [PATCH v20 00/28] Intel SGX1 support

From: Jarkko Sakkinen
Date: Thu May 16 2019 - 01:03:42 EST


On Wed, May 15, 2019 at 06:21:47AM -0700, Sean Christopherson wrote:
> On Wed, May 15, 2019 at 01:35:31PM +0300, Jarkko Sakkinen wrote:
> > On Tue, May 14, 2019 at 01:45:27PM -0700, Sean Christopherson wrote:
> > > On Tue, May 14, 2019 at 08:13:36AM -0700, Andy Lutomirski wrote:
> > > > I think it's as simple as requiring that, if SECINFO.X is set, then
> > > > the src pointer points to the appropriate number of bytes of
> > > > executable memory. (Unless there's some way for an enclave to change
> > > > SECINFO after the fact -- is there?)
> > >
> > > Nit: SECINFO is just the struct passed to EADD, I think what you're really
> > > asking is "can the EPCM permissions be changed after the fact".
> > >
> > > And the answer is, yes.
> > >
> > > On SGX2 hardware, the enclave can extend the EPCM permissions at runtime
> > > via ENCLU[EMODPE], e.g. to make a page writable.
> >
> > Small correction: it is EMODPR.
>
> No, I'm referring to EMODPE, note the ENCLU classification.
>
> > Anyway, it is good to mention that these would require EACCEPT from the
> > enclave side. In order to take advantage of this is in a malicous
> > enclave, one would require SELinux/IMA/whatnot policy to have permitted
> > it in the first place.
>
> EMODPE doesn't require EACCEPT or any equivalent from the kernel. As
> you alluded to, the page tables would still need to allow PROT_EXEC. I
> was simply trying to answer Andy's question regarding SECINFO.

Ah, have to admit that I had totally forgot EMODPE :-) Have not had
to deal with that opcode that much.

/Jarkko