aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Micay <danielmicay@gmail.com>2017-05-11 16:02:49 -0400
committerMoyster <oysterized@gmail.com>2018-05-16 13:29:19 +0200
commit8e0884d3c03fa3b61e1948c851fe434c6d4d3f39 (patch)
tree2e69e0d3583488d0b36c8004d423d58c3e0314e4
parentd3daa0d30b3d151dcfc2cd5a3b707bb3b1602409 (diff)
downloadandroid_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.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/exec.c b/fs/exec.c
index ee10ebb57..632f839d5 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -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);