]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
function-graph: add memory barriers for accessing task's ret_stack
authorSteven Rostedt <srostedt@redhat.com>
Tue, 2 Jun 2009 18:01:19 +0000 (14:01 -0400)
committerSteven Rostedt <rostedt@goodmis.org>
Tue, 2 Jun 2009 18:42:17 +0000 (14:42 -0400)
The code that handles the tasks ret_stack allocation for every task
assumes that only an interrupt can cause issues (even though interrupts
are disabled).

In reality, the code is allocating the ret_stack for tasks that may be
running on other CPUs and there are not efficient memory barriers to
handle this case.

[ Impact: prevent crash due to using of uninitialized ret_stack variables ]

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
kernel/trace/ftrace.c

index 20e066065eb3934fd497ecc93d92cebc152a972d..1664d3f33d38caf52592e79a7fef78f7344e586a 100644 (file)
@@ -2580,12 +2580,12 @@ static int alloc_retstack_tasklist(struct ftrace_ret_stack **ret_stack_list)
                }
 
                if (t->ret_stack == NULL) {
-                       t->curr_ret_stack = -1;
-                       /* Make sure IRQs see the -1 first: */
-                       barrier();
-                       t->ret_stack = ret_stack_list[start++];
                        atomic_set(&t->tracing_graph_pause, 0);
                        atomic_set(&t->trace_overrun, 0);
+                       t->curr_ret_stack = -1;
+                       /* Make sure the tasks see the -1 first: */
+                       smp_wmb();
+                       t->ret_stack = ret_stack_list[start++];
                }
        } while_each_thread(g, t);