Skip to content

Commit 7bbaf27

Browse files
chenhuacaitorvalds
authored andcommitted
zboot: fix stack protector in compressed boot phase
Calling __stack_chk_guard_setup() in decompress_kernel() is too late that stack checking always fails for decompress_kernel() itself. So remove __stack_chk_guard_setup() and initialize __stack_chk_guard before we call decompress_kernel(). Original code comes from ARM but also used for MIPS and SH, so fix them together. If without this fix, compressed booting of these archs will fail because stack checking is enabled by default (>=4.16). Link: http://lkml.kernel.org/r/[email protected] Fixes: 8779657 ("stackprotector: Introduce CONFIG_CC_STACKPROTECTOR_STRONG") Signed-off-by: Huacai Chen <[email protected]> Acked-by: James Hogan <[email protected]> Acked-by: Kees Cook <[email protected]> Acked-by: Rich Felker <[email protected]> Cc: Ralf Baechle <[email protected]> Cc: Russell King <[email protected]> Cc: Yoshinori Sato <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 06dd3df commit 7bbaf27

File tree

3 files changed

+3
-24
lines changed

3 files changed

+3
-24
lines changed

arch/arm/boot/compressed/misc.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,7 @@ asmlinkage void __div0(void)
128128
error("Attempting division by 0!");
129129
}
130130

131-
unsigned long __stack_chk_guard;
132-
133-
void __stack_chk_guard_setup(void)
134-
{
135-
__stack_chk_guard = 0x000a0dff;
136-
}
131+
const unsigned long __stack_chk_guard = 0x000a0dff;
137132

138133
void __stack_chk_fail(void)
139134
{
@@ -150,8 +145,6 @@ decompress_kernel(unsigned long output_start, unsigned long free_mem_ptr_p,
150145
{
151146
int ret;
152147

153-
__stack_chk_guard_setup();
154-
155148
output_data = (unsigned char *)output_start;
156149
free_mem_ptr = free_mem_ptr_p;
157150
free_mem_end_ptr = free_mem_ptr_end_p;

arch/mips/boot/compressed/decompress.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,7 @@ void error(char *x)
7676
#include "../../../../lib/decompress_unxz.c"
7777
#endif
7878

79-
unsigned long __stack_chk_guard;
80-
81-
void __stack_chk_guard_setup(void)
82-
{
83-
__stack_chk_guard = 0x000a0dff;
84-
}
79+
const unsigned long __stack_chk_guard = 0x000a0dff;
8580

8681
void __stack_chk_fail(void)
8782
{
@@ -92,8 +87,6 @@ void decompress_kernel(unsigned long boot_heap_start)
9287
{
9388
unsigned long zimage_start, zimage_size;
9489

95-
__stack_chk_guard_setup();
96-
9790
zimage_start = (unsigned long)(&__image_begin);
9891
zimage_size = (unsigned long)(&__image_end) -
9992
(unsigned long)(&__image_begin);

arch/sh/boot/compressed/misc.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,7 @@ 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-
}
107+
const unsigned long __stack_chk_guard = 0x000a0dff;
113108

114109
void __stack_chk_fail(void)
115110
{
@@ -130,8 +125,6 @@ void decompress_kernel(void)
130125
{
131126
unsigned long output_addr;
132127

133-
__stack_chk_guard_setup();
134-
135128
#ifdef CONFIG_SUPERH64
136129
output_addr = (CONFIG_MEMORY_START + 0x2000);
137130
#else

0 commit comments

Comments
 (0)