Commit ea14eb714041d40fcc5180b5a586034503650149
Committed by
Steven Rostedt
1 parent
52fbe9cde7
Exists in
master
and in
7 other branches
function-graph: Init curr_ret_stack with ret_stack
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. Cc: stable@kernel.org Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff
kernel/trace/ftrace.c
... | ... | @@ -3349,6 +3349,7 @@ |
3349 | 3349 | { |
3350 | 3350 | /* Make sure we do not use the parent ret_stack */ |
3351 | 3351 | t->ret_stack = NULL; |
3352 | + t->curr_ret_stack = -1; | |
3352 | 3353 | |
3353 | 3354 | if (ftrace_graph_active) { |
3354 | 3355 | struct ftrace_ret_stack *ret_stack; |
... | ... | @@ -3358,7 +3359,6 @@ |
3358 | 3359 | GFP_KERNEL); |
3359 | 3360 | if (!ret_stack) |
3360 | 3361 | return; |
3361 | - t->curr_ret_stack = -1; | |
3362 | 3362 | atomic_set(&t->tracing_graph_pause, 0); |
3363 | 3363 | atomic_set(&t->trace_overrun, 0); |
3364 | 3364 | t->ftrace_timestamp = 0; |