1 #ifndef _ASM_STACKPROTECTOR_H
2 #define _ASM_STACKPROTECTOR_H 1
8 * Initialize the stackprotector canary value.
10 * NOTE: this must only be called from functions that never return,
11 * and it must always be inlined.
13 static __always_inline void boot_init_stack_canary(void)
19 * If we're the non-boot CPU, nothing set the PDA stack
20 * canary up for us - and if we are the boot CPU we have
21 * a 0 stack canary. This is a good place for updating
22 * it, as we wont ever return from this function (so the
23 * invalid canaries already on the stack wont ever
26 * We both use the random pool and the current TSC as a source
27 * of randomness. The TSC only matters for very early init,
28 * there it already has some randomness on most systems. Later
29 * on during the bootup the random pool has true entropy too.
31 get_random_bytes(&canary, sizeof(canary));
32 tsc = __native_read_tsc();
33 canary += tsc + (tsc << 32UL);
35 current->stack_canary = canary;
36 write_pda(stack_canary, canary);