aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390
diff options
context:
space:
mode:
authorHeiko Carstens <heiko.carstens@de.ibm.com>2011-01-12 03:55:28 -0500
committerMartin Schwidefsky <sky@mschwide.boeblingen.de.ibm.com>2011-01-12 03:55:25 -0500
commit9887a1fcddef1386d3387edf6497d08670460edb (patch)
treec586ef2f1053acbb71c837ed5b46cbfe32bf7263 /arch/s390
parentdf1ca53cba34b1d40a4ed47907d71397e4ee72c2 (diff)
[S390] Randomize lower bits of stack address
Randomize the lower bits of the stack address like x86 and powerpc. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch/s390')
-rw-r--r--arch/s390/include/asm/system.h2
-rw-r--r--arch/s390/kernel/process.c9
2 files changed, 10 insertions, 1 deletions
diff --git a/arch/s390/include/asm/system.h b/arch/s390/include/asm/system.h
index 6710b0eac165..8f8d759f6a7b 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);
449extern void (*_machine_halt)(void); 449extern void (*_machine_halt)(void);
450extern void (*_machine_power_off)(void); 450extern void (*_machine_power_off)(void);
451 451
452#define arch_align_stack(x) (x) 452extern unsigned long arch_align_stack(unsigned long sp);
453 453
454static inline int tprot(unsigned long addr) 454static inline int tprot(unsigned long addr)
455{ 455{
diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
index 6ba42222b542..38ff69e562c8 100644
--- a/arch/s390/kernel/process.c
+++ b/arch/s390/kernel/process.c
@@ -30,9 +30,11 @@
30#include <linux/tick.h> 30#include <linux/tick.h>
31#include <linux/elfcore.h> 31#include <linux/elfcore.h>
32#include <linux/kernel_stat.h> 32#include <linux/kernel_stat.h>
33#include <linux/personality.h>
33#include <linux/syscalls.h> 34#include <linux/syscalls.h>
34#include <linux/compat.h> 35#include <linux/compat.h>
35#include <linux/kprobes.h> 36#include <linux/kprobes.h>
37#include <linux/random.h>
36#include <asm/compat.h> 38#include <asm/compat.h>
37#include <asm/uaccess.h> 39#include <asm/uaccess.h>
38#include <asm/pgtable.h> 40#include <asm/pgtable.h>
@@ -332,3 +334,10 @@ unsigned long get_wchan(struct task_struct *p)
332 } 334 }
333 return 0; 335 return 0;
334} 336}
337
338unsigned long arch_align_stack(unsigned long sp)
339{
340 if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
341 sp -= get_random_int() & ~PAGE_MASK;
342 return sp & ~0xf;
343}