* [PATCH v2] ftrace: Reject "!!" in front of a set_ftrace_filter command
@ 2026-11-19 3:09 Yifan Feng
2026-11-19 17:58 ` Steven Rostedt
0 siblings, 1 reply; 2+ messages in thread
From: Yifan Feng @ 2026-11-19 3:09 UTC (permalink / raw)
To: Steven Rostedt, Masami Hiramatsu
Cc: Mark Rutland, Mathieu Desnoyers, linux-trace-kernel, linux-kernel,
Yifan Feng
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.
Fixes: 23b4ff3aa479 ("ftrace: add traceon traceoff commands to enable/disable the buffers")
Suggested-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Yifan Feng <evanfengff@gmail.com>
---
v2: keep the WARN_ON() and reject "!!" before a command callback runs (Steven Rostedt).
v1: https://lore.kernel.org/linux-trace-kernel/20261118032637.80038-1-evanfengff@gmail.com
QEMU, all 7 probe commands: one WARNING each before, none after, other results unchanged.
Found and written with the help of an AI coding assistant.
kernel/trace/ftrace.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index c7d74b33d36d..44a861f021be 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -5846,6 +5846,9 @@ static int ftrace_process_regex(struct ftrace_iterator *iter,
/* command found */
+ if (func[0] == '!' && func[1] == '!')
+ return -EINVAL;
+
command = strsep(&next, ":");
guard(mutex)(&ftrace_cmd_mutex);
base-commit: 4405c18c95d2d0f99f6c581ef0ee8591a1aa6ccd
--
2.39.3 (Apple Git-146)
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v2] ftrace: Reject "!!" in front of a set_ftrace_filter command
2026-11-19 3:09 [PATCH v2] ftrace: Reject "!!" in front of a set_ftrace_filter command Yifan Feng
@ 2026-11-19 17:58 ` Steven Rostedt
0 siblings, 0 replies; 2+ messages in thread
From: Steven Rostedt @ 2026-11-19 17:58 UTC (permalink / raw)
To: Yifan Feng
Cc: Masami Hiramatsu, Mark Rutland, Mathieu Desnoyers,
linux-trace-kernel, linux-kernel
On Wed, 18 Nov 2026 19:09:00 -0800
Yifan Feng <evanfengff@gmail.com> wrote:
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> index c7d74b33d36d..44a861f021be 100644
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c
> @@ -5846,6 +5846,9 @@ static int ftrace_process_regex(struct ftrace_iterator *iter,
>
> /* command found */
>
A comment is needed here. Something like:
/*
* 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);
-- Steve
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-19 17:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 3:09 [PATCH v2] ftrace: Reject "!!" in front of a set_ftrace_filter command Yifan Feng
2026-11-19 17:58 ` Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox