[PATCH v3 13/16] tracing/filters: Fix error position for function filter operations
From: Masami Hiramatsu (Google)
Date: Tue Oct 27 2026 - 20:46:20 EST
From: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>
In parse_pred(), by the time the '.function' field size and operator
checks are reached, 'i' has already been advanced past the operator to
the operand.
Save the position of the '.function' modifier in 'fn_pos' and pass
'pos + fn_pos' for ILLEGAL_FIELD_OP and 'pos + op_pos' for INVALID_OP
so the error caret points to '.function' and the operator respectively.
Fixes: e6745a4da964 ("tracing: Add a way to filter function addresses to function names")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>
---
Changes in v3:
- Newly added to fix error positions for .function modifier and
operator checks in parse_pred().
---
kernel/trace/trace_events_filter.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index 903caf62a407..b1b4f1a57dc9 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -1695,6 +1695,7 @@ static int parse_pred(const char *str, void *data,
int op;
int s;
int field_pos = 0;
+ int fn_pos = 0;
int op_pos = 0;
int i = 0;
@@ -1736,6 +1737,7 @@ static int parse_pred(const char *str, void *data,
/* See if the field is a kernel function name */
if ((len = str_has_prefix(str + i, ".function"))) {
function = true;
+ fn_pos = i;
i += len;
}
@@ -1779,7 +1781,7 @@ static int parse_pred(const char *str, void *data,
if (function) {
/* The field must be the same size as long */
if (field->size != sizeof(long)) {
- parse_error(pe, FILT_ERR_ILLEGAL_FIELD_OP, pos + i);
+ parse_error(pe, FILT_ERR_ILLEGAL_FIELD_OP, pos + fn_pos);
goto err_free;
}
@@ -1789,7 +1791,7 @@ static int parse_pred(const char *str, void *data,
case OP_EQ:
break;
default:
- parse_error(pe, FILT_ERR_INVALID_OP, pos + i);
+ parse_error(pe, FILT_ERR_INVALID_OP, pos + op_pos);
goto err_free;
}