0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef __ASM_STACKPROTECTOR_H
0014 #define __ASM_STACKPROTECTOR_H
0015
0016 #include <linux/random.h>
0017 #include <linux/version.h>
0018 #include <asm/pointer_auth.h>
0019
0020 extern unsigned long __stack_chk_guard;
0021
0022
0023
0024
0025
0026
0027
0028 static __always_inline void boot_init_stack_canary(void)
0029 {
0030 #if defined(CONFIG_STACKPROTECTOR)
0031 unsigned long canary;
0032
0033
0034 get_random_bytes(&canary, sizeof(canary));
0035 canary ^= LINUX_VERSION_CODE;
0036 canary &= CANARY_MASK;
0037
0038 current->stack_canary = canary;
0039 if (!IS_ENABLED(CONFIG_STACKPROTECTOR_PER_TASK))
0040 __stack_chk_guard = current->stack_canary;
0041 #endif
0042 ptrauth_thread_init_kernel(current);
0043 ptrauth_thread_switch_kernel(current);
0044 ptrauth_enable();
0045 }
0046
0047 #endif