Skip to contentSkip to conversation

tracing/function-return-tracer: Add a barrier to ensure return stack index is incremented in memory

PATCH Applied Frederic Weisbecker 3 participants 3 messages Nov 15, 2008 – Nov 16, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tracing/function-return-tracer: Add a barrier to ensure return stack 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.

---
 arch/x86/kernel/ftrace.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
arch/x86/kernel/ftrace.c +1 -0
index fe83273..db25236 100644
@@ -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;
Signature · 1 line
1.5.2.5
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Frederic Weisbecker

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.

-- Steve

Quoted 17 lines
Cc Andi Kleen <[email protected]>
---
 arch/x86/kernel/ftrace.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
arch/x86/kernel/ftrace.c +1 -0
index fe83273..db25236 100644
@@ -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;
Applied
#2 lore raw
In reply to Frederic Weisbecker
Quoted 10 lines · Frederic Weisbecker

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.

applied, thanks Frederic!

Ingo