Skip to content

Commit

Permalink
function-graph: always initialize task ret_stack
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Steven Rostedt authored and Steven Rostedt committed Jun 2, 2009
1 parent f7e8b61 commit 84047e3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions kernel/trace/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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)
Expand Down

0 comments on commit 84047e3

Please sign in to comment.