summaryrefslogtreecommitdiff
path: root/sys-kernel/cairn-sources/files/5.10.10/hardened-patches/0087-randomize-lower-bits-of-the-argument-block.patch
diff options
context:
space:
mode:
Diffstat (limited to 'sys-kernel/cairn-sources/files/5.10.10/hardened-patches/0087-randomize-lower-bits-of-the-argument-block.patch')
-rw-r--r--sys-kernel/cairn-sources/files/5.10.10/hardened-patches/0087-randomize-lower-bits-of-the-argument-block.patch47
1 files changed, 47 insertions, 0 deletions
diff --git a/sys-kernel/cairn-sources/files/5.10.10/hardened-patches/0087-randomize-lower-bits-of-the-argument-block.patch b/sys-kernel/cairn-sources/files/5.10.10/hardened-patches/0087-randomize-lower-bits-of-the-argument-block.patch
new file mode 100644
index 000000000000..13a4242f2e9d
--- /dev/null
+++ b/sys-kernel/cairn-sources/files/5.10.10/hardened-patches/0087-randomize-lower-bits-of-the-argument-block.patch
@@ -0,0 +1,47 @@
+From 29f3c78257ea25a5452d9272ff85b4f764f16aef Mon Sep 17 00:00:00 2001
+From: Daniel Micay <danielmicay@gmail.com>
+Date: Thu, 11 May 2017 16:02:49 -0400
+Subject: [PATCH 087/113] 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 <danielmicay@gmail.com>
+[levente@leventepolyak.net: do not randomize with ADDR_NO_RANDOMIZE personality]
+Signed-off-by: Levente Polyak <levente@leventepolyak.net>
+---
+ fs/exec.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/fs/exec.c b/fs/exec.c
+index ca89e0e3ef10..d2a03d32e195 100644
+--- a/fs/exec.c
++++ b/fs/exec.c
+@@ -34,6 +34,7 @@
+ #include <linux/swap.h>
+ #include <linux/string.h>
+ #include <linux/init.h>
++#include <linux/sched.h>
+ #include <linux/sched/mm.h>
+ #include <linux/sched/coredump.h>
+ #include <linux/sched/signal.h>
+@@ -64,6 +65,7 @@
+ #include <linux/compat.h>
+ #include <linux/vmalloc.h>
+ #include <linux/io_uring.h>
++#include <linux/random.h>
+
+ #include <linux/uaccess.h>
+ #include <asm/mmu_context.h>
+@@ -280,6 +282,8 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
+ mm->stack_vm = mm->total_vm = 1;
+ mmap_write_unlock(mm);
+ bprm->p = vma->vm_end - sizeof(void *);
++ if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
++ bprm->p ^= get_random_int() & ~PAGE_MASK;
+ return 0;
+ err:
+ mmap_write_unlock(mm);
+--
+2.30.0
+