From: Masami Hiramatsu (Google) <[email protected]>

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: [email protected]
Signed-off-by: Masami Hiramatsu (Google) <[email protected]>
---
 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 b35ecb01697b..3f0c73819365 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -759,7 +759,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);             
\
 }


Reply via email to