From 711e5650589c9d3c99706c6a5d52d2659519dc74 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Thu, 11 May 2017 16:02:49 -0400 Subject: [PATCH] randomize lower bits of the argument block This was based on the PaX RANDUSTACK feature in grsecurity, where all of the lower bits are randomized. PaX keeps 16-byte alignment. Signed-off-by: Daniel Micay --- fs/exec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/exec.c b/fs/exec.c index 65145a3df0651..7a44a665045c9 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -62,6 +62,7 @@ #include #include #include +#include #include #include @@ -300,6 +301,8 @@ static int __bprm_mm_init(struct linux_binprm *bprm) arch_bprm_mm_init(mm, vma); up_write(&mm->mmap_sem); bprm->p = vma->vm_end - sizeof(void *); + if (randomize_va_space) + bprm->p ^= get_random_int() & ~PAGE_MASK; return 0; err: up_write(&mm->mmap_sem);