diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-02-14 09:42:02 +0100 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2008-05-26 16:15:32 +0200 |
commit | 18aa8bb12dcb10adc3d7c9d69714d53667c0ab7f (patch) | |
tree | 2081f51b29106b05867c70ee71641ecc466147da /include | |
parent | stackprotector: include files (diff) | |
download | linux-18aa8bb12dcb10adc3d7c9d69714d53667c0ab7f.tar.xz linux-18aa8bb12dcb10adc3d7c9d69714d53667c0ab7f.zip |
stackprotector: add boot_init_stack_canary()
add the boot_init_stack_canary() and make the secondary idle threads
use it.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-x86/stackprotector.h | 20 | ||||
-rw-r--r-- | include/linux/stackprotector.h | 4 |
2 files changed, 24 insertions, 0 deletions
diff --git a/include/asm-x86/stackprotector.h b/include/asm-x86/stackprotector.h index dcac7a6bdba2..0f91f7a2688c 100644 --- a/include/asm-x86/stackprotector.h +++ b/include/asm-x86/stackprotector.h @@ -1,4 +1,24 @@ #ifndef _ASM_STACKPROTECTOR_H #define _ASM_STACKPROTECTOR_H 1 +/* + * Initialize the stackprotector canary value. + * + * NOTE: this must only be called from functions that never return, + * and it must always be inlined. + */ +static __always_inline void boot_init_stack_canary(void) +{ + /* + * If we're the non-boot CPU, nothing set the PDA stack + * canary up for us - and if we are the boot CPU we have + * a 0 stack canary. This is a good place for updating + * it, as we wont ever return from this function (so the + * invalid canaries already on the stack wont ever + * trigger): + */ + current->stack_canary = get_random_int(); + write_pda(stack_canary, current->stack_canary); +} + #endif diff --git a/include/linux/stackprotector.h b/include/linux/stackprotector.h index d3e8bbe602f8..422e71aafd0b 100644 --- a/include/linux/stackprotector.h +++ b/include/linux/stackprotector.h @@ -3,6 +3,10 @@ #ifdef CONFIG_CC_STACKPROTECTOR # include <asm/stackprotector.h> +#else +static inline void boot_init_stack_canary(void) +{ +} #endif #endif |