forked from Minki/linux
x86: fix canary of the boot CPU's idle task
the boot CPU's idle task has a zero stackprotector canary value. this is a special task that is never forked, so the fork code does not randomize its canary. Do it when we hit cpu_idle(). Academic sidenote: this means that the early init code runs with a zero canary and hence the canary becomes predictable for this short, boot-only amount of time. Although attack vectors against early init code are very rare, it might make sense to move this initialization to an earlier point. (to one of the early init functions that never return - such as start_kernel()) Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
This commit is contained in:
parent
ce22bd92cb
commit
7e09b2a02d
@ -150,9 +150,13 @@ void cpu_idle(void)
|
||||
#ifdef CONFIG_CC_STACKPROTECTOR
|
||||
/*
|
||||
* If we're the non-boot CPU, nothing set the PDA stack
|
||||
* canary up for us. This is as good a place as any for
|
||||
* doing that.
|
||||
* 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
|
||||
/* endless idle loop with no priority at all */
|
||||
|
Loading…
Reference in New Issue
Block a user