Skip to content

Commit b4a1dec

Browse files
sumanthkorikkarVasily Gorbik
authored andcommitted
s390/ftrace: Fix return address recovery of traced function
When fgraph is enabled the traced function return address is replaced with trampoline return_to_handler(). The original return address of the traced function is saved in per task return stack along with a stack pointer for reliable stack unwinding via function_graph_enter_regs(). During stack unwinding e.g. for livepatching, ftrace_graph_ret_addr() identifies the original return address of the traced function with the saved stack pointer. With a recent change, the stack pointers passed to ftrace_graph_ret_addr() and function_graph_enter_regs() do not match anymore, and therefore the original return address is not found. Pass the correct stack pointer to function_graph_enter_regs() to fix this. Fixes: 7495e17 ("s390/tracing: Enable HAVE_FTRACE_GRAPH_FUNC") Reviewed-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Sumanth Korikkar <sumanthk@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
1 parent a22ee38 commit b4a1dec

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/s390/kernel/ftrace.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,12 +266,13 @@ void ftrace_graph_func(unsigned long ip, unsigned long parent_ip,
266266
struct ftrace_ops *op, struct ftrace_regs *fregs)
267267
{
268268
unsigned long *parent = &arch_ftrace_regs(fregs)->regs.gprs[14];
269+
unsigned long sp = arch_ftrace_regs(fregs)->regs.gprs[15];
269270

270271
if (unlikely(ftrace_graph_is_dead()))
271272
return;
272273
if (unlikely(atomic_read(&current->tracing_graph_pause)))
273274
return;
274-
if (!function_graph_enter_regs(*parent, ip, 0, parent, fregs))
275+
if (!function_graph_enter_regs(*parent, ip, 0, (unsigned long *)sp, fregs))
275276
*parent = (unsigned long)&return_to_handler;
276277
}
277278

0 commit comments

Comments
 (0)