Skip to content

Commit 8a157d8

Browse files
committed
tracing: Do not free "head" on error path of filter_free_subsystem_filters()
The variable "head" is allocated and initialized as a list before allocating the first "item" for the list. If the allocation of "item" fails, it frees "head" and then jumps to the label "free_now" which will process head and free it. This will cause a UAF of "head", and it doesn't need to free it before jumping to the "free_now" label as that code will free it. Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Link: https://lore.kernel.org/20250610093348.33c5643a@gandalf.local.home Fixes: a9d0aab ("tracing: Fix regression of filter waiting a long time on RCU synchronization") Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Closes: https://lore.kernel.org/r/202506070424.lCiNreTI-lkp@intel.com/ Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent 19272b3 commit 8a157d8

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

kernel/trace/trace_events_filter.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,10 +1437,8 @@ static void filter_free_subsystem_filters(struct trace_subsystem_dir *dir,
14371437
INIT_LIST_HEAD(&head->list);
14381438

14391439
item = kmalloc(sizeof(*item), GFP_KERNEL);
1440-
if (!item) {
1441-
kfree(head);
1440+
if (!item)
14421441
goto free_now;
1443-
}
14441442

14451443
item->filter = filter;
14461444
list_add_tail(&item->list, &head->list);

0 commit comments

Comments
 (0)