aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHeiko Carstens <heiko.carstens@de.ibm.com>2011-01-12 03:55:27 -0500
committerMartin Schwidefsky <sky@mschwide.boeblingen.de.ibm.com>2011-01-12 03:55:25 -0500
commitdf1ca53cba34b1d40a4ed47907d71397e4ee72c2 (patch)
treecbfc440a178eaadbfea7af7dbf0b2d69dec48a1b
parent1060f62ea47e609b0c1672e8d1ac216e57f11a8e (diff)
[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>
-rw-r--r--arch/s390/mm/mmap.c13
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 @@
27#include <linux/personality.h> 27#include <linux/personality.h>
28#include <linux/mm.h> 28#include <linux/mm.h>
29#include <linux/module.h> 29#include <linux/module.h>
30#include <linux/random.h>
30#include <asm/pgalloc.h> 31#include <asm/pgalloc.h>
31#include <asm/compat.h> 32#include <asm/compat.h>
32 33
@@ -56,6 +57,14 @@ static inline int mmap_is_legacy(void)
56 return sysctl_legacy_va_layout; 57 return sysctl_legacy_va_layout;
57} 58}
58 59
60static unsigned long mmap_rnd(void)
61{
62 if (!(current->flags & PF_RANDOMIZE))
63 return 0;
64 /* 8MB randomization for mmap_base */
65 return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
66}
67
59static inline unsigned long mmap_base(void) 68static inline unsigned long mmap_base(void)
60{ 69{
61 unsigned long gap = rlimit(RLIMIT_STACK); 70 unsigned long gap = rlimit(RLIMIT_STACK);
@@ -64,8 +73,8 @@ static inline unsigned long mmap_base(void)
64 gap = MIN_GAP; 73 gap = MIN_GAP;
65 else if (gap > MAX_GAP) 74 else if (gap > MAX_GAP)
66 gap = MAX_GAP; 75 gap = MAX_GAP;
67 76 gap &= PAGE_MASK;
68 return STACK_TOP - stack_maxrandom_size() - (gap & PAGE_MASK); 77 return STACK_TOP - stack_maxrandom_size() - mmap_rnd() - gap;
69} 78}
70 79
71#ifndef CONFIG_64BIT 80#ifndef CONFIG_64BIT