summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRik van Riel <riel@redhat.com>2017-06-30 11:20:08 +1000
committerStephen Rothwell <sfr@canb.auug.org.au>2017-07-04 14:53:42 +1000
commit8d8f40cd3706af78d251063974af5b5afd5a7410 (patch)
tree359325559393d7c52e65ced66ab8dd187fb26f4b
parent1c5acefcf4b449c243c73230e6aee4efb230f43f (diff)
downloadlinux-8d8f40cd3706af78d251063974af5b5afd5a7410.tar.gz
linux-8d8f40cd3706af78d251063974af5b5afd5a7410.tar.xz
sh64: ascii armor the sh64 boot init stack canary
Use the ascii-armor canary to prevent unterminated C string overflows from being able to successfully overwrite the canary, even if they somehow obtain the canary value. Inspired by execshield ascii-armor and Daniel Micay's linux-hardened tree. Link: http://lkml.kernel.org/r/20170524123446.78510066@annuminas.surriel.com Signed-off-by: Rik van Riel <riel@redhat.com> Acked-by: Kees Cook <keescook@chromium.org> Cc: Daniel Micay <danielmicay@gmail.com> Cc: "Theodore Ts'o" <tytso@mit.edu> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Ingo Molnar <mingo@kernel.org> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Yoshinori Sato <ysato@users.sourceforge.jp> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
-rw-r--r--arch/sh/include/asm/stackprotector.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/arch/sh/include/asm/stackprotector.h b/arch/sh/include/asm/stackprotector.h
index d9df3a76847c..141515a43b78 100644
--- a/arch/sh/include/asm/stackprotector.h
+++ b/arch/sh/include/asm/stackprotector.h
@@ -19,6 +19,7 @@ static __always_inline void boot_init_stack_canary(void)
/* Try to get a semi random initial value. */
get_random_bytes(&canary, sizeof(canary));
canary ^= LINUX_VERSION_CODE;
+ canary &= CANARY_MASK;
current->stack_canary = canary;
__stack_chk_guard = current->stack_canary;