[PATCH] fprobes: Add a comment why fprobe_kprobe_handler exits if kprobe is running

From: Masami Hiramatsu (Google)
Date: Fri Jul 07 2023 - 12:38:14 EST


From: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>

Add a comment the reason why fprobe_kprobe_handler() exits if any other
kprobe is running.

Suggested-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
Link: https://lore.kernel.org/all/20230706120916.3c6abf15@xxxxxxxxxxxxxxxxxx/
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>
---
kernel/trace/fprobe.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/kernel/trace/fprobe.c b/kernel/trace/fprobe.c
index 75517667b54f..133b31f44945 100644
--- a/kernel/trace/fprobe.c
+++ b/kernel/trace/fprobe.c
@@ -100,6 +100,12 @@ static void fprobe_kprobe_handler(unsigned long ip, unsigned long parent_ip,
return;
}

+ /*
+ * This user handler is shared with other kprobes and is not expected to be
+ * called recursively. So if any other kprobe handler is running, this will
+ * exit as kprobe does. See the section 'Share the callbacks with kprobes'
+ * in Documentation/trace/fprobe.rst for more information.
+ */
if (unlikely(kprobe_running())) {
fp->nmissed++;
return;