On Fri, May 17, 2019 at 10:43:01AM -0700, Andy Lutomirski wrote: > > > On May 17, 2019, at 10:29 AM, Sean Christopherson <sean.j.christopherson@xxxxxxxxx> wrote: > > > > AIUI, having FILE__WRITE and FILE__EXECUTE on /dev/sgx/enclave would allow > > *any* enclave/process to map EPC as RWX. Moving to anon inodes and thus > > PROCESS__EXECMEM achieves per-process granularity. > > How does anon_inode make any difference? Anon_inode is not the same thing as > anon_vma. In this snippet, IS_PRIVATE() is true for anon inodes, false for /dev/sgx/enclave. Because EPC memory is always shared, SELinux will never check PROCESS__EXECMEM for mprotect() on/dev/sgx/enclave. static int file_map_prot_check(struct file *file, unsigned long prot, int shared) { const struct cred *cred = current_cred(); u32 sid = cred_sid(cred); int rc = 0; if (default_noexec && (prot & PROT_EXEC) && (!file || IS_PRIVATE(file_inode(file)) || (!shared && (prot & PROT_WRITE)))) { /* * We are making executable an anonymous mapping or a * private file mapping that will also be writable. * This has an additional check. */ rc = avc_has_perm(&selinux_state, sid, sid, SECCLASS_PROCESS, PROCESS__EXECMEM, NULL); if (rc) goto error; } ... }