diff options
| author | Daniel Micay <danielmicay@gmail.com> | 2017-05-11 16:02:49 -0400 |
|---|---|---|
| committer | Moyster <oysterized@gmail.com> | 2018-05-16 13:29:19 +0200 |
| commit | 8e0884d3c03fa3b61e1948c851fe434c6d4d3f39 (patch) | |
| tree | 2e69e0d3583488d0b36c8004d423d58c3e0314e4 | |
| parent | d3daa0d30b3d151dcfc2cd5a3b707bb3b1602409 (diff) | |
| download | android_kernel_m2note-8e0884d3c03fa3b61e1948c851fe434c6d4d3f39.tar.gz | |
randomize lower bits of the argument block
This was extracted from the PaX RANDUSTACK feature in grsecurity, where
all of the lower bits are randomized. PaX keeps 16-byte alignment.
Signed-off-by: Daniel Micay <danielmicay@gmail.com>
| -rw-r--r-- | fs/exec.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -55,6 +55,7 @@ #include <linux/pipe_fs_i.h> #include <linux/oom.h> #include <linux/compat.h> +#include <linux/random.h> #include <asm/uaccess.h> #include <asm/mmu_context.h> @@ -297,6 +298,8 @@ static int __bprm_mm_init(struct linux_binprm *bprm) mm->stack_vm = mm->total_vm = 1; up_write(&mm->mmap_sem); bprm->p = vma->vm_end - sizeof(void *); + if (randomize_va_space) + bprm->p ^= get_random_long() & ~PAGE_MASK; return 0; err: up_write(&mm->mmap_sem); |
