Skip to content

Commit 990cb8a

Browse files
committed
[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>
1 parent 7e27d6e commit 990cb8a

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

arch/arm/include/asm/elf.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,7 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
121121
extern void elf_set_personality(const struct elf32_hdr *);
122122
#define SET_PERSONALITY(ex) elf_set_personality(&(ex))
123123

124+
extern unsigned long arch_randomize_brk(struct mm_struct *mm);
125+
#define arch_randomize_brk arch_randomize_brk
126+
124127
#endif

arch/arm/kernel/process.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <linux/tick.h>
2929
#include <linux/utsname.h>
3030
#include <linux/uaccess.h>
31+
#include <linux/random.h>
3132

3233
#include <asm/leds.h>
3334
#include <asm/processor.h>
@@ -421,3 +422,9 @@ unsigned long get_wchan(struct task_struct *p)
421422
} while (count ++ < 16);
422423
return 0;
423424
}
425+
426+
unsigned long arch_randomize_brk(struct mm_struct *mm)
427+
{
428+
unsigned long range_end = mm->brk + 0x02000000;
429+
return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
430+
}

0 commit comments

Comments
 (0)