Cong Wang 2884dc7d08 bpf: Fix a potential use-after-free in bpf_link_free()
After commit 1a80dbcb2dba, 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: 1a80dbcb2dba ("bpf: support deferring bpf_link dealloc to after RCU grace period")
Reported-by: syzbot+1989ee16d94720836244@syzkaller.appspotmail.com
Signed-off-by: Cong Wang <cong.wang@bytedance.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/bpf/20240602182703.207276-1-xiyou.wangcong@gmail.com
2024-06-03 18:16:19 +02:00
..
2024-05-19 11:38:15 -07:00
2024-05-13 14:14:05 -07:00
2024-05-20 10:23:39 -07:00
2024-05-22 10:49:54 -07:00
2024-05-22 12:13:40 -07:00
2024-05-27 08:09:12 -07:00
2024-05-22 11:53:02 -07:00
2024-05-21 15:29:01 -07:00
2024-05-17 17:31:24 -07:00
2024-05-15 17:06:08 -07:00
2024-05-23 12:04:36 -07:00
2023-12-23 15:52:13 +01:00
2023-10-19 11:02:48 +02:00
2024-04-25 21:07:04 -07:00
2024-05-06 14:22:02 -06:00
2024-03-01 12:23:37 +01:00
2023-12-01 09:51:44 -08:00
2024-03-13 12:53:53 -07:00
2024-05-17 17:31:24 -07:00
2024-05-23 12:04:36 -07:00
2023-10-30 17:56:53 -10:00
2023-10-04 10:41:57 -07:00
2024-05-17 17:31:24 -07:00
2023-12-29 12:22:29 -08:00
2024-05-23 19:40:26 -07:00
2024-05-17 17:31:24 -07:00
2024-04-25 20:56:00 -07:00