aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-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