diff options
author | Nicolas Pitre <nico@fluxnic.net> | 2010-06-14 21:16:19 -0400 |
---|---|---|
committer | Nicolas Pitre <nico@fluxnic.net> | 2010-06-14 21:22:11 -0400 |
commit | cc92c28b2db5b406657ecc05235d4ca4e222ae34 (patch) | |
tree | 202734aa4fc2e5b9953deb3fa8a5d249e21a7fe2 /arch/arm/mm/mmap.c | |
parent | 990cb8acf23cab19a2930f1ed5e7dc108f89079b (diff) |
[ARM] add address randomization to mmap()
Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Diffstat (limited to 'arch/arm/mm/mmap.c')
-rw-r--r-- | arch/arm/mm/mmap.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c index f5abc51c5a0..4f5b39687df 100644 --- a/arch/arm/mm/mmap.c +++ b/arch/arm/mm/mmap.c @@ -7,6 +7,7 @@ #include <linux/shm.h> #include <linux/sched.h> #include <linux/io.h> +#include <linux/random.h> #include <asm/cputype.h> #include <asm/system.h> @@ -80,6 +81,9 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, start_addr = addr = TASK_UNMAPPED_BASE; 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: if (do_align) |