]> Git Repo - linux.git/commitdiff
mips: adjust brk randomization offset to fit generic version
authorAlexandre Ghiti <[email protected]>
Mon, 23 Sep 2019 22:39:11 +0000 (15:39 -0700)
committerLinus Torvalds <[email protected]>
Tue, 24 Sep 2019 22:54:12 +0000 (15:54 -0700)
This commit simply bumps up to 32MB and 1GB the random offset of brk,
compared to 8MB and 256MB, for 32bit and 64bit respectively.

Link: http://lkml.kernel.org/r/[email protected]
Suggested-by: Kees Cook <[email protected]>
Signed-off-by: Alexandre Ghiti <[email protected]>
Acked-by: Paul Burton <[email protected]>
Reviewed-by: Kees Cook <[email protected]>
Reviewed-by: Luis Chamberlain <[email protected]>
Cc: Albert Ou <[email protected]>
Cc: Alexander Viro <[email protected]>
Cc: Catalin Marinas <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: James Hogan <[email protected]>
Cc: Palmer Dabbelt <[email protected]>
Cc: Ralf Baechle <[email protected]>
Cc: Russell King <[email protected]>
Cc: Will Deacon <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
arch/mips/mm/mmap.c

index a7e84b2e71d75d402a0ce369b2c6057021fef94a..ff6ab87e9c563b61b0083ba4e470a23cf282d0c8 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/random.h>
 #include <linux/sched/signal.h>
 #include <linux/sched/mm.h>
+#include <linux/sizes.h>
 
 unsigned long shm_align_mask = PAGE_SIZE - 1;  /* Sane caches */
 EXPORT_SYMBOL(shm_align_mask);
@@ -189,11 +190,11 @@ static inline unsigned long brk_rnd(void)
        unsigned long rnd = get_random_long();
 
        rnd = rnd << PAGE_SHIFT;
-       /* 8MB for 32bit, 256MB for 64bit */
+       /* 32MB for 32bit, 1GB for 64bit */
        if (TASK_IS_32BIT_ADDR)
-               rnd = rnd & 0x7ffffful;
+               rnd = rnd & (SZ_32M - 1);
        else
-               rnd = rnd & 0xffffffful;
+               rnd = rnd & (SZ_1G - 1);
 
        return rnd;
 }
This page took 0.052784 seconds and 4 git commands to generate.