[PATCH] mm: fix VMA heap bounds checking

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



After selinux converting to VMA heap check helper, the gcl triggers
an execheap SELinux denial, which caused by different check logical.

The old from selinux only check VMA range within VMA heap range, and
the new will check the intersects between the two ranges, but the corner
cases(vm_end=start_brk, brk=vm_start) doesn't be handled correctly.

Since commit 11250fd12eb8 ("mm: factor out VMA stack and heap checks")
only a function extraction, it seems that the issue introduced from
commit 0db0c01b53a1 ("procfs: fix /proc/<pid>/maps heap check"), let's
fix above corner cases, meanwhile, corrent the wrong indentation of the
stack and heap check helpers.

Reported-and-tested-by: Ondrej Mosnacek <omosnace@xxxxxxxxxx>
Closes: https://lore.kernel.org/selinux/CAFqZXNv0SVT0fkOK6neP9AXbj3nxJ61JAY4+zJzvxqJaeuhbFw@xxxxxxxxxxxxxx/
Fixes: 0db0c01b53a1 ("procfs: fix /proc/<pid>/maps heap check")
Signed-off-by: Kefeng Wang <wangkefeng.wang@xxxxxxxxxx>
---
 include/linux/mm.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 1be544664f92..2bea89dc0bdf 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -886,8 +886,8 @@ static inline bool vma_is_anonymous(struct vm_area_struct *vma)
  */
 static inline bool vma_is_initial_heap(const struct vm_area_struct *vma)
 {
-       return vma->vm_start <= vma->vm_mm->brk &&
-		vma->vm_end >= vma->vm_mm->start_brk;
+	return vma->vm_start < vma->vm_mm->brk &&
+		vma->vm_end > vma->vm_mm->start_brk;
 }
 
 /*
@@ -901,8 +901,8 @@ static inline bool vma_is_initial_stack(const struct vm_area_struct *vma)
 	 * its "stack".  It's not even well-defined for programs written
 	 * languages like Go.
 	 */
-       return vma->vm_start <= vma->vm_mm->start_stack &&
-	       vma->vm_end >= vma->vm_mm->start_stack;
+	return vma->vm_start <= vma->vm_mm->start_stack &&
+		vma->vm_end >= vma->vm_mm->start_stack;
 }
 
 static inline bool vma_is_temporary_stack(struct vm_area_struct *vma)
-- 
2.27.0





[Index of Archives]     [Selinux Refpolicy]     [Linux SGX]     [Fedora Users]     [Fedora Desktop]     [Yosemite Photos]     [Yosemite Camping]     [Yosemite Campsites]     [KDE Users]     [Gnome Users]

  Powered by Linux