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 85a83c831856..c8d0485578be 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -968,12 +968,9 @@ static void check_stack_usage(void) | |||
968 | { | 968 | { |
969 | static DEFINE_SPINLOCK(low_water_lock); | 969 | static DEFINE_SPINLOCK(low_water_lock); |
970 | static int lowest_to_date = THREAD_SIZE; | 970 | static int lowest_to_date = THREAD_SIZE; |
971 | unsigned long *n = end_of_stack(current); | ||
972 | unsigned long free; | 971 | unsigned long free; |
973 | 972 | ||
974 | while (*n == 0) | 973 | free = stack_not_used(current); |
975 | n++; | ||
976 | free = (unsigned long)n - (unsigned long)end_of_stack(current); | ||
977 | 974 | ||
978 | if (free >= lowest_to_date) | 975 | if (free >= lowest_to_date) |
979 | return; | 976 | return; |
diff --git a/kernel/fork.c b/kernel/fork.c index 30de644a40c4..99c5c655b098 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -58,6 +58,7 @@ | |||
58 | #include <linux/tty.h> | 58 | #include <linux/tty.h> |
59 | #include <linux/proc_fs.h> | 59 | #include <linux/proc_fs.h> |
60 | #include <linux/blkdev.h> | 60 | #include <linux/blkdev.h> |
61 | #include <linux/magic.h> | ||
61 | 62 | ||
62 | #include <asm/pgtable.h> | 63 | #include <asm/pgtable.h> |
63 | #include <asm/pgalloc.h> | 64 | #include <asm/pgalloc.h> |
@@ -207,6 +208,8 @@ static struct task_struct *dup_task_struct(struct task_struct *orig) | |||
207 | { | 208 | { |
208 | struct task_struct *tsk; | 209 | struct task_struct *tsk; |
209 | struct thread_info *ti; | 210 | struct thread_info *ti; |
211 | unsigned long *stackend; | ||
212 | |||
210 | int err; | 213 | int err; |
211 | 214 | ||
212 | prepare_to_copy(orig); | 215 | prepare_to_copy(orig); |
@@ -232,6 +235,8 @@ static struct task_struct *dup_task_struct(struct task_struct *orig) | |||
232 | goto out; | 235 | goto out; |
233 | 236 | ||
234 | setup_thread_stack(tsk, orig); | 237 | setup_thread_stack(tsk, orig); |
238 | stackend = end_of_stack(tsk); | ||
239 | *stackend = STACK_END_MAGIC; /* for overflow detection */ | ||
235 | 240 | ||
236 | #ifdef CONFIG_CC_STACKPROTECTOR | 241 | #ifdef CONFIG_CC_STACKPROTECTOR |
237 | tsk->stack_canary = get_random_int(); | 242 | tsk->stack_canary = get_random_int(); |
diff --git a/kernel/panic.c b/kernel/panic.c index 12c5a0a6c89b..e0a87bb025c0 100644 --- a/kernel/panic.c +++ b/kernel/panic.c | |||
@@ -80,6 +80,9 @@ NORET_TYPE void panic(const char * fmt, ...) | |||
80 | vsnprintf(buf, sizeof(buf), fmt, args); | 80 | vsnprintf(buf, sizeof(buf), fmt, args); |
81 | va_end(args); | 81 | va_end(args); |
82 | printk(KERN_EMERG "Kernel panic - not syncing: %s\n",buf); | 82 | printk(KERN_EMERG "Kernel panic - not syncing: %s\n",buf); |
83 | #ifdef CONFIG_DEBUG_BUGVERBOSE | ||
84 | dump_stack(); | ||
85 | #endif | ||
83 | bust_spinlocks(0); | 86 | bust_spinlocks(0); |
84 | 87 | ||
85 | /* | 88 | /* |
@@ -343,13 +346,20 @@ EXPORT_SYMBOL(warn_slowpath); | |||
343 | #endif | 346 | #endif |
344 | 347 | ||
345 | #ifdef CONFIG_CC_STACKPROTECTOR | 348 | #ifdef CONFIG_CC_STACKPROTECTOR |
349 | |||
350 | #ifndef GCC_HAS_SP | ||
351 | #warning You have selected the CONFIG_CC_STACKPROTECTOR option, but the gcc used does not support this. | ||
352 | #endif | ||
353 | |||
346 | /* | 354 | /* |
347 | * Called when gcc's -fstack-protector feature is used, and | 355 | * Called when gcc's -fstack-protector feature is used, and |
348 | * gcc detects corruption of the on-stack canary value | 356 | * gcc detects corruption of the on-stack canary value |
349 | */ | 357 | */ |
350 | void __stack_chk_fail(void) | 358 | void __stack_chk_fail(void) |
351 | { | 359 | { |
352 | panic("stack-protector: Kernel stack is corrupted"); | 360 | panic("stack-protector: Kernel stack is corrupted in: %p\n", |
361 | __builtin_return_address(0)); | ||
353 | } | 362 | } |
354 | EXPORT_SYMBOL(__stack_chk_fail); | 363 | EXPORT_SYMBOL(__stack_chk_fail); |
364 | |||
355 | #endif | 365 | #endif |
diff --git a/kernel/sched.c b/kernel/sched.c index 6f230596bd0c..d897a524e7d8 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -5790,12 +5790,7 @@ void sched_show_task(struct task_struct *p) | |||
5790 | printk(KERN_CONT " %016lx ", thread_saved_pc(p)); | 5790 | printk(KERN_CONT " %016lx ", thread_saved_pc(p)); |
5791 | #endif | 5791 | #endif |
5792 | #ifdef CONFIG_DEBUG_STACK_USAGE | 5792 | #ifdef CONFIG_DEBUG_STACK_USAGE |
5793 | { | 5793 | free = stack_not_used(p); |
5794 | unsigned long *n = end_of_stack(p); | ||
5795 | while (!*n) | ||
5796 | n++; | ||
5797 | free = (unsigned long)n - (unsigned long)end_of_stack(p); | ||
5798 | } | ||
5799 | #endif | 5794 | #endif |
5800 | printk(KERN_CONT "%5lu %5d %6d\n", free, | 5795 | printk(KERN_CONT "%5lu %5d %6d\n", free, |
5801 | task_pid_nr(p), task_pid_nr(p->real_parent)); | 5796 | task_pid_nr(p), task_pid_nr(p->real_parent)); |