]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
riscv: Fix ftrace_graph_ret_addr() to use the correct task pointer
authorRui Qi <qirui.001@bytedance.com>
Sun, 7 Jun 2026 02:17:53 +0000 (20:17 -0600)
committerPaul Walmsley <pjw@kernel.org>
Sun, 7 Jun 2026 02:17:53 +0000 (20:17 -0600)
The walk_stackframe() function is used to unwind the stack of a given
task. When function graph tracing is enabled, ftrace_graph_ret_addr()
is called to resolve the original return address if it was modified by
the tracer.

The current code incorrectly passes 'current' instead of 'task' to
ftrace_graph_ret_addr(). This causes incorrect return address resolution
when unwinding a stack of a different task (e.g., when the task is
blocked in __switch_to).

Fix this by passing 'task' instead of 'current' to match the behavior
of other architectures (arm64, loongarch, powerpc, s390, x86).

Signed-off-by: Rui Qi <qirui.001@bytedance.com>
Link: https://patch.msgid.link/20260408092915.46408-1-qirui.001@bytedance.com
Signed-off-by: Paul Walmsley <pjw@kernel.org>
arch/riscv/kernel/stacktrace.c

index b41b6255751cb1dc53277c19f438e5729ec3e303..2692d3a06afa2be5e1cd94fe8ec0c9f721ad2884 100644 (file)
@@ -87,7 +87,7 @@ void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
                } else {
                        fp = READ_ONCE_TASK_STACK(task, frame->fp);
                        pc = READ_ONCE_TASK_STACK(task, frame->ra);
-                       pc = ftrace_graph_ret_addr(current, &graph_idx, pc,
+                       pc = ftrace_graph_ret_addr(task, &graph_idx, pc,
                                                   &frame->ra);
                        if (pc >= (unsigned long)handle_exception &&
                            pc < (unsigned long)&ret_from_exception_end) {