aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/asm-x86/pda.h1
-rw-r--r--kernel/panic.c29
2 files changed, 8 insertions, 22 deletions
diff --git a/include/asm-x86/pda.h b/include/asm-x86/pda.h
index 62b734986a44..a5ff5bb76299 100644
--- a/include/asm-x86/pda.h
+++ b/include/asm-x86/pda.h
@@ -131,4 +131,5 @@ do { \
131 131
132#define PDA_STACKOFFSET (5*8) 132#define PDA_STACKOFFSET (5*8)
133 133
134#define refresh_stack_canary() write_pda(stack_canary, current->stack_canary)
134#endif 135#endif
diff --git a/kernel/panic.c b/kernel/panic.c
index 28153aec7100..87445a894c3a 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -328,37 +328,21 @@ EXPORT_SYMBOL(warn_on_slowpath);
328#ifndef GCC_HAS_SP 328#ifndef GCC_HAS_SP
329#warning You have selected the CONFIG_CC_STACKPROTECTOR option, but the gcc used does not support this. 329#warning You have selected the CONFIG_CC_STACKPROTECTOR option, but the gcc used does not support this.
330#endif 330#endif
331
331static unsigned long __stack_check_testing; 332static unsigned long __stack_check_testing;
333
332/* 334/*
333 * Self test function for the stack-protector feature. 335 * Self test function for the stack-protector feature.
334 * This test requires that the local variable absolutely has 336 * This test requires that the local variable absolutely has
335 * a stack slot, hence the barrier()s. 337 * a stack slot.
336 */ 338 */
337static noinline void __stack_chk_test_func(void) 339static noinline void __stack_chk_test_func(void)
338{ 340{
339 unsigned long foo; 341 unsigned long dummy_buffer[64]; /* force gcc to use the canary */
340 barrier();
341 /*
342 * we need to make sure we're not about to clobber the return address,
343 * while real exploits do this, it's unhealthy on a running system.
344 * Besides, if we would, the test is already failed anyway so
345 * time to pull the emergency brake on it.
346 */
347 if ((unsigned long)__builtin_return_address(0) ==
348 *(((unsigned long *)&foo)+1)) {
349 printk(KERN_ERR "No -fstack-protector-stack-frame!\n");
350 }
351#ifdef CONFIG_FRAME_POINTER
352 /* We also don't want to clobber the frame pointer */
353 if ((unsigned long)__builtin_return_address(0) ==
354 *(((unsigned long *)&foo)+2)) {
355 printk(KERN_ERR "No -fstack-protector-stack-frame!\n");
356 }
357#endif
358 if (current->stack_canary != *(((unsigned long *)&foo)+1))
359 printk(KERN_ERR "No -fstack-protector canary found\n");
360 342
361 current->stack_canary = ~current->stack_canary; 343 current->stack_canary = ~current->stack_canary;
344 refresh_stack_canary();
345 dummy_buffer[3] = 1; /* fool gcc into keeping the variable */
362} 346}
363 347
364static int __stack_chk_test(void) 348static int __stack_chk_test(void)
@@ -371,6 +355,7 @@ static int __stack_chk_test(void)
371 WARN_ON(1); 355 WARN_ON(1);
372 }; 356 };
373 current->stack_canary = ~current->stack_canary; 357 current->stack_canary = ~current->stack_canary;
358 refresh_stack_canary();
374 return 0; 359 return 0;
375} 360}
376/* 361/*