Re: SGX vs LSM (Re: [PATCH v20 00/28] Intel SGX1 support)
From: James Morris
Date: Wed May 15 2019 - 16:00:46 EST
On Wed, 15 May 2019, Andy Lutomirski wrote:
> There are two issues with how this interacts with LSMs:
>
> 1) LSMs might want to be able to whitelist, blacklist, or otherwise
> restrict what enclaves can run at all. The current proposal that
> everyone seems to dislike the least is to have a .sigstruct file on
> disk that contains a hash and signature of the enclave in a
> CPU-defined format. To initialize an enclave, a program will pass an
> fd to this file, and a new LSM hook can be called to allow or disallow
> the operation. In a SELinux context, the idea is that policy could
> require the .sigstruct file to be labeled with a type like
> sgx_sigstruct_t, and only enclaves that have a matching .sigstruct
> with such a label could run.
The .sigstruct file is for the CPU to consume, not the kernel correct?
How is it bound to the enclave file?
Why not just use an xattr, like security.sgx ?
>
> 2) Just like any other DSO, there are potential issues with how
> enclaves deal with writable vs executable memory. This takes two
> forms. First, a task should probably require EXECMEM, EXECMOD, or
> similar permission to run an enclave that can modify its own text.
> Second, it would be nice if a task that did *not* have EXECMEM,
> EXECMOD, or similar could still run the enclave if it had EXECUTE
> permission on the file containing the enclave.
>
> Currently, this all works because DSOs are run by mmapping the file to
> create multiple VMAs, some of which are executable, non-writable, and
> non-CoWed, and some of which are writable but not executable. With
> SGX, there's only really one inode per enclave (the anon_inode that
> comes form /dev/sgx/enclave), and it can only be sensibly mapped
> MAP_SHARED.
>
> With the current version of the SGX driver, to run an enclave, I think
> you'll need either EXECUTE rights to /dev/sgx/enclave or EXECMOD or
> similar, all of which more or less mean that you can run any modified
> code you want, and none of which is useful to prevent enclaves from
> contain RWX segments.
>
> So my question is: what, if anything, should change to make this work better?
Would it be possible to provide multiple fds (perhaps via a pseudo fs
interface) which can be mapped to different types of VMAs?
--
James Morris
<jmorris@xxxxxxxxx>