kprobes: Mark ftrace mcount handler functions nokprobe [Linux 3.16.72]

This Linux kernel change "kprobes: Mark ftrace mcount handler functions nokprobe" is included in the Linux 3.16.72 release. This change is authored by Masami Hiramatsu <mhiramat [at]> on Sun Feb 24 01:50:20 2019 +0900. The commit for this change in Linux stable tree is 51d68a4 (patch) which is from upstream commit fabe38a. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream fabe38a.

kprobes: Mark ftrace mcount handler functions nokprobe

commit fabe38ab6b2bd9418350284c63825f13b8a6abba upstream.

Mark ftrace mcount handler functions nokprobe since
probing on these functions with kretprobe pushes
return address incorrectly on kretprobe shadow stack.

Reported-by: Francis Deslauriers <[email protected]>
Tested-by: Andrea Righi <[email protected]>
Signed-off-by: Masami Hiramatsu <[email protected]>
Acked-by: Steven Rostedt <[email protected]>
Acked-by: Steven Rostedt (VMware) <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Mathieu Desnoyers <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Link:[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
[bwh: Backported to 3.16: there is no ftrace_ops_assist_func()]
Signed-off-by: Ben Hutchings <[email protected]>

There are 5 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 kernel/trace/ftrace.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 8ee705e..c59d43d 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -32,6 +32,7 @@
 #include <linux/list.h>
 #include <linux/hash.h>
 #include <linux/rcupdate.h>
+#include <linux/kprobes.h>

 #include <trace/events/sched.h>

@@ -4508,7 +4509,7 @@ void ftrace_reset_array_ops(struct trace_array *tr)

-static inline void
+static nokprobe_inline void
 __ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip,
               struct ftrace_ops *ignored, struct pt_regs *regs)
@@ -4561,11 +4562,13 @@ static void ftrace_ops_list_func(unsigned long ip, unsigned long parent_ip,
    __ftrace_ops_list_func(ip, parent_ip, NULL, regs);
 static void ftrace_ops_no_ops(unsigned long ip, unsigned long parent_ip)
    __ftrace_ops_list_func(ip, parent_ip, NULL, NULL);

 static void clear_ftrace_swapper(void)

Leave a Reply

Your email address will not be published. Required fields are marked *