From: Andi Kleen Date: Tue, 26 Sep 2006 08:52:28 +0000 (+0200) Subject: [PATCH] i386/x86-64: Don't randomize stack top when no randomization personality... X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c16b63e09d9d03158e0a92e961234e94c4862620;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [PATCH] i386/x86-64: Don't randomize stack top when no randomization personality is set Based on patch from Frank van Maarseveen , but extended. Signed-off-by: Andi Kleen --- diff --git a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c index 8657c739656a..b741c3e1a5eb 100644 --- a/arch/i386/kernel/process.c +++ b/arch/i386/kernel/process.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -905,7 +906,7 @@ asmlinkage int sys_get_thread_area(struct user_desc __user *u_info) unsigned long arch_align_stack(unsigned long sp) { - if (randomize_va_space) + if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space) sp -= get_random_int() % 8192; return sp & ~0xf; } diff --git a/arch/x86_64/kernel/process.c b/arch/x86_64/kernel/process.c index 6e0527635b4c..6fbd19564e4e 100644 --- a/arch/x86_64/kernel/process.c +++ b/arch/x86_64/kernel/process.c @@ -845,7 +845,7 @@ int dump_task_regs(struct task_struct *tsk, elf_gregset_t *regs) unsigned long arch_align_stack(unsigned long sp) { - if (randomize_va_space) + if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space) sp -= get_random_int() % 8192; return sp & ~0xf; } diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 672a3b90bc55..5109dbff93bf 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -515,7 +515,8 @@ static unsigned long randomize_stack_top(unsigned long stack_top) { unsigned int random_variable = 0; - if (current->flags & PF_RANDOMIZE) { + if ((current->flags & PF_RANDOMIZE) && + !(current->personality & ADDR_NO_RANDOMIZE)) { random_variable = get_random_int() & STACK_RND_MASK; random_variable <<= PAGE_SHIFT; }