Skip to content

Commit 3162f75

Browse files
fenrus75Andi Kleen
authored andcommitted
[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 <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Signed-off-by: Andi Kleen <[email protected]> CC: Andi Kleen <[email protected]>
1 parent 0a42540 commit 3162f75

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

kernel/panic.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,3 +271,15 @@ void oops_exit(void)
271271
{
272272
do_oops_enter_exit();
273273
}
274+
275+
#ifdef CONFIG_CC_STACKPROTECTOR
276+
/*
277+
* Called when gcc's -fstack-protector feature is used, and
278+
* gcc detects corruption of the on-stack canary value
279+
*/
280+
void __stack_chk_fail(void)
281+
{
282+
panic("stack-protector: Kernel stack is corrupted");
283+
}
284+
EXPORT_SYMBOL(__stack_chk_fail);
285+
#endif

0 commit comments

Comments
 (0)