Currently, SELinux implements the "execstack" capability using the following code: security/selinux/hooks.c function: selinux_file_mprotect() } else if (!vma->vm_file && vma->vm_start <= vma->vm_mm->start_stack && vma->vm_end >= vma->vm_mm->start_stack) { rc = current_has_perm(current, PROCESS__EXECSTACK); } However, at least on Android, this check doesn't work for pthread allocated stacks. Those stacks are allocated in libc via mmap(), and aren't accounted for in the kernel as stack pages. As a result, attempting to mprotect(PROT_EXEC) a pthread stack page requires the "execmem" permission, not the "execstack" permission. "man mmap" defines MAP_STACK, which is currently a no-op in the kernel indicating that the memory is intended to be used as a stack. In theory, Android's libc could set this flag for memory intended to be used as a stack, but doing so is useless if the kernel ignores it. Is there any reason why SELinux shouldn't use MAP_STACK to determine whether the execmem or execstack capability is checked? In Android, this would be a net security win, since nobody is granted execstack today. -- Nick Kralevich | Android Security | nnk@xxxxxxxxxx | 650.214.4037 _______________________________________________ Selinux mailing list Selinux@xxxxxxxxxxxxx To unsubscribe, send email to Selinux-leave@xxxxxxxxxxxxx. To get help, send an email containing "help" to Selinux-request@xxxxxxxxxxxxx.