diff options
author | Heiko Carstens <heiko.carstens@de.ibm.com> | 2011-01-12 09:55:27 +0100 |
---|---|---|
committer | Martin Schwidefsky <sky@mschwide.boeblingen.de.ibm.com> | 2011-01-12 09:55:25 +0100 |
commit | df1ca53cba34b1d40a4ed47907d71397e4ee72c2 (patch) | |
tree | cbfc440a178eaadbfea7af7dbf0b2d69dec48a1b /arch/s390 | |
parent | 1060f62ea47e609b0c1672e8d1ac216e57f11a8e (diff) | |
download | linux-df1ca53cba34b1d40a4ed47907d71397e4ee72c2.tar.gz linux-df1ca53cba34b1d40a4ed47907d71397e4ee72c2.tar.bz2 linux-df1ca53cba34b1d40a4ed47907d71397e4ee72c2.zip |
[S390] Randomize mmap start address
Randomize mmap start address with 8MB.
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch/s390')
-rw-r--r-- | arch/s390/mm/mmap.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c index 74d663f367e2..c9a9f7f18188 100644 --- a/arch/s390/mm/mmap.c +++ b/arch/s390/mm/mmap.c @@ -27,6 +27,7 @@ #include <linux/personality.h> #include <linux/mm.h> #include <linux/module.h> +#include <linux/random.h> #include <asm/pgalloc.h> #include <asm/compat.h> @@ -56,6 +57,14 @@ static inline int mmap_is_legacy(void) return sysctl_legacy_va_layout; } +static unsigned long mmap_rnd(void) +{ + if (!(current->flags & PF_RANDOMIZE)) + return 0; + /* 8MB randomization for mmap_base */ + return (get_random_int() & 0x7ffUL) << PAGE_SHIFT; +} + static inline unsigned long mmap_base(void) { unsigned long gap = rlimit(RLIMIT_STACK); @@ -64,8 +73,8 @@ static inline unsigned long mmap_base(void) gap = MIN_GAP; else if (gap > MAX_GAP) gap = MAX_GAP; - - return STACK_TOP - stack_maxrandom_size() - (gap & PAGE_MASK); + gap &= PAGE_MASK; + return STACK_TOP - stack_maxrandom_size() - mmap_rnd() - gap; } #ifndef CONFIG_64BIT |