From 9887a1fcddef1386d3387edf6497d08670460edb Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Wed, 12 Jan 2011 09:55:28 +0100 Subject: [S390] Randomize lower bits of stack address Randomize the lower bits of the stack address like x86 and powerpc. Signed-off-by: Heiko Carstens Signed-off-by: Martin Schwidefsky --- arch/s390/include/asm/system.h | 2 +- arch/s390/kernel/process.c | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'arch/s390') diff --git a/arch/s390/include/asm/system.h b/arch/s390/include/asm/system.h index 6710b0eac16..8f8d759f6a7 100644 --- a/arch/s390/include/asm/system.h +++ b/arch/s390/include/asm/system.h @@ -449,7 +449,7 @@ extern void (*_machine_restart)(char *command); extern void (*_machine_halt)(void); extern void (*_machine_power_off)(void); -#define arch_align_stack(x) (x) +extern unsigned long arch_align_stack(unsigned long sp); static inline int tprot(unsigned long addr) { diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c index 6ba42222b54..38ff69e562c 100644 --- a/arch/s390/kernel/process.c +++ b/arch/s390/kernel/process.c @@ -30,9 +30,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -332,3 +334,10 @@ unsigned long get_wchan(struct task_struct *p) } return 0; } + +unsigned long arch_align_stack(unsigned long sp) +{ + if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space) + sp -= get_random_int() & ~PAGE_MASK; + return sp & ~0xf; +} -- cgit v1.2.3-18-g5258