Commit 18aa8bb1 authored by Ingo Molnar's avatar Ingo Molnar Committed by Thomas Gleixner

stackprotector: add boot_init_stack_canary()

add the boot_init_stack_canary() and make the secondary idle threads
use it.
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 9b5609fd
...@@ -147,7 +147,6 @@ void cpu_idle(void) ...@@ -147,7 +147,6 @@ void cpu_idle(void)
{ {
current_thread_info()->status |= TS_POLLING; current_thread_info()->status |= TS_POLLING;
#ifdef CONFIG_CC_STACKPROTECTOR
/* /*
* If we're the non-boot CPU, nothing set the PDA stack * 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 * canary up for us - and if we are the boot CPU we have
...@@ -156,9 +155,8 @@ void cpu_idle(void) ...@@ -156,9 +155,8 @@ void cpu_idle(void)
* invalid canaries already on the stack wont ever * invalid canaries already on the stack wont ever
* trigger): * trigger):
*/ */
current->stack_canary = get_random_int(); boot_init_stack_canary();
write_pda(stack_canary, current->stack_canary);
#endif
/* endless idle loop with no priority at all */ /* endless idle loop with no priority at all */
while (1) { while (1) {
tick_nohz_stop_sched_tick(); tick_nohz_stop_sched_tick();
......
#ifndef _ASM_STACKPROTECTOR_H #ifndef _ASM_STACKPROTECTOR_H
#define _ASM_STACKPROTECTOR_H 1 #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 #endif
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
#ifdef CONFIG_CC_STACKPROTECTOR #ifdef CONFIG_CC_STACKPROTECTOR
# include <asm/stackprotector.h> # include <asm/stackprotector.h>
#else
static inline void boot_init_stack_canary(void)
{
}
#endif #endif
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment