Skip to content

Commit de04d29

Browse files
thejhgregkh
authored andcommitted
mm: enforce min addr even if capable() in expand_downwards()
commit 0a1d529 upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ff86bb4 commit de04d29

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

‎mm/mmap.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2391,12 +2391,11 @@ int expand_downwards(struct vm_area_struct *vma,
23912391
{
23922392
struct mm_struct *mm = vma->vm_mm;
23932393
struct vm_area_struct *prev;
2394-
int error;
2394+
int error = 0;
23952395

23962396
address &= PAGE_MASK;
2397-
error = security_mmap_addr(address);
2398-
if (error)
2399-
return error;
2397+
if (address < mmap_min_addr)
2398+
return -EPERM;
24002399

24012400
/* Enforce stack_guard_gap */
24022401
prev = vma->vm_prev;

0 commit comments

Comments
 (0)