From: Arjan van de Ven Date: Tue, 26 Sep 2006 08:52:39 +0000 (+0200) Subject: [PATCH] Add the __stack_chk_fail() function X-Git-Tag: v2.6.19-rc1~1077^2~48 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=3162f751d04086a9d006342de63ac8f44fe0f72a;p=linux-2.6-omap-h63xx.git [PATCH] Add the __stack_chk_fail() function GCC emits a call to a __stack_chk_fail() function when the stack canary is not matching the expected value. Since this is a bad security issue; lets panic the kernel rather than limping along; the kernel really can't be trusted anymore when this happens. Signed-off-by: Arjan van de Ven Signed-off-by: Ingo Molnar Signed-off-by: Andi Kleen CC: Andi Kleen --- diff --git a/kernel/panic.c b/kernel/panic.c index d2db3e2209e..6ceb664fb52 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -271,3 +271,15 @@ void oops_exit(void) { do_oops_enter_exit(); } + +#ifdef CONFIG_CC_STACKPROTECTOR +/* + * Called when gcc's -fstack-protector feature is used, and + * gcc detects corruption of the on-stack canary value + */ +void __stack_chk_fail(void) +{ + panic("stack-protector: Kernel stack is corrupted"); +} +EXPORT_SYMBOL(__stack_chk_fail); +#endif