Skip to content
Commit 2884dc7d authored by Cong Wang's avatar Cong Wang Committed by Daniel Borkmann
Browse files

bpf: Fix a potential use-after-free in bpf_link_free()

After commit 1a80dbcb, bpf_link can be freed by
link->ops->dealloc_deferred, but the code still tests and uses
link->ops->dealloc afterward, which leads to a use-after-free as
reported by syzbot. Actually, one of them should be sufficient, so
just call one of them instead of both. Also add a WARN_ON() in case
of any problematic implementation.

Fixes: 1a80dbcb

 ("bpf: support deferring bpf_link dealloc to after RCU grace period")
Reported-by: default avatar <syzbot+1989ee16d94720836244@syzkaller.appspotmail.com>
Signed-off-by: default avatarCong Wang <cong.wang@bytedance.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/bpf/20240602182703.207276-1-xiyou.wangcong@gmail.com
parent 2317dc2c
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment