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 <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Link: https://lore.kernel.org/[email protected] Fixes: a9d0aab ("tracing: Fix regression of filter waiting a long time on RCU synchronization") Reported-by: kernel test robot <[email protected]> Reported-by: Dan Carpenter <[email protected]> Closes: https://lore.kernel.org/r/[email protected]/ Signed-off-by: Steven Rostedt (Google) <[email protected]>
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)