Explorar o código

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.

Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Frederic Weisbecker %!s(int64=16) %!d(string=hai) anos
pai
achega
b01c746617
Modificáronse 1 ficheiros con 1 adicións e 0 borrados
  1. 1 0
      arch/x86/kernel/ftrace.c

+ 1 - 0
arch/x86/kernel/ftrace.c

@@ -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;