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