Skip to contentSkip to conversation

x86: Don't randomize stack unless current->personality permits it

PATCH In review Frank van Maarseveen 2 participants 2 messages Jul 11, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: Don't randomize stack unless current->personality permits it

Do not randomize stack location unless current->personality permits it.

---

The problem seems also present in

	arch/um/kernel/process_kern.c
	arch/x86_64/kernel/process.c
 arch/i386/kernel/process.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)
arch/i386/kernel/process.c +2 -1
diff -rup a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c
@@ -38,6 +38,7 @@
 #include <linux/kallsyms.h>
 #include <linux/ptrace.h>
 #include <linux/random.h>
+#include <linux/personality.h>
 
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
@@ -898,7 +899,7 @@ asmlinkage int sys_get_thread_area(struc
 
 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;
 }
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Frank van Maarseveen

Do not randomize stack location unless current->personality permits it.

---

hmm I could have sworn this was taken care of already,

thinking about it... prior to adding randomization, there already was 8K randomization of the stack pointer.. we probably only made the new randomization conditional on the personality..
(and to be honest for performance reasons you really really want that 8K at least on the netburst architectures)