diff options
author | Franck Bui-Huu <fbuihuu@gmail.com> | 2007-07-19 08:04:21 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2007-07-20 13:57:40 -0400 |
commit | 941091024ef0f2f7e09eb81201d293ac18833cc8 (patch) | |
tree | 8a031f67f89d29649a151d3e5275bb8aae8de8a2 /arch/mips/kernel/process.c | |
parent | c55757b261038d17c729068fcdaef646a665385f (diff) |
[MIPS] User stack pointer randomisation
Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/kernel/process.c')
-rw-r--r-- | arch/mips/kernel/process.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c index 8f4cf27c7157..bd05f5a927ea 100644 --- a/arch/mips/kernel/process.c +++ b/arch/mips/kernel/process.c | |||
@@ -25,7 +25,9 @@ | |||
25 | #include <linux/init.h> | 25 | #include <linux/init.h> |
26 | #include <linux/completion.h> | 26 | #include <linux/completion.h> |
27 | #include <linux/kallsyms.h> | 27 | #include <linux/kallsyms.h> |
28 | #include <linux/random.h> | ||
28 | 29 | ||
30 | #include <asm/asm.h> | ||
29 | #include <asm/bootinfo.h> | 31 | #include <asm/bootinfo.h> |
30 | #include <asm/cpu.h> | 32 | #include <asm/cpu.h> |
31 | #include <asm/dsp.h> | 33 | #include <asm/dsp.h> |
@@ -460,3 +462,15 @@ unsigned long get_wchan(struct task_struct *task) | |||
460 | out: | 462 | out: |
461 | return pc; | 463 | return pc; |
462 | } | 464 | } |
465 | |||
466 | /* | ||
467 | * Don't forget that the stack pointer must be aligned on a 8 bytes | ||
468 | * boundary for 32-bits ABI and 16 bytes for 64-bits ABI. | ||
469 | */ | ||
470 | unsigned long arch_align_stack(unsigned long sp) | ||
471 | { | ||
472 | if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space) | ||
473 | sp -= get_random_int() & ~PAGE_MASK; | ||
474 | |||
475 | return sp & ALMASK; | ||
476 | } | ||