Skip to content

Commit a3e892a

Browse files
committed
tracing: fprobe: Fix infinite recursion using preempt_*_notrace()
Since preempt_count_add/del() are tracable functions, it is not allowed to use preempt_disable/enable() in ftrace handlers. Without this fix, probing on `preempt_count_add%return` will cause an infinite recursion of fprobes. To fix this problem, use preempt_disable/enable_notrace() in fprobe_return(). Link: https://lore.kernel.org/all/175374642359.1471729.1054175011228386560.stgit@mhiramat.tok.corp.google.com/ Fixes: 4346ba1 ("fprobe: Rewrite fprobe on function-graph tracer") Cc: [email protected] Signed-off-by: Masami Hiramatsu (Google) <[email protected]>
1 parent 038d61f commit a3e892a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/trace/fprobe.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ static void fprobe_return(struct ftrace_graph_ret *trace,
352352
size_words = SIZE_IN_LONG(size);
353353
ret_ip = ftrace_regs_get_instruction_pointer(fregs);
354354

355-
preempt_disable();
355+
preempt_disable_notrace();
356356

357357
curr = 0;
358358
while (size_words > curr) {
@@ -368,7 +368,7 @@ static void fprobe_return(struct ftrace_graph_ret *trace,
368368
}
369369
curr += size;
370370
}
371-
preempt_enable();
371+
preempt_enable_notrace();
372372
}
373373
NOKPROBE_SYMBOL(fprobe_return);
374374

0 commit comments

Comments
 (0)