Merge tag 'locking-urgent-2020-12-27' of git://git.kernel.org/pub/scm/linux/kernel...
[linux/fpc-iii.git] / arch / sh / include / asm / stackprotector.h
blob35616841d0a1c8cb6a4082590cfe5aa5f6d78494
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_SH_STACKPROTECTOR_H
3 #define __ASM_SH_STACKPROTECTOR_H
5 #include <linux/random.h>
6 #include <linux/version.h>
8 extern unsigned long __stack_chk_guard;
11 * Initialize the stackprotector canary value.
13 * NOTE: this must only be called from functions that never return,
14 * and it must always be inlined.
16 static __always_inline void boot_init_stack_canary(void)
18 unsigned long canary;
20 /* Try to get a semi random initial value. */
21 get_random_bytes(&canary, sizeof(canary));
22 canary ^= LINUX_VERSION_CODE;
23 canary &= CANARY_MASK;
25 current->stack_canary = canary;
26 __stack_chk_guard = current->stack_canary;
29 #endif /* __ASM_SH_STACKPROTECTOR_H */