aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndi Kleen <ak@suse.de>2006-09-26 04:52:28 -0400
committerAndi Kleen <andi@basil.nowhere.org>2006-09-26 04:52:28 -0400
commitc16b63e09d9d03158e0a92e961234e94c4862620 (patch)
tree154c9b5e082bf0633482be6c33c973cc35c602d8
parentd5d9ca6d882f7c8d47ef91a701fc042cbebbc334 (diff)
[PATCH] i386/x86-64: Don't randomize stack top when no randomization personality is set
Based on patch from Frank van Maarseveen <frankvm@frankvm.com>, but extended. Signed-off-by: Andi Kleen <ak@suse.de>
-rw-r--r--arch/i386/kernel/process.c3
-rw-r--r--arch/x86_64/kernel/process.c2
-rw-r--r--fs/binfmt_elf.c3
3 files changed, 5 insertions, 3 deletions
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 @@
37#include <linux/kallsyms.h> 37#include <linux/kallsyms.h>
38#include <linux/ptrace.h> 38#include <linux/ptrace.h>
39#include <linux/random.h> 39#include <linux/random.h>
40#include <linux/personality.h>
40 41
41#include <asm/uaccess.h> 42#include <asm/uaccess.h>
42#include <asm/pgtable.h> 43#include <asm/pgtable.h>
@@ -905,7 +906,7 @@ asmlinkage int sys_get_thread_area(struct user_desc __user *u_info)
905 906
906unsigned long arch_align_stack(unsigned long sp) 907unsigned long arch_align_stack(unsigned long sp)
907{ 908{
908 if (randomize_va_space) 909 if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
909 sp -= get_random_int() % 8192; 910 sp -= get_random_int() % 8192;
910 return sp & ~0xf; 911 return sp & ~0xf;
911} 912}
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)
845 845
846unsigned long arch_align_stack(unsigned long sp) 846unsigned long arch_align_stack(unsigned long sp)
847{ 847{
848 if (randomize_va_space) 848 if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
849 sp -= get_random_int() % 8192; 849 sp -= get_random_int() % 8192;
850 return sp & ~0xf; 850 return sp & ~0xf;
851} 851}
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)
515{ 515{
516 unsigned int random_variable = 0; 516 unsigned int random_variable = 0;
517 517
518 if (current->flags & PF_RANDOMIZE) { 518 if ((current->flags & PF_RANDOMIZE) &&
519 !(current->personality & ADDR_NO_RANDOMIZE)) {
519 random_variable = get_random_int() & STACK_RND_MASK; 520 random_variable = get_random_int() & STACK_RND_MASK;
520 random_variable <<= PAGE_SHIFT; 521 random_variable <<= PAGE_SHIFT;
521 } 522 }