[for-next][PATCH 11/15] tracing/filters: Reject empty unquoted operand in function event filter
From: Steven Rostedt
Date: Thu Nov 26 2026 - 11:25:18 EST
From: "Masami Hiramatsu (Google)" <mhiramat@xxxxxxxxxx>
In parse_pred(), when parsing an unquoted operand for function events,
if the filter expression has no operand before a delimiter (e.g.
'(ip == )' or '(ip == && x == 1)'), the loop terminates with len == 0.
While an empty quoted string (e.g. 'ip == ""') is syntactically valid
and denotes an empty pattern, an unquoted empty operand is a syntax
error where an operand was expected before the delimiter. Previously,
this accepted the predicate with an empty pattern.
Reject empty unquoted operands by checking '!q && !len' and reporting
FILT_ERR_INVALID_VALUE.
Fixes: 80765597bc58 ("tracing: Rewrite filter logic to be simpler and faster")
Link: https://patch.msgid.link/179323791027.740114.822862076687011726.stgit@devnote2
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>
Signed-off-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
---
kernel/trace/trace_events_filter.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index bce80a2c677a..79eb187be39d 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -1886,6 +1886,10 @@ static int parse_pred(const char *str, void *data,
len = i - s;
if (q)
i++;
+ if (!q && !len) {
+ parse_error(pe, FILT_ERR_INVALID_VALUE, pos + i);
+ goto err_free;
+ }
if (len >= MAX_FILTER_STR_VAL) {
parse_error(pe, FILT_ERR_OPERAND_TOO_LONG, pos + i);
goto err_free;
--
2.53.0