Skip to contentSkip to conversation

ftrace: Do not WARN on a function probe glob that starts with '!'

PATCH In review Yifan Feng 2 participants 2 messages Nov 18

Subsystems (2)
lore
Share & tools
lore

Yifan Feng

author
#0 lore raw

PATCH 1/1 ftrace: Do not WARN on a function probe glob that starts with '!'

Removing a function probe with a second '!' in front of the glob triggers a 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 callback strips the first '!' and filter_parse_regex() then reports the second one as a negated glob. This is plain bad input from user space, so return -EINVAL without the warning.

Fixes 23b4ff3aa479 ("ftrace: add traceon traceoff commands to enable/disable the buffers")

---
Tested on v7.4-rc3 in QEMU: WARNING and taint before, -EINVAL only after. Found and written with the help of an AI coding assistant.

 kernel/trace/ftrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/ftrace.c +1 -1
index c7d74b33d36d..04ea82a18601 100644
@@ -5672,7 +5672,7 @@ unregister_ftrace_function_probe_func(char *glob, struct trace_array *tr,
 		func_g.len = strlen(func_g.search);
 
 		/* we do not support '!' for function probes */
-		if (WARN_ON(not))
+		if (not)
 			return -EINVAL;
 	}
 

base-commit: 7ccb044c27720d48175577080b851f047ddcfd1c

Signature · 1 line
2.39.3 (Apple Git-146)
maintainer
#1 lore raw
Quoted 9 lines · On Tue, 17 Nov 2026 19:26:37 -0800 Yifan Feng <[email protected]> wrote:

Removing a function probe with a second '!' in front of the glob triggers a 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 callback strips the first '!' and filter_parse_regex() then reports the second one as a negated glob. This is plain bad input from user space, so return -EINVAL without the warning.

I still want the warning because that should never happen.

The real fix is to make "!!" return -EINVAL immediately.

-- Steve

Quoted 25 lines
Fixes 23b4ff3aa479 ("ftrace: add traceon traceoff commands to enable/disable the buffers")

---
Tested on v7.4-rc3 in QEMU: WARNING and taint before, -EINVAL only after. Found and written with the help of an AI coding assistant.

 kernel/trace/ftrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/ftrace.c +1 -1
index c7d74b33d36d..04ea82a18601 100644
@@ -5672,7 +5672,7 @@ unregister_ftrace_function_probe_func(char *glob, struct trace_array *tr,
 		func_g.len = strlen(func_g.search);
 
 		/* we do not support '!' for function probes */
-		if (WARN_ON(not))
+		if (not)
 			return -EINVAL;
 	}
 

base-commit: 7ccb044c27720d48175577080b851f047ddcfd1c