aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/exit.c5
-rw-r--r--kernel/fork.c5
-rw-r--r--kernel/panic.c12
-rw-r--r--kernel/sched.c7
4 files changed, 18 insertions, 11 deletions
diff --git a/kernel/exit.c b/kernel/exit.c
index c9e5a1c14e08..e69edc74aeeb 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -981,12 +981,9 @@ static void check_stack_usage(void)
981{ 981{
982 static DEFINE_SPINLOCK(low_water_lock); 982 static DEFINE_SPINLOCK(low_water_lock);
983 static int lowest_to_date = THREAD_SIZE; 983 static int lowest_to_date = THREAD_SIZE;
984 unsigned long *n = end_of_stack(current);
985 unsigned long free; 984 unsigned long free;
986 985
987 while (*n == 0) 986 free = stack_not_used(current);
988 n++;
989 free = (unsigned long)n - (unsigned long)end_of_stack(current);
990 987
991 if (free >= lowest_to_date) 988 if (free >= lowest_to_date)
992 return; 989 return;
diff --git a/kernel/fork.c b/kernel/fork.c
index 43cbf30669e6..913284e3db14 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -61,6 +61,7 @@
61#include <linux/proc_fs.h> 61#include <linux/proc_fs.h>
62#include <linux/blkdev.h> 62#include <linux/blkdev.h>
63#include <trace/sched.h> 63#include <trace/sched.h>
64#include <linux/magic.h>
64 65
65#include <asm/pgtable.h> 66#include <asm/pgtable.h>
66#include <asm/pgalloc.h> 67#include <asm/pgalloc.h>
@@ -212,6 +213,8 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
212{ 213{
213 struct task_struct *tsk; 214 struct task_struct *tsk;
214 struct thread_info *ti; 215 struct thread_info *ti;
216 unsigned long *stackend;
217
215 int err; 218 int err;
216 219
217 prepare_to_copy(orig); 220 prepare_to_copy(orig);
@@ -237,6 +240,8 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
237 goto out; 240 goto out;
238 241
239 setup_thread_stack(tsk, orig); 242 setup_thread_stack(tsk, orig);
243 stackend = end_of_stack(tsk);
244 *stackend = STACK_END_MAGIC; /* for overflow detection */
240 245
241#ifdef CONFIG_CC_STACKPROTECTOR 246#ifdef CONFIG_CC_STACKPROTECTOR
242 tsk->stack_canary = get_random_int(); 247 tsk->stack_canary = get_random_int();
diff --git a/kernel/panic.c b/kernel/panic.c
index 13f06349a786..3a0b0898690a 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -74,6 +74,9 @@ NORET_TYPE void panic(const char * fmt, ...)
74 vsnprintf(buf, sizeof(buf), fmt, args); 74 vsnprintf(buf, sizeof(buf), fmt, args);
75 va_end(args); 75 va_end(args);
76 printk(KERN_EMERG "Kernel panic - not syncing: %s\n",buf); 76 printk(KERN_EMERG "Kernel panic - not syncing: %s\n",buf);
77#ifdef CONFIG_DEBUG_BUGVERBOSE
78 dump_stack();
79#endif
77 bust_spinlocks(0); 80 bust_spinlocks(0);
78 81
79 /* 82 /*
@@ -353,15 +356,22 @@ EXPORT_SYMBOL(warn_slowpath);
353#endif 356#endif
354 357
355#ifdef CONFIG_CC_STACKPROTECTOR 358#ifdef CONFIG_CC_STACKPROTECTOR
359
360#ifndef GCC_HAS_SP
361#warning You have selected the CONFIG_CC_STACKPROTECTOR option, but the gcc used does not support this.
362#endif
363
356/* 364/*
357 * Called when gcc's -fstack-protector feature is used, and 365 * Called when gcc's -fstack-protector feature is used, and
358 * gcc detects corruption of the on-stack canary value 366 * gcc detects corruption of the on-stack canary value
359 */ 367 */
360void __stack_chk_fail(void) 368void __stack_chk_fail(void)
361{ 369{
362 panic("stack-protector: Kernel stack is corrupted"); 370 panic("stack-protector: Kernel stack is corrupted in: %p\n",
371 __builtin_return_address(0));
363} 372}
364EXPORT_SYMBOL(__stack_chk_fail); 373EXPORT_SYMBOL(__stack_chk_fail);
374
365#endif 375#endif
366 376
367core_param(panic, panic_timeout, int, 0644); 377core_param(panic, panic_timeout, int, 0644);
diff --git a/kernel/sched.c b/kernel/sched.c
index fff1c4a20b65..c731dd820d1a 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -5805,12 +5805,7 @@ void sched_show_task(struct task_struct *p)
5805 printk(KERN_CONT " %016lx ", thread_saved_pc(p)); 5805 printk(KERN_CONT " %016lx ", thread_saved_pc(p));
5806#endif 5806#endif
5807#ifdef CONFIG_DEBUG_STACK_USAGE 5807#ifdef CONFIG_DEBUG_STACK_USAGE
5808 { 5808 free = stack_not_used(p);
5809 unsigned long *n = end_of_stack(p);
5810 while (!*n)
5811 n++;
5812 free = (unsigned long)n - (unsigned long)end_of_stack(p);
5813 }
5814#endif 5809#endif
5815 printk(KERN_CONT "%5lu %5d %6d\n", free, 5810 printk(KERN_CONT "%5lu %5d %6d\n", free,
5816 task_pid_nr(p), task_pid_nr(p->real_parent)); 5811 task_pid_nr(p), task_pid_nr(p->real_parent));