[for-linus][PATCH 4/5] ftrace: Reject "!!" in front of a set_ftrace_filter command
From: Steven Rostedt
Date: Fri Nov 27 2026 - 13:43:12 EST
From: Yifan Feng <evanfengff@xxxxxxxxx>
A command written to set_ftrace_filter with two '!' in front of the
function glob triggers the WARN_ON() in
unregister_ftrace_function_probe_func():
# echo '!!vfs_read:traceoff' >> set_ftrace_filter
WARNING: kernel/trace/ftrace.c:5675 at unregister_ftrace_function_probe_func+0x662/0x870
The command callbacks strip the first '!' and pass the rest as the glob
of the probe to remove. filter_parse_regex() then reports the second
'!' as a negated glob, which function probes do not support.
Return -EINVAL for such input in ftrace_process_regex(), before a
command callback is called.
Cc: stable@xxxxxxxxxxxxxxx
Link: https://patch.msgid.link/20261119191205.32892-1-evanfengff@xxxxxxxxx
Fixes: 23b4ff3aa479 ("ftrace: add traceon traceoff commands to enable/disable the buffers")
Suggested-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
Signed-off-by: Yifan Feng <evanfengff@xxxxxxxxx>
Reviewed-by: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>
Signed-off-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
---
kernel/trace/ftrace.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 6654da9d1bbf..5b161959e701 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -5847,6 +5847,13 @@ static int ftrace_process_regex(struct ftrace_iterator *iter,
/* command found */
+ /*
+ * A double "!!" confuses the parser. This isn't a boolean operation,
+ * simply reject it.
+ */
+ if (func[0] == '!' && func[1] == '!')
+ return -EINVAL;
+
command = strsep(&next, ":");
guard(mutex)(&ftrace_cmd_mutex);
--
2.53.0