Skip to content

Commit 05a3d6e

Browse files
committed
selinux: revert our use of vma_is_initial_heap()
Unfortunately it appears that vma_is_initial_heap() is currently broken for applications that do not currently have any heap allocated, e.g. brk == start_brk. The breakage is such that it will cause SELinux to check for the process/execheap permission on memory regions that cross brk/start_brk even when there is no heap. The proper fix would be to correct vma_is_initial_heap(), but as there are multiple callers I am hesitant to unilaterally modify the helper out of concern that I would end up breaking some other subsystem. The mm developers have been made aware of the situation and hopefully they will have a fix at some point in the future, but we need a fix soon so we are simply going to revert our use of vma_is_initial_heap() in favor of our old logic/code which works as expected, even in the face of a zero size heap. We can return to using vma_is_initial_heap() at some point in the future when it is fixed. Cc: [email protected] Reported-by: Marc Reisner <[email protected]> Closes: https://lore.kernel.org/all/[email protected] Fixes: 68df1ba ("selinux: use vma_is_initial_stack() and vma_is_initial_heap()") Signed-off-by: Paul Moore <[email protected]>
1 parent 6dd1e4c commit 05a3d6e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

security/selinux/hooks.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3852,7 +3852,17 @@ static int selinux_file_mprotect(struct vm_area_struct *vma,
38523852
if (default_noexec &&
38533853
(prot & PROT_EXEC) && !(vma->vm_flags & VM_EXEC)) {
38543854
int rc = 0;
3855-
if (vma_is_initial_heap(vma)) {
3855+
/*
3856+
* We don't use the vma_is_initial_heap() helper as it has
3857+
* a history of problems and is currently broken on systems
3858+
* where there is no heap, e.g. brk == start_brk. Before
3859+
* replacing the conditional below with vma_is_initial_heap(),
3860+
* or something similar, please ensure that the logic is the
3861+
* same as what we have below or you have tested every possible
3862+
* corner case you can think to test.
3863+
*/
3864+
if (vma->vm_start >= vma->vm_mm->start_brk &&
3865+
vma->vm_end <= vma->vm_mm->brk) {
38563866
rc = avc_has_perm(sid, sid, SECCLASS_PROCESS,
38573867
PROCESS__EXECHEAP, NULL);
38583868
} else if (!vma->vm_file && (vma_is_initial_stack(vma) ||

0 commit comments

Comments
 (0)