Re: [PATCH 04/10] tracing/filters: Handle out-of-range CPU for OP_NE in cpumask comparison
From: Steven Rostedt
Date: Mon Oct 26 2026 - 15:39:07 EST
On Sun, 25 Oct 2026 01:26:01 +0900
"Masami Hiramatsu (Google)" <mhiramat@xxxxxxxxxx> wrote:
> From: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>
>
> In filter_pred_##size##_cpumask(), if the event's scalar CPU value is
> out of range (cpu >= nr_cpu_ids), it unconditionally returns 0.
>
> However, if the predicate operation is OP_NE (e.g., field != CPUS{0,1}),
> an out-of-range CPU cannot match any valid CPU in the user-provided
> cpumask and the condition is satisfied. Returning 0 produces a false
> negative.
>
> Return "pred->op == OP_NE" instead of 0 when cpu >= nr_cpu_ids.
>
> Fixes: 3cbec9d7b93d ("tracing/filters: Enable filtering a scalar field by a cpumask")
> Cc: stable@xxxxxxxxxxxxxxx
BTW, a lot of these are just "stupid input produces stupid results" and I
personally feel it doesn't deserve a stable tag. I don't even think it
deserves the "fixes" tag.
Now if the stupid input were to produce a crash or warning, then that's
different.
-- Steve
> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@xxxxxxxxxx>
> ---
> kernel/trace/trace_events_filter.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
> index 69da95f42541..d9aeeec4ed91 100644
> --- a/kernel/trace/trace_events_filter.c
> +++ b/kernel/trace/trace_events_filter.c
> @@ -762,7 +762,7 @@ static int filter_pred_##size##_cpumask(struct filter_pred *pred, void *event) \
> unsigned int cpu = *addr; \
> \
> if (cpu >= nr_cpu_ids) \
> - return 0; \
> + return pred->op == OP_NE; \
> \
> return do_filter_scalar_cpumask(pred->op, cpu, pred->mask); \
> }