Skip to content

Commit 6921d1e

Browse files
ea1davisrostedt
authored andcommitted
tracing: Fix filter logic error
If the processing of the tr->events loop fails, the filter that has been added to filter_head will be released twice in free_filter_list(&head->rcu) and __free_filter(filter). After adding the filter of tr->events, add the filter to the filter_head process to avoid triggering uaf. Link: https://lore.kernel.org/[email protected] Fixes: a9d0aab ("tracing: Fix regression of filter waiting a long time on RCU synchronization") Reported-by: [email protected] Closes: https://syzkaller.appspot.com/bug?extid=daba72c4af9915e9c894 Tested-by: [email protected] Acked-by: Masami Hiramatsu (Google) <[email protected]> Signed-off-by: Edward Adam Davis <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 86731a2 commit 6921d1e

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

kernel/trace/trace_events_filter.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,13 +1436,6 @@ static void filter_free_subsystem_filters(struct trace_subsystem_dir *dir,
14361436

14371437
INIT_LIST_HEAD(&head->list);
14381438

1439-
item = kmalloc(sizeof(*item), GFP_KERNEL);
1440-
if (!item)
1441-
goto free_now;
1442-
1443-
item->filter = filter;
1444-
list_add_tail(&item->list, &head->list);
1445-
14461439
list_for_each_entry(file, &tr->events, list) {
14471440
if (file->system != dir)
14481441
continue;
@@ -1454,6 +1447,13 @@ static void filter_free_subsystem_filters(struct trace_subsystem_dir *dir,
14541447
event_clear_filter(file);
14551448
}
14561449

1450+
item = kmalloc(sizeof(*item), GFP_KERNEL);
1451+
if (!item)
1452+
goto free_now;
1453+
1454+
item->filter = filter;
1455+
list_add_tail(&item->list, &head->list);
1456+
14571457
delay_free_filter(head);
14581458
return;
14591459
free_now:

0 commit comments

Comments
 (0)