diff options
author | Steven Rostedt <srostedt@redhat.com> | 2009-06-02 12:26:07 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2009-06-02 14:41:50 -0400 |
commit | 82310a3272d5a2a7652f5649ad8a55f58c8f74d9 (patch) | |
tree | c909c7a3f1fd3430f64be1d4aa8aff84fdf45b04 /kernel/trace/trace_functions_graph.c | |
parent | 179c498ae2998461fe436437a74dc29036fc7dcc (diff) | |
download | op-kernel-dev-82310a3272d5a2a7652f5649ad8a55f58c8f74d9.zip op-kernel-dev-82310a3272d5a2a7652f5649ad8a55f58c8f74d9.tar.gz |
function-graph: enable the stack after initialization of other variables
The function graph tracer checks if the task_struct has ret_stack defined
to know if it is OK or not to use it. The initialization is done for
all tasks by one process, but the idle tasks use the same initialization
used by new tasks.
If an interrupt happens on an idle task that just had the ret_stack
created, but before the rest of the initialization took place, then
we can corrupt the return address of the functions.
This patch moves the setting of the task_struct's ret_stack to after
the other variables have been initialized.
[ Impact: prevent kernel panic on idle task when starting function graph ]
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace/trace_functions_graph.c')
-rw-r--r-- | kernel/trace/trace_functions_graph.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c index d28687e..baeb5fe 100644 --- a/kernel/trace/trace_functions_graph.c +++ b/kernel/trace/trace_functions_graph.c @@ -65,6 +65,12 @@ ftrace_push_return_trace(unsigned long ret, unsigned long func, int *depth) if (!current->ret_stack) return -EBUSY; + /* + * We must make sure the ret_stack is tested before we read + * anything else. + */ + smp_rmb(); + /* The return trace stack is full */ if (current->curr_ret_stack == FTRACE_RETFUNC_DEPTH - 1) { atomic_inc(¤t->trace_overrun); |