Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mips: use STACK_TOP when computing mmap base address

mmap base address must be computed wrt stack top address, using TASK_SIZE
is wrong since STACK_TOP and TASK_SIZE are not equivalent.

Link: http://lkml.kernel.org/r/20190730055113.23635-11-alex@ghiti.fr
Signed-off-by: Alexandre Ghiti <alex@ghiti.fr>
Acked-by: Kees Cook <keescook@chromium.org>
Acked-by: Paul Burton <paul.burton@mips.com>
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: James Hogan <jhogan@kernel.org>
Cc: Palmer Dabbelt <palmer@sifive.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Alexandre Ghiti and committed by
Linus Torvalds
b5fb8617 b1f61b5b

+2 -2
+2 -2
arch/mips/mm/mmap.c
··· 22 22 23 23 /* gap between mmap and stack */ 24 24 #define MIN_GAP (128*1024*1024UL) 25 - #define MAX_GAP ((TASK_SIZE)/6*5) 25 + #define MAX_GAP ((STACK_TOP)/6*5) 26 26 #define STACK_RND_MASK (0x7ff >> (PAGE_SHIFT - 12)) 27 27 28 28 static int mmap_is_legacy(struct rlimit *rlim_stack) ··· 54 54 else if (gap > MAX_GAP) 55 55 gap = MAX_GAP; 56 56 57 - return PAGE_ALIGN(TASK_SIZE - gap - rnd); 57 + return PAGE_ALIGN(STACK_TOP - gap - rnd); 58 58 } 59 59 60 60 #define COLOUR_ALIGN(addr, pgoff) \