Commit cc92c28b authored by Nicolas Pitre's avatar Nicolas Pitre

[ARM] add address randomization to mmap()

Signed-off-by: default avatarNicolas Pitre <nicolas.pitre@linaro.org>
parent 990cb8ac
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <linux/shm.h> #include <linux/shm.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/random.h>
#include <asm/cputype.h> #include <asm/cputype.h>
#include <asm/system.h> #include <asm/system.h>
...@@ -80,6 +81,9 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, ...@@ -80,6 +81,9 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
start_addr = addr = TASK_UNMAPPED_BASE; start_addr = addr = TASK_UNMAPPED_BASE;
mm->cached_hole_size = 0; mm->cached_hole_size = 0;
} }
/* 8 bits of randomness in 20 address space bits */
if (current->flags & PF_RANDOMIZE)
addr += (get_random_int() % (1 << 8)) << PAGE_SHIFT;
full_search: full_search:
if (do_align) if (do_align)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment