Skip to content

Commit 0a1d529

Browse files
thejhtorvalds
authored andcommitted
mm: enforce min addr even if capable() in expand_downwards()
security_mmap_addr() does a capability check with current_cred(), but we can reach this code from contexts like a VFS write handler where current_cred() must not be used. This can be abused on systems without SMAP to make NULL pointer dereferences exploitable again. Fixes: 8869477 ("security: protect from stack expansion into low vm addresses") Cc: stable@kernel.org Signed-off-by: Jann Horn <jannh@google.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 7d762d6 commit 0a1d529

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

mm/mmap.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2426,12 +2426,11 @@ int expand_downwards(struct vm_area_struct *vma,
24262426
{
24272427
struct mm_struct *mm = vma->vm_mm;
24282428
struct vm_area_struct *prev;
2429-
int error;
2429+
int error = 0;
24302430

24312431
address &= PAGE_MASK;
2432-
error = security_mmap_addr(address);
2433-
if (error)
2434-
return error;
2432+
if (address < mmap_min_addr)
2433+
return -EPERM;
24352434

24362435
/* Enforce stack_guard_gap */
24372436
prev = vma->vm_prev;

0 commit comments

Comments
 (0)