Commit 2c8340ed authored by Rik van Riel's avatar Rik van Riel Committed by Linus Torvalds

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.comSigned-off-by: default avatarRik van Riel <riel@redhat.com>
Acked-by: default avatarKees 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: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent d21f5498
...@@ -19,6 +19,7 @@ static __always_inline void boot_init_stack_canary(void) ...@@ -19,6 +19,7 @@ static __always_inline void boot_init_stack_canary(void)
/* Try to get a semi random initial value. */ /* Try to get a semi random initial value. */
get_random_bytes(&canary, sizeof(canary)); get_random_bytes(&canary, sizeof(canary));
canary ^= LINUX_VERSION_CODE; canary ^= LINUX_VERSION_CODE;
canary &= CANARY_MASK;
current->stack_canary = canary; current->stack_canary = canary;
__stack_chk_guard = current->stack_canary; __stack_chk_guard = current->stack_canary;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment