]> git.karo-electronics.de Git - karo-tx-linux.git/blob - arch/sh/include/asm/stackprotector.h
Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
[karo-tx-linux.git] / arch / sh / include / asm / stackprotector.h
1 #ifndef __ASM_SH_STACKPROTECTOR_H
2 #define __ASM_SH_STACKPROTECTOR_H
3
4 #include <linux/random.h>
5 #include <linux/version.h>
6
7 extern unsigned long __stack_chk_guard;
8
9 /*
10  * Initialize the stackprotector canary value.
11  *
12  * NOTE: this must only be called from functions that never return,
13  * and it must always be inlined.
14  */
15 static __always_inline void boot_init_stack_canary(void)
16 {
17         unsigned long canary;
18
19         /* Try to get a semi random initial value. */
20         get_random_bytes(&canary, sizeof(canary));
21         canary ^= LINUX_VERSION_CODE;
22         canary &= CANARY_MASK;
23
24         current->stack_canary = canary;
25         __stack_chk_guard = current->stack_canary;
26 }
27
28 #endif /* __ASM_SH_STACKPROTECTOR_H */