From ac92a5ba0f9108d643d402b4b77927d361e9489e Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Sun, 13 Jul 2008 21:42:44 +0200 Subject: [PATCH] --- yaml --- r: 136363 b: refs/heads/master c: 4f962d4d65923d7b722192e729840cfb79af0a5a h: refs/heads/master i: 136361: c87e2a5c9226e498f0b6f3a3338da04514c81705 136359: c9efd4755e5112d7e483fb9903ace066dc17fbac v: v3 --- [refs] | 2 +- trunk/kernel/panic.c | 47 -------------------------------------------- 2 files changed, 1 insertion(+), 48 deletions(-) diff --git a/[refs] b/[refs] index 3b219d2b6639..f943a0e9d915 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: af9ff7868f0f76d3364351b1641b9dfa99588e77 +refs/heads/master: 4f962d4d65923d7b722192e729840cfb79af0a5a diff --git a/trunk/kernel/panic.c b/trunk/kernel/panic.c index 87445a894c3a..c35c9eca3eb2 100644 --- a/trunk/kernel/panic.c +++ b/trunk/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