aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2009-06-02 16:51:55 -0400
committerSteven Rostedt <rostedt@goodmis.org>2009-06-02 16:51:55 -0400
commit84047e360af0394ac5861d433f26bbcf30f77dd1 (patch)
tree55848e2ca4856a64b348a57ecca495c2f065aa0f /kernel/trace
parentfunction-graph: move initialization of new tasks up in fork (diff)
downloadlinux-dev-84047e360af0394ac5861d433f26bbcf30f77dd1.tar.xz
linux-dev-84047e360af0394ac5861d433f26bbcf30f77dd1.zip
function-graph: always initialize task ret_stack
On creating a new task while running the function graph tracer, if we fail to allocate the ret_stack, and then fail the fork, the code will free the parent ret_stack. This is because the child duplicated the parent and currently points to the parent's ret_stack. This patch always initializes the task's ret_stack to NULL. [ Impact: prevent crash of parent on low memory during fork ] Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace')
-rw-r--r--kernel/trace/ftrace.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 1664d3f33d38..bb081f37cac7 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -2738,6 +2738,9 @@ void unregister_ftrace_graph(void)
/* Allocate a return stack for newly created task */
void ftrace_graph_init_task(struct task_struct *t)
{
+ /* Make sure we do not use the parent ret_stack */
+ t->ret_stack = NULL;
+
if (atomic_read(&ftrace_graph_active)) {
struct ftrace_ret_stack *ret_stack;
@@ -2753,8 +2756,7 @@ void ftrace_graph_init_task(struct task_struct *t)
/* make curr_ret_stack visable before we add the ret_stack */
smp_wmb();
t->ret_stack = ret_stack;
- } else
- t->ret_stack = NULL;
+ }
}
void ftrace_graph_exit_task(struct task_struct *t)