1f2c9699fSGuo Ren /* SPDX-License-Identifier: GPL-2.0 */ 2f2c9699fSGuo Ren 3f2c9699fSGuo Ren #ifndef _ASM_RISCV_STACKPROTECTOR_H 4f2c9699fSGuo Ren #define _ASM_RISCV_STACKPROTECTOR_H 5f2c9699fSGuo Ren 6f2c9699fSGuo Ren extern unsigned long __stack_chk_guard; 7f2c9699fSGuo Ren 8f2c9699fSGuo Ren /* 9f2c9699fSGuo Ren * Initialize the stackprotector canary value. 10f2c9699fSGuo Ren * 11f2c9699fSGuo Ren * NOTE: this must only be called from functions that never return, 12f2c9699fSGuo Ren * and it must always be inlined. 13f2c9699fSGuo Ren */ boot_init_stack_canary(void)14f2c9699fSGuo Renstatic __always_inline void boot_init_stack_canary(void) 15f2c9699fSGuo Ren { 16*622754e8SJason A. Donenfeld unsigned long canary = get_random_canary(); 17f2c9699fSGuo Ren 18f2c9699fSGuo Ren current->stack_canary = canary; 19fea2fed2SGuo Ren if (!IS_ENABLED(CONFIG_STACKPROTECTOR_PER_TASK)) 20f2c9699fSGuo Ren __stack_chk_guard = current->stack_canary; 21f2c9699fSGuo Ren } 22f2c9699fSGuo Ren #endif /* _ASM_RISCV_STACKPROTECTOR_H */ 23