Skip to content

Commit cc92c28

Browse files
committed
[ARM] add address randomization to mmap()
Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org>
1 parent 990cb8a commit cc92c28

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

arch/arm/mm/mmap.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <linux/shm.h>
88
#include <linux/sched.h>
99
#include <linux/io.h>
10+
#include <linux/random.h>
1011
#include <asm/cputype.h>
1112
#include <asm/system.h>
1213

@@ -80,6 +81,9 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
8081
start_addr = addr = TASK_UNMAPPED_BASE;
8182
mm->cached_hole_size = 0;
8283
}
84+
/* 8 bits of randomness in 20 address space bits */
85+
if (current->flags & PF_RANDOMIZE)
86+
addr += (get_random_int() % (1 << 8)) << PAGE_SHIFT;
8387

8488
full_search:
8589
if (do_align)

0 commit comments

Comments
 (0)