aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Pitre <nico@fluxnic.net>2010-06-14 16:27:19 -0400
committerLeann Ogasawara <leann.ogasawara@canonical.com>2010-08-21 17:45:45 -0700
commit738ee294012e4d047e614b01b4a05551b7d55b67 (patch)
tree704db2b6ecdf465116218758aaddd5bf465ad580
parent64002030245c63657a5b0a1215336e3d485267e6 (diff)
[ARM] implement arch_randomize_brk()
For this feature to take effect, CONFIG_COMPAT_BRK must be turned off. This can safely be turned off for any EABI user space versions. Signed-off-by: Nicolas Pitre <nicolas.pitre@linaro.org> (cherry picked from commit 990cb8acf23cab19a2930f1ed5e7dc108f89079b) Signed-off-by: Leann Ogasawara <leann.ogasawara@canonical.com>
-rw-r--r--arch/arm/include/asm/elf.h3
-rw-r--r--arch/arm/kernel/process.c7
2 files changed, 10 insertions, 0 deletions
diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
index 51662feb9f1..0a96e8c1b82 100644
--- a/arch/arm/include/asm/elf.h
+++ b/arch/arm/include/asm/elf.h
@@ -121,4 +121,7 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
extern void elf_set_personality(const struct elf32_hdr *);
#define SET_PERSONALITY(ex) elf_set_personality(&(ex))
+extern unsigned long arch_randomize_brk(struct mm_struct *mm);
+#define arch_randomize_brk arch_randomize_brk
+
#endif
diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
index aa4cfb5ddf4..43557a1eb61 100644
--- a/arch/arm/kernel/process.c
+++ b/arch/arm/kernel/process.c
@@ -28,6 +28,7 @@
#include <linux/tick.h>
#include <linux/utsname.h>
#include <linux/uaccess.h>
+#include <linux/random.h>
#include <asm/leds.h>
#include <asm/processor.h>
@@ -432,3 +433,9 @@ unsigned long get_wchan(struct task_struct *p)
} while (count ++ < 16);
return 0;
}
+
+unsigned long arch_randomize_brk(struct mm_struct *mm)
+{
+ unsigned long range_end = mm->brk + 0x02000000;
+ return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
+}