Re: [PATCH v4 13/15] tracing/filters: Fix error positions for CPUS mask parsing

From: Steven Rostedt

Date: Tue Nov 24 2026 - 19:44:55 EST


On Thu, 29 Oct 2026 10:39:25 +0900
"Masami Hiramatsu (Google)" <mhiramat@xxxxxxxxxx> wrote:

> From: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>
>
> In parse_pred(), CPUS mask error paths report incorrect error positions:
> - Checking 'str[i++] != '\'{'\'' post-increments 'i' before calling
> parse_error(), shifting the error caret one character past the
> missing brace position.
> - In the CPUS operator check and comparison function selection check,
> 'pos + i' points to the CPUS operand or past it instead of the
> unsupported operator.
>
> Check 'str[i] != '\'{'\'' before incrementing 'i', and pass 'pos + op_pos'
> for the operator checks so the error caret points accurately.
>
> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>
> ---
> Changes in v4:
> - Drop Fixes and Cc: stable tags since these error position fixes are
> cleanups.
> Changes in v3:
> - Group error position fixes for CPUS mask parsing into a single patch
> targeting commit 39f7c41c908b and commit 3cbec9d7b93d.
> ---
> kernel/trace/trace_events_filter.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
> index 9b1100769676..1a9a1cc8daa2 100644
> --- a/kernel/trace/trace_events_filter.c
> +++ b/kernel/trace/trace_events_filter.c
> @@ -1932,16 +1932,17 @@ static int parse_pred(const char *str, void *data,
> case OP_BAND:
> break;
> default:
> - parse_error(pe, FILT_ERR_ILLEGAL_FIELD_OP, pos + i);
> + parse_error(pe, FILT_ERR_ILLEGAL_FIELD_OP, pos + op_pos);
> goto err_free;
> }
>
> /* Skip CPUS */
> i += 4;
> - if (str[i++] != '{') {
> + if (str[i] != '{') {
> parse_error(pe, FILT_ERR_MISSING_BRACE_OPEN, pos + i);

Instead of moving the i++ to below, couldn't you just make the above:

parse_error(pe, FILT_ERR_MISSING_BRACE_OPEN, pos + i - 1);

?

-- Steve



> goto err_free;
> }
> + i++;
> maskstart = i;
>
> /* Walk the cpulist until closing } */
> @@ -2029,7 +2030,7 @@ static int parse_pred(const char *str, void *data,
> }
> }
> if (pred->fn_num == FILTER_PRED_FN_NOP) {
> - parse_error(pe, FILT_ERR_INVALID_OP, pos + i);
> + parse_error(pe, FILT_ERR_INVALID_OP, pos + op_pos);
> goto err_free;
> }
>