Skip to content

Commit

Permalink
sh/boot: add static stack-protector to pre-kernel
Browse files Browse the repository at this point in the history
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/[email protected]
Signed-off-by: Kees Cook <[email protected]>
Cc: Yoshinori Sato <[email protected]>
Cc: Rich Felker <[email protected]>
Cc: Al Viro <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Laura Abbott <[email protected]>
Cc: Masahiro Yamada <[email protected]>
Cc: Michal Marek <[email protected]>
Cc: Nicholas Piggin <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
kees authored and torvalds committed Nov 18, 2017
1 parent 868038b commit fb6cc4a
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions arch/sh/boot/compressed/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@ static void error(char *x)
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
#define stackalign 8
#else
Expand All @@ -118,6 +130,8 @@ void decompress_kernel(void)
{
unsigned long output_addr;

__stack_chk_guard_setup();

#ifdef CONFIG_SUPERH64
output_addr = (CONFIG_MEMORY_START + 0x2000);
#else
Expand Down

0 comments on commit fb6cc4a

Please sign in to comment.