![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0 */ 0002 /* 0003 * GCC stack protector support. 0004 * 0005 * Stack protector works by putting predefined pattern at the start of 0006 * the stack frame and verifying that it hasn't been overwritten when 0007 * returning from the function. The pattern is called stack canary 0008 * and gcc expects it to be defined by a global variable called 0009 * "__stack_chk_guard" on ARM. This prevents SMP systems from using a 0010 * different value for each task unless we enable a GCC plugin that 0011 * replaces these symbol references with references to each task's own 0012 * value. 0013 */ 0014 0015 #ifndef _ASM_STACKPROTECTOR_H 0016 #define _ASM_STACKPROTECTOR_H 1 0017 0018 #include <linux/random.h> 0019 #include <linux/version.h> 0020 0021 #include <asm/thread_info.h> 0022 0023 extern unsigned long __stack_chk_guard; 0024 0025 /* 0026 * Initialize the stackprotector canary value. 0027 * 0028 * NOTE: this must only be called from functions that never return, 0029 * and it must always be inlined. 0030 */ 0031 static __always_inline void boot_init_stack_canary(void) 0032 { 0033 unsigned long canary; 0034 0035 /* Try to get a semi random initial value. */ 0036 get_random_bytes(&canary, sizeof(canary)); 0037 canary ^= LINUX_VERSION_CODE; 0038 0039 current->stack_canary = canary; 0040 #ifndef CONFIG_STACKPROTECTOR_PER_TASK 0041 __stack_chk_guard = current->stack_canary; 0042 #endif 0043 } 0044 0045 #endif /* _ASM_STACKPROTECTOR_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |