]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/2.6.33.2/function-graph-init-curr_ret_stack-with-ret_stack.patch
5.0-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 2.6.33.2 / function-graph-init-curr_ret_stack-with-ret_stack.patch
1 From ea14eb714041d40fcc5180b5a586034503650149 Mon Sep 17 00:00:00 2001
2 From: Steven Rostedt <srostedt@redhat.com>
3 Date: Fri, 12 Mar 2010 19:41:23 -0500
4 Subject: function-graph: Init curr_ret_stack with ret_stack
5
6 From: Steven Rostedt <srostedt@redhat.com>
7
8 commit ea14eb714041d40fcc5180b5a586034503650149 upstream.
9
10 If the graph tracer is active, and a task is forked but the allocating of
11 the processes graph stack fails, it can cause crash later on.
12
13 This is due to the temporary stack being NULL, but the curr_ret_stack
14 variable is copied from the parent. If it is not -1, then in
15 ftrace_graph_probe_sched_switch() the following:
16
17 for (index = next->curr_ret_stack; index >= 0; index--)
18 next->ret_stack[index].calltime += timestamp;
19
20 Will cause a kernel OOPS.
21
22 Found with Li Zefan's ftrace_stress_test.
23
24 Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
25 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
26
27 ---
28 kernel/trace/ftrace.c | 2 +-
29 1 file changed, 1 insertion(+), 1 deletion(-)
30
31 --- a/kernel/trace/ftrace.c
32 +++ b/kernel/trace/ftrace.c
33 @@ -3364,6 +3364,7 @@ void ftrace_graph_init_task(struct task_
34 {
35 /* Make sure we do not use the parent ret_stack */
36 t->ret_stack = NULL;
37 + t->curr_ret_stack = -1;
38
39 if (ftrace_graph_active) {
40 struct ftrace_ret_stack *ret_stack;
41 @@ -3373,7 +3374,6 @@ void ftrace_graph_init_task(struct task_
42 GFP_KERNEL);
43 if (!ret_stack)
44 return;
45 - t->curr_ret_stack = -1;
46 atomic_set(&t->tracing_graph_pause, 0);
47 atomic_set(&t->trace_overrun, 0);
48 t->ftrace_timestamp = 0;