1 From 0a1d52994d440e21def1c2174932410b4f2a98a1 Mon Sep 17 00:00:00 2001
2 From: Jann Horn <jannh@google.com>
3 Date: Wed, 27 Feb 2019 21:29:52 +0100
4 Subject: mm: enforce min addr even if capable() in expand_downwards()
6 From: Jann Horn <jannh@google.com>
8 commit 0a1d52994d440e21def1c2174932410b4f2a98a1 upstream.
10 security_mmap_addr() does a capability check with current_cred(), but
11 we can reach this code from contexts like a VFS write handler where
12 current_cred() must not be used.
14 This can be abused on systems without SMAP to make NULL pointer
15 dereferences exploitable again.
17 Fixes: 8869477a49c3 ("security: protect from stack expansion into low vm addresses")
19 Signed-off-by: Jann Horn <jannh@google.com>
20 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
21 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
25 1 file changed, 3 insertions(+), 4 deletions(-)
29 @@ -2292,12 +2292,11 @@ int expand_downwards(struct vm_area_stru
31 struct vm_area_struct *prev;
32 unsigned long gap_addr;
37 - error = security_mmap_addr(address);
40 + if (address < mmap_min_addr)
43 /* Enforce stack_guard_gap */
44 gap_addr = address - stack_guard_gap;