diff options
author | Franck Bui-Huu <fbuihuu@gmail.com> | 2007-07-19 14:04:21 +0200 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2007-07-20 19:57:40 +0200 |
commit | 941091024ef0f2f7e09eb81201d293ac18833cc8 (patch) | |
tree | 8a031f67f89d29649a151d3e5275bb8aae8de8a2 /arch/mips/kernel/process.c | |
parent | [MIPS] Remove unused include/asm-mips/gfx.h (diff) | |
download | linux-941091024ef0f2f7e09eb81201d293ac18833cc8.tar.xz linux-941091024ef0f2f7e09eb81201d293ac18833cc8.zip |
[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 @@ #include <linux/init.h> #include <linux/completion.h> #include <linux/kallsyms.h> +#include <linux/random.h> +#include <asm/asm.h> #include <asm/bootinfo.h> #include <asm/cpu.h> #include <asm/dsp.h> @@ -460,3 +462,15 @@ unsigned long get_wchan(struct task_struct *task) out: return pc; } + +/* + * Don't forget that the stack pointer must be aligned on a 8 bytes + * boundary for 32-bits ABI and 16 bytes for 64-bits ABI. + */ +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 & ALMASK; +} |