Skip to content

Commit e9c856c

Browse files
anakryikoAlexei Starovoitov
authored andcommitted
bpf: put uprobe link's path and task in release callback
There is no need to delay putting either path or task to deallocation step. It can be done right after bpf_uprobe_unregister. Between release and dealloc, there could be still some running BPF programs, but they don't access either task or path, only data in link->uprobes, so it is safe to do. On the other hand, doing path_put() in dealloc callback makes this dealloc sleepable because path_put() itself might sleep. Which is problematic due to the need to call uprobe's dealloc through call_rcu(), which is what is done in the next bug fix patch. So solve the problem by releasing these resources early. Signed-off-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 0379654 commit e9c856c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

kernel/trace/bpf_trace.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3157,16 +3157,16 @@ static void bpf_uprobe_multi_link_release(struct bpf_link *link)
31573157

31583158
umulti_link = container_of(link, struct bpf_uprobe_multi_link, link);
31593159
bpf_uprobe_unregister(&umulti_link->path, umulti_link->uprobes, umulti_link->cnt);
3160+
if (umulti_link->task)
3161+
put_task_struct(umulti_link->task);
3162+
path_put(&umulti_link->path);
31603163
}
31613164

31623165
static void bpf_uprobe_multi_link_dealloc(struct bpf_link *link)
31633166
{
31643167
struct bpf_uprobe_multi_link *umulti_link;
31653168

31663169
umulti_link = container_of(link, struct bpf_uprobe_multi_link, link);
3167-
if (umulti_link->task)
3168-
put_task_struct(umulti_link->task);
3169-
path_put(&umulti_link->path);
31703170
kvfree(umulti_link->uprobes);
31713171
kfree(umulti_link);
31723172
}

0 commit comments

Comments
 (0)