diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/fork.c | 12 | ||||
-rw-r--r-- | kernel/trace/trace_stack.c | 4 |
2 files changed, 10 insertions, 6 deletions
diff --git a/kernel/fork.c b/kernel/fork.c index 9387ae8ab048..ad64248c4b18 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
@@ -294,11 +294,18 @@ int __weak arch_dup_task_struct(struct task_struct *dst, | |||
294 | return 0; | 294 | return 0; |
295 | } | 295 | } |
296 | 296 | ||
297 | void set_task_stack_end_magic(struct task_struct *tsk) | ||
298 | { | ||
299 | unsigned long *stackend; | ||
300 | |||
301 | stackend = end_of_stack(tsk); | ||
302 | *stackend = STACK_END_MAGIC; /* for overflow detection */ | ||
303 | } | ||
304 | |||
297 | static struct task_struct *dup_task_struct(struct task_struct *orig) | 305 | static struct task_struct *dup_task_struct(struct task_struct *orig) |
298 | { | 306 | { |
299 | struct task_struct *tsk; | 307 | struct task_struct *tsk; |
300 | struct thread_info *ti; | 308 | struct thread_info *ti; |
301 | unsigned long *stackend; | ||
302 | int node = tsk_fork_get_node(orig); | 309 | int node = tsk_fork_get_node(orig); |
303 | int err; | 310 | int err; |
304 | 311 | ||
@@ -328,8 +335,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig) | |||
328 | setup_thread_stack(tsk, orig); | 335 | setup_thread_stack(tsk, orig); |
329 | clear_user_return_notifier(tsk); | 336 | clear_user_return_notifier(tsk); |
330 | clear_tsk_need_resched(tsk); | 337 | clear_tsk_need_resched(tsk); |
331 | stackend = end_of_stack(tsk); | 338 | set_task_stack_end_magic(tsk); |
332 | *stackend = STACK_END_MAGIC; /* for overflow detection */ | ||
333 | 339 | ||
334 | #ifdef CONFIG_CC_STACKPROTECTOR | 340 | #ifdef CONFIG_CC_STACKPROTECTOR |
335 | tsk->stack_canary = get_random_int(); | 341 | tsk->stack_canary = get_random_int(); |
diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c index 8a4e5cb66a4c..1636e41828c2 100644 --- a/kernel/trace/trace_stack.c +++ b/kernel/trace/trace_stack.c | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/sysctl.h> | 13 | #include <linux/sysctl.h> |
14 | #include <linux/init.h> | 14 | #include <linux/init.h> |
15 | #include <linux/fs.h> | 15 | #include <linux/fs.h> |
16 | #include <linux/magic.h> | ||
17 | 16 | ||
18 | #include <asm/setup.h> | 17 | #include <asm/setup.h> |
19 | 18 | ||
@@ -171,8 +170,7 @@ check_stack(unsigned long ip, unsigned long *stack) | |||
171 | i++; | 170 | i++; |
172 | } | 171 | } |
173 | 172 | ||
174 | if ((current != &init_task && | 173 | if (*end_of_stack(current) != STACK_END_MAGIC) { |
175 | *(end_of_stack(current)) != STACK_END_MAGIC)) { | ||
176 | print_max_stack(); | 174 | print_max_stack(); |
177 | BUG(); | 175 | BUG(); |
178 | } | 176 | } |