diff options
| author | Steven Rostedt <srostedt@redhat.com> | 2010-03-12 19:41:23 -0500 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-04-01 19:01:16 -0400 |
| commit | a86a83770fe3cc858f91b0ae6406477dc8d0bf17 (patch) | |
| tree | cf4a66ad68b7bbd83e38b200c090a871ee7e8afb /kernel | |
| parent | 65bddd361043f9e65122c39f714d3d6471c5c0e3 (diff) | |
function-graph: Init curr_ret_stack with ret_stack
commit ea14eb714041d40fcc5180b5a586034503650149 upstream.
If the graph tracer is active, and a task is forked but the allocating of
the processes graph stack fails, it can cause crash later on.
This is due to the temporary stack being NULL, but the curr_ret_stack
variable is copied from the parent. If it is not -1, then in
ftrace_graph_probe_sched_switch() the following:
for (index = next->curr_ret_stack; index >= 0; index--)
next->ret_stack[index].calltime += timestamp;
Will cause a kernel OOPS.
Found with Li Zefan's ftrace_stress_test.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/trace/ftrace.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 1e6640f80454..404c9ba1602b 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c | |||
| @@ -3364,6 +3364,7 @@ void ftrace_graph_init_task(struct task_struct *t) | |||
| 3364 | { | 3364 | { |
| 3365 | /* Make sure we do not use the parent ret_stack */ | 3365 | /* Make sure we do not use the parent ret_stack */ |
| 3366 | t->ret_stack = NULL; | 3366 | t->ret_stack = NULL; |
| 3367 | t->curr_ret_stack = -1; | ||
| 3367 | 3368 | ||
| 3368 | if (ftrace_graph_active) { | 3369 | if (ftrace_graph_active) { |
| 3369 | struct ftrace_ret_stack *ret_stack; | 3370 | struct ftrace_ret_stack *ret_stack; |
| @@ -3373,7 +3374,6 @@ void ftrace_graph_init_task(struct task_struct *t) | |||
| 3373 | GFP_KERNEL); | 3374 | GFP_KERNEL); |
| 3374 | if (!ret_stack) | 3375 | if (!ret_stack) |
| 3375 | return; | 3376 | return; |
| 3376 | t->curr_ret_stack = -1; | ||
| 3377 | atomic_set(&t->tracing_graph_pause, 0); | 3377 | atomic_set(&t->tracing_graph_pause, 0); |
| 3378 | atomic_set(&t->trace_overrun, 0); | 3378 | atomic_set(&t->trace_overrun, 0); |
| 3379 | t->ftrace_timestamp = 0; | 3379 | t->ftrace_timestamp = 0; |
