SELinux Permissions Bypass via io_setup()
When a process tries to map memory using sys_mmap_pgoff(), vm_mmap_pgoff() is called, which first performs the LSM security check by calling security_mmap_file() and then calls do_mmap_pgoff(), which takes care of the rest and does not rerun the same security check. The syscall handler for io_setup() calls ioctx_alloc(), which calls aio_setup_ring(), which allocates memory via do_mmap_pgoff() - the method that doesn't contain the security check. aio_setup_ring() only requests that the memory is mapped as PROT_READ | PROT_WRITE; however, if the process has called personality(READ_IMPLIES_EXEC) before, this will actually result in the creation of a memory mapping that is both writable and executable, bypassing the SELinux restriction.