aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mm/mmap.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
index 5e85ed371364..15a8160096b3 100644
--- a/arch/arm/mm/mmap.c
+++ b/arch/arm/mm/mmap.c
@@ -169,14 +169,22 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
169 return addr; 169 return addr;
170} 170}
171 171
172static unsigned long mmap_rnd(void)
173{
174 unsigned long rnd;
175
176 /* 8 bits of randomness in 20 address space bits */
177 rnd = (unsigned long)get_random_int() % (1 << 8);
178
179 return rnd << PAGE_SHIFT;
180}
181
172void arch_pick_mmap_layout(struct mm_struct *mm) 182void arch_pick_mmap_layout(struct mm_struct *mm)
173{ 183{
174 unsigned long random_factor = 0UL; 184 unsigned long random_factor = 0UL;
175 185
176 /* 8 bits of randomness in 20 address space bits */ 186 if (current->flags & PF_RANDOMIZE)
177 if ((current->flags & PF_RANDOMIZE) && 187 random_factor = mmap_rnd();
178 !(current->personality & ADDR_NO_RANDOMIZE))
179 random_factor = (get_random_int() % (1 << 8)) << PAGE_SHIFT;
180 188
181 if (mmap_is_legacy()) { 189 if (mmap_is_legacy()) {
182 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor; 190 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;