diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/exit.c | 5 | ||||
-rw-r--r-- | kernel/fork.c | 5 | ||||
-rw-r--r-- | kernel/panic.c | 12 | ||||
-rw-r--r-- | kernel/sched.c | 7 |
4 files changed, 18 insertions, 11 deletions
diff --git a/kernel/exit.c b/kernel/exit.c index c7740fa3252c..2a803c28df9e 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -977,12 +977,9 @@ static void check_stack_usage(void) | |||
977 | { | 977 | { |
978 | static DEFINE_SPINLOCK(low_water_lock); | 978 | static DEFINE_SPINLOCK(low_water_lock); |
979 | static int lowest_to_date = THREAD_SIZE; | 979 | static int lowest_to_date = THREAD_SIZE; |
980 | unsigned long *n = end_of_stack(current); | ||
981 | unsigned long free; | 980 | unsigned long free; |
982 | 981 | ||
983 | while (*n == 0) | 982 | free = stack_not_used(current); |
984 | n++; | ||
985 | free = (unsigned long)n - (unsigned long)end_of_stack(current); | ||
986 | 983 | ||
987 | if (free >= lowest_to_date) | 984 | if (free >= lowest_to_date) |
988 | return; | 985 | return; |
diff --git a/kernel/fork.c b/kernel/fork.c index 1d68f1255dd8..4a9b318dad0d 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 2a2ff36ff44d..33cab3de1763 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 | /* |
@@ -355,15 +358,22 @@ EXPORT_SYMBOL(warn_slowpath); | |||
355 | #endif | 358 | #endif |
356 | 359 | ||
357 | #ifdef CONFIG_CC_STACKPROTECTOR | 360 | #ifdef CONFIG_CC_STACKPROTECTOR |
361 | |||
362 | #ifndef GCC_HAS_SP | ||
363 | #warning You have selected the CONFIG_CC_STACKPROTECTOR option, but the gcc used does not support this. | ||
364 | #endif | ||
365 | |||
358 | /* | 366 | /* |
359 | * Called when gcc's -fstack-protector feature is used, and | 367 | * Called when gcc's -fstack-protector feature is used, and |
360 | * gcc detects corruption of the on-stack canary value | 368 | * gcc detects corruption of the on-stack canary value |
361 | */ | 369 | */ |
362 | void __stack_chk_fail(void) | 370 | void __stack_chk_fail(void) |
363 | { | 371 | { |
364 | panic("stack-protector: Kernel stack is corrupted"); | 372 | panic("stack-protector: Kernel stack is corrupted in: %p\n", |
373 | __builtin_return_address(0)); | ||
365 | } | 374 | } |
366 | EXPORT_SYMBOL(__stack_chk_fail); | 375 | EXPORT_SYMBOL(__stack_chk_fail); |
376 | |||
367 | #endif | 377 | #endif |
368 | 378 | ||
369 | core_param(panic, panic_timeout, int, 0644); | 379 | core_param(panic, panic_timeout, int, 0644); |
diff --git a/kernel/sched.c b/kernel/sched.c index 8be2c13b50d0..1d2909067040 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -5939,12 +5939,7 @@ void sched_show_task(struct task_struct *p) | |||
5939 | printk(KERN_CONT " %016lx ", thread_saved_pc(p)); | 5939 | printk(KERN_CONT " %016lx ", thread_saved_pc(p)); |
5940 | #endif | 5940 | #endif |
5941 | #ifdef CONFIG_DEBUG_STACK_USAGE | 5941 | #ifdef CONFIG_DEBUG_STACK_USAGE |
5942 | { | 5942 | free = stack_not_used(p); |
5943 | unsigned long *n = end_of_stack(p); | ||
5944 | while (!*n) | ||
5945 | n++; | ||
5946 | free = (unsigned long)n - (unsigned long)end_of_stack(p); | ||
5947 | } | ||
5948 | #endif | 5943 | #endif |
5949 | printk(KERN_CONT "%5lu %5d %6d\n", free, | 5944 | printk(KERN_CONT "%5lu %5d %6d\n", free, |
5950 | task_pid_nr(p), task_pid_nr(p->real_parent)); | 5945 | task_pid_nr(p), task_pid_nr(p->real_parent)); |