Skip to content

Commit

Permalink
tracing/function-return-tracer: add a barrier to ensure return stack …
Browse files Browse the repository at this point in the history
…index is incremented in memory

Impact: fix possible race condition in ftrace function return tracer

This fixes a possible race condition if index incrementation
is not immediately flushed in memory.

Thanks for Andi Kleen and Steven Rostedt for pointing out this issue
and give me this solution.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Frederic Weisbecker authored and Ingo Molnar committed Nov 16, 2008
1 parent 9858096 commit b01c746
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions arch/x86/kernel/ftrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ static int push_return_trace(unsigned long ret, unsigned long long time,
return -EBUSY;

index = ++ti->curr_ret_stack;
barrier();
ti->ret_stack[index].ret = ret;
ti->ret_stack[index].func = func;
ti->ret_stack[index].calltime = time;
Expand Down

0 comments on commit b01c746

Please sign in to comment.