diff options
author | Filippo Arcidiacono <filippo.arcidiacono@st.com> | 2012-04-19 02:45:57 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2012-04-19 02:45:57 -0400 |
commit | 5d920bb929a99446062a48cf90867bbca57b8e77 (patch) | |
tree | fdadebe0b0fe8906ffd81ad9f726430d6428a8f5 /arch/sh/include/asm/stackprotector.h | |
parent | 932e9f352b5d685725076f21b237f7c7d804b29c (diff) |
sh: initial stack protector support.
This implements basic -fstack-protector support, based on the early ARM
version in c743f38013aeff58ef6252601e397b5ba281c633. The SMP case is
limited to the initial canary value, while the UP case handles per-task
granularity (limited to 32-bit sh until a new enough sh64 compiler
manifests itself).
Signed-off-by: Filippo Arcidiacono <filippo.arcidiacono@st.com>
Reviewed-by: Carmelo Amoroso <carmelo.amoroso@st.com>
Signed-off-by: Stuart Menefy <stuart.menefy@st.com>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh/include/asm/stackprotector.h')
-rw-r--r-- | arch/sh/include/asm/stackprotector.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/arch/sh/include/asm/stackprotector.h b/arch/sh/include/asm/stackprotector.h new file mode 100644 index 000000000000..d9df3a76847c --- /dev/null +++ b/arch/sh/include/asm/stackprotector.h | |||
@@ -0,0 +1,27 @@ | |||
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 | |||
23 | current->stack_canary = canary; | ||
24 | __stack_chk_guard = current->stack_canary; | ||
25 | } | ||
26 | |||
27 | #endif /* __ASM_SH_STACKPROTECTOR_H */ | ||