From c13f814382b1935e2238a82f1feefa1ee3534916 Mon Sep 17 00:00:00 2001 From: Ben Chan Date: Tue, 24 Jun 2014 16:00:17 -0700 Subject: [PATCH] MIPS: ZBOOT: implement stack protector in compressed boot phase This patch implements the stack protector code in MIPS compressed boot phase based on the same code added to arm in commit 87e2549be2ac90448b6203354c2260ac779156f3 "stackprotector: Introduce CONFIG_CC_STACKPROTECTOR_STRONG" by Kees Cook Signed-off-by: Ben Chan Cc: Kees Cook Cc: Olof Johansson Reviewed-by: Kees Cook Cc: linux-mips@linux-mips.org Cc: linux-kernel@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/7175/ Signed-off-by: Ralf Baechle --- arch/mips/boot/compressed/decompress.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/mips/boot/compressed/decompress.c b/arch/mips/boot/compressed/decompress.c index c00c4ddf45148..b49c7adbfa895 100644 --- a/arch/mips/boot/compressed/decompress.c +++ b/arch/mips/boot/compressed/decompress.c @@ -67,10 +67,24 @@ void error(char *x) #include "../../../../lib/decompress_unxz.c" #endif +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"); +} + void decompress_kernel(unsigned long boot_heap_start) { unsigned long zimage_start, zimage_size; + __stack_chk_guard_setup(); + zimage_start = (unsigned long)(&__image_begin); zimage_size = (unsigned long)(&__image_end) - (unsigned long)(&__image_begin); -- 2.39.5