1c3ff2a51SChristophe Leroy /* SPDX-License-Identifier: GPL-2.0 */ 2c3ff2a51SChristophe Leroy /* 3c3ff2a51SChristophe Leroy * GCC stack protector support. 4c3ff2a51SChristophe Leroy * 5c3ff2a51SChristophe Leroy */ 6c3ff2a51SChristophe Leroy 7c3ff2a51SChristophe Leroy #ifndef _ASM_STACKPROTECTOR_H 8c3ff2a51SChristophe Leroy #define _ASM_STACKPROTECTOR_H 9c3ff2a51SChristophe Leroy 10c3ff2a51SChristophe Leroy #include <asm/reg.h> 11c3ff2a51SChristophe Leroy #include <asm/current.h> 1206ec27aeSChristophe Leroy #include <asm/paca.h> 13c3ff2a51SChristophe Leroy 14c3ff2a51SChristophe Leroy /* 15c3ff2a51SChristophe Leroy * Initialize the stackprotector canary value. 16c3ff2a51SChristophe Leroy * 17c3ff2a51SChristophe Leroy * NOTE: this must only be called from functions that never return, 18c3ff2a51SChristophe Leroy * and it must always be inlined. 19c3ff2a51SChristophe Leroy */ boot_init_stack_canary(void)20c3ff2a51SChristophe Leroystatic __always_inline void boot_init_stack_canary(void) 21c3ff2a51SChristophe Leroy { 22*622754e8SJason A. Donenfeld unsigned long canary = get_random_canary(); 23c3ff2a51SChristophe Leroy 24c3ff2a51SChristophe Leroy current->stack_canary = canary; 2506ec27aeSChristophe Leroy #ifdef CONFIG_PPC64 2606ec27aeSChristophe Leroy get_paca()->canary = canary; 2706ec27aeSChristophe Leroy #endif 28c3ff2a51SChristophe Leroy } 29c3ff2a51SChristophe Leroy 30c3ff2a51SChristophe Leroy #endif /* _ASM_STACKPROTECTOR_H */ 31