History

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.

Steven Rostedt committed 1 year ago

Commit 8a157d81 parent 19272b31 file · +1 −3Browse files

Unified · Split

kernel/trace/trace_events_filter.c+1−3
@@ -1437,10 +1437,8 @@ static void filter_free_subsystem_filters(struct trace_subsystem_dir *dir, · 1436 unmodified lines
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);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t