[for-next][PATCH 11/24] tracing: Fix ftrace_graph_get_ret_stack() to use task and not current

From: Steven Rostedt
Date: Fri Dec 21 2018 - 12:58:11 EST

From: "Steven Rostedt (VMware)" <rostedt@xxxxxxxxxxx>

The function ftrace_graph_get_ret_stack() takes a task struct descriptor but
uses current as the task to perform the operations on. In pretty much all
cases the task decriptor is the same as current, so this wasn't an issue.
But there is a case in the ARM architecture that passes in a task that is
not current, and expects a result from that task, and this code breaks it.

Fixes: 51584396cff5 ("arm64: Use ftrace_graph_get_ret_stack() instead of curr_ret_stack")
Reported-by: James Morse <james.morse@xxxxxxx>
Tested-by: James Morse <james.morse@xxxxxxx>
Signed-off-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx>
kernel/trace/fgraph.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c
index d4f04f0ca646..8dfd5021b933 100644
--- a/kernel/trace/fgraph.c
+++ b/kernel/trace/fgraph.c
@@ -246,10 +246,10 @@ unsigned long ftrace_return_to_handler(unsigned long frame_pointer)
struct ftrace_ret_stack *
ftrace_graph_get_ret_stack(struct task_struct *task, int idx)
- idx = current->curr_ret_stack - idx;
+ idx = task->curr_ret_stack - idx;

if (idx >= 0 && idx <= task->curr_ret_stack)
- return &current->ret_stack[idx];
+ return &task->ret_stack[idx];

return NULL;