tracing/filters: Fix double-free of struct filter_pred.mask
authorValentin Schneider <vschneid@redhat.com>
Fri, 1 Sep 2023 15:10:37 +0000 (17:10 +0200)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Sat, 2 Sep 2023 01:27:22 +0000 (21:27 -0400)
When a cpulist filter is found to contain a single CPU, that CPU is saved
as a scalar and the backing cpumask storage is freed.

Also NULL the mask to avoid a double-free once we get down to
free_predicate().

Link: https://lkml.kernel.org/r/20230901151039.125186-3-vschneid@redhat.com
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Reported-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Valentin Schneider <vschneid@redhat.com>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
kernel/trace/trace_events_filter.c

index c06e1d596f4b9474de8b6ab09e9df14f6c482257..eb331e8b00b61175caf3950eaac6e81ddfd9c83d 100644 (file)
@@ -1773,6 +1773,7 @@ static int parse_pred(const char *str, void *data,
                if (single) {
                        pred->val = cpumask_first(pred->mask);
                        kfree(pred->mask);
+                       pred->mask = NULL;
                }
 
                if (field->filter_type == FILTER_CPUMASK) {