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

From: Jethro Beekman
Date: Fri May 10 2019 - 13:39:16 EST


On 2019-05-10 10:23, Xing, Cedric wrote:
... I think an alternative could be to treat an enclave file as a regular shared object so all IMA/LSM checks could be triggered/performed as part of the loading process, then let the driver "copy" those pages to EPC. ...

If compared to the idea of "enclave loader inside kernel", I think this alternative is much simpler and more flexible. In particular,
* It requires minimal change to the driver - just take EPCM permissions from source pages' VMA instead of from ioctl parameter.
* It requires little change to user mode enclave loader - just mmap() enclave file in the same way as dlopen() would do, then all IMA/LSM checks applicable to shared objects will be triggered/performed transparently.
* It doesn't assume/tie to specific enclave formats.

It does assume a specific format, namely, that the memory layout (including page types/permissions) of the enclave can be represented in a "flat file" on disk, or at least that the enclave memory contents consist of 4096-byte chunks in that file.

Of the formats I have described in my other email, the only format that satisfies this property is the "CPU-native (instruction stream)" format which is not in use today. The ELF/PE formats in use today don't satisfy this property as the files don't contain the TCS contents. The SGXS format doesn't satisfy this property because the enclave memory is represented with 256-byte chunks.

* It is extensible - Today every regular page within a process is allowed implicitly to be the source for an EPC page. In future, if at all desirable/necessary, IMA/LSM could be extended to leave a flag somewhere (e.g. in VMA) to indicate explicitly whether a regular page (or range) could be a source for EPC. Then SGX specific hooks/policies could be supported easily.

How do you think?

-Cedric


--
Jethro Beekman | Fortanix

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature