Commit fb6cc4ac authored by Kees Cook's avatar Kees Cook Committed by Linus Torvalds

sh/boot: add static stack-protector to pre-kernel

The sh decompressor code triggers stack-protector code generation when
using CONFIG_CC_STACKPROTECTOR_STRONG.  As done for arm and mips, add a
simple static stack-protector canary.  As this wasn't protected before,
the risk of using a weak canary is minimized.  Once the kernel is
actually up, a better canary is chosen.

Link: http://lkml.kernel.org/r/1506972007-80614-2-git-send-email-keescook@chromium.orgSigned-off-by: default avatarKees Cook <keescook@chromium.org>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Laura Abbott <labbott@redhat.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Michal Marek <mmarek@suse.com>
Cc: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 868038be
...@@ -104,6 +104,18 @@ static void error(char *x) ...@@ -104,6 +104,18 @@ static void error(char *x)
while(1); /* Halt */ while(1); /* Halt */
} }
unsigned long __stack_chk_guard;
void __stack_chk_guard_setup(void)
{
__stack_chk_guard = 0x000a0dff;
}
void __stack_chk_fail(void)
{
error("stack-protector: Kernel stack is corrupted\n");
}
#ifdef CONFIG_SUPERH64 #ifdef CONFIG_SUPERH64
#define stackalign 8 #define stackalign 8
#else #else
...@@ -118,6 +130,8 @@ void decompress_kernel(void) ...@@ -118,6 +130,8 @@ void decompress_kernel(void)
{ {
unsigned long output_addr; unsigned long output_addr;
__stack_chk_guard_setup();
#ifdef CONFIG_SUPERH64 #ifdef CONFIG_SUPERH64
output_addr = (CONFIG_MEMORY_START + 0x2000); output_addr = (CONFIG_MEMORY_START + 0x2000);
#else #else
......
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