aboutsummaryrefslogtreecommitdiff
path: root/kernel/panic.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/panic.c')
-rw-r--r--kernel/panic.c47
1 files changed, 0 insertions, 47 deletions
diff --git a/kernel/panic.c b/kernel/panic.c
index 87445a894c3..c35c9eca3eb 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -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