Skip to content

Commit

Permalink
[PATCH] Add the __stack_chk_fail() function
Browse files Browse the repository at this point in the history
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 <arjan@linux.intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andi Kleen <ak@suse.de>
CC: Andi Kleen <ak@suse.de>
  • Loading branch information
Arjan van de Ven authored and Andi Kleen committed Sep 26, 2006
1 parent 0a42540 commit 3162f75
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions kernel/panic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 3162f75

Please sign in to comment.