Skip to content

Commit fb6cc4a

Browse files
keestorvalds
authored andcommitted
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.org Signed-off-by: Kees 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: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 868038b commit fb6cc4a

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

‎arch/sh/boot/compressed/misc.c‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,18 @@ static void error(char *x)
104104
while(1); /* Halt */
105105
}
106106

107+
unsigned long __stack_chk_guard;
108+
109+
void __stack_chk_guard_setup(void)
110+
{
111+
__stack_chk_guard = 0x000a0dff;
112+
}
113+
114+
void __stack_chk_fail(void)
115+
{
116+
error("stack-protector: Kernel stack is corrupted\n");
117+
}
118+
107119
#ifdef CONFIG_SUPERH64
108120
#define stackalign 8
109121
#else
@@ -118,6 +130,8 @@ void decompress_kernel(void)
118130
{
119131
unsigned long output_addr;
120132

133+
__stack_chk_guard_setup();
134+
121135
#ifdef CONFIG_SUPERH64
122136
output_addr = (CONFIG_MEMORY_START + 0x2000);
123137
#else

0 commit comments

Comments
 (0)