Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 136363
b: refs/heads/master
c: 4f962d4
h: refs/heads/master
i:
  136361: c87e2a5
  136359: c9efd47
v: v3
  • Loading branch information
Ingo Molnar committed Jul 13, 2008
1 parent 90764a6 commit ac92a5b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 48 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: af9ff7868f0f76d3364351b1641b9dfa99588e77
refs/heads/master: 4f962d4d65923d7b722192e729840cfb79af0a5a
47 changes: 0 additions & 47 deletions trunk/kernel/panic.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,62 +329,15 @@ EXPORT_SYMBOL(warn_on_slowpath);
#warning You have selected the CONFIG_CC_STACKPROTECTOR option, but the gcc used does not support this.
#endif

static unsigned long __stack_check_testing;

/*
* Self test function for the stack-protector feature.
* This test requires that the local variable absolutely has
* a stack slot.
*/
static noinline void __stack_chk_test_func(void)
{
unsigned long dummy_buffer[64]; /* force gcc to use the canary */

current->stack_canary = ~current->stack_canary;
refresh_stack_canary();
dummy_buffer[3] = 1; /* fool gcc into keeping the variable */
}

static int __stack_chk_test(void)
{
printk(KERN_INFO "Testing -fstack-protector-all feature\n");
__stack_check_testing = (unsigned long)&__stack_chk_test_func;
__stack_chk_test_func();
if (__stack_check_testing) {
printk(KERN_ERR "-fstack-protector-all test failed\n");
WARN_ON(1);
};
current->stack_canary = ~current->stack_canary;
refresh_stack_canary();
return 0;
}
/*
* Called when gcc's -fstack-protector feature is used, and
* gcc detects corruption of the on-stack canary value
*/
void __stack_chk_fail(void)
{
if (__stack_check_testing == (unsigned long)&__stack_chk_test_func) {
long delta;

delta = (unsigned long)__builtin_return_address(0) -
__stack_check_testing;
/*
* The test needs to happen inside the test function, so
* check if the return address is close to that function.
* The function is only 2 dozen bytes long, but keep a wide
* safety margin to avoid panic()s for normal users regardless
* of the quality of the compiler.
*/
if (delta >= 0 && delta <= 400) {
__stack_check_testing = 0;
return;
}
}
panic("stack-protector: Kernel stack is corrupted in: %p\n",
__builtin_return_address(0));
}
EXPORT_SYMBOL(__stack_chk_fail);

late_initcall(__stack_chk_test);
#endif

0 comments on commit ac92a5b

Please sign in to comment.