[for-linus][PATCH 10/32] tracing/filters: Check for missing operand after operator in parse_pred()

From: Steven Rostedt

Date: Fri Nov 20 2026 - 12:43:15 EST


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

In parse_pred(), after matching the operator and skipping whitespace,
the filter string may terminate (str[i] == '\0') if the operand is
missing (e.g. "ip ==" or "common_pid ==").

For function events, the loop 'for (i++; str[i]; i++)' unconditionally
increments 'i' past the NUL terminator, causing an out-of-bounds read.
For other event types, allocating a predicate only to fail later during
value parsing is wasteful.

Check if 'str[i]' is NUL immediately after skipping whitespace after
the operator, and report FILT_ERR_INVALID_FILTER.

Cc: stable@xxxxxxxxxxxxxxx
Fixes: 80765597bc58 ("tracing: Rewrite filter logic to be simpler and faster")
Link: https://patch.msgid.link/179323789181.740114.16161070743864669086.stgit@devnote2
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>
Signed-off-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
---
kernel/trace/trace_events_filter.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index 1b960cfdc69d..32fcc6215d24 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -1766,6 +1766,11 @@ static int parse_pred(const char *str, void *data,
while (isspace(str[i]))
i++;

+ if (!str[i]) {
+ parse_error(pe, FILT_ERR_INVALID_FILTER, pos + i);
+ goto err_free;
+ }
+
s = i;

pred = kzalloc_obj(*pred);
--
2.53.0