Skip to content

Commit 3ee9033

Browse files
rnavgregkh
authored andcommitted
powerpc/kprobes: Pause function_graph tracing during jprobes handling
commit a9f8553e935f26cb5447f67e280946b0923cd2dc upstream. This fixes a crash when function_graph and jprobes are used together. This is essentially commit 237d28d ("ftrace/jprobes/x86: Fix conflict between jprobes and function graph tracing"), but for powerpc. Jprobes breaks function_graph tracing since the jprobe hook needs to use jprobe_return(), which never returns back to the hook, but instead to the original jprobe'd function. The solution is to momentarily pause function_graph tracing before invoking the jprobe hook and re-enable it when returning back to the original jprobe'd function. Fixes: 6794c78 ("powerpc64: port of the function graph tracer") Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com> Acked-by: Masami Hiramatsu <mhiramat@kernel.org> Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent bc7b3e9 commit 3ee9033

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

arch/powerpc/kernel/kprobes.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,15 @@ int __kprobes setjmp_pre_handler(struct kprobe *p, struct pt_regs *regs)
514514
#endif
515515
#endif
516516

517+
/*
518+
* jprobes use jprobe_return() which skips the normal return
519+
* path of the function, and this messes up the accounting of the
520+
* function graph tracer.
521+
*
522+
* Pause function graph tracing while performing the jprobe function.
523+
*/
524+
pause_graph_tracing();
525+
517526
return 1;
518527
}
519528

@@ -536,6 +545,8 @@ int __kprobes longjmp_break_handler(struct kprobe *p, struct pt_regs *regs)
536545
* saved regs...
537546
*/
538547
memcpy(regs, &kcb->jprobe_saved_regs, sizeof(struct pt_regs));
548+
/* It's OK to start function graph tracing again */
549+
unpause_graph_tracing();
539550
preempt_enable_no_resched();
540551
return 1;
541552
}

0 commit comments

Comments
 (0)