Commit 2884dc7
bpf: Fix a potential use-after-free in bpf_link_free()
After commit 1a80dbc, 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: 1a80dbc ("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.com1 parent 2317dc2 commit 2884dc7
1 file changed
Lines changed: 6 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2998 | 2998 | | |
2999 | 2999 | | |
3000 | 3000 | | |
| 3001 | + | |
3001 | 3002 | | |
3002 | 3003 | | |
3003 | 3004 | | |
| |||
3056 | 3057 | | |
3057 | 3058 | | |
3058 | 3059 | | |
| 3060 | + | |
3059 | 3061 | | |
3060 | 3062 | | |
3061 | 3063 | | |
3062 | 3064 | | |
3063 | 3065 | | |
3064 | 3066 | | |
3065 | | - | |
| 3067 | + | |
3066 | 3068 | | |
3067 | 3069 | | |
3068 | | - | |
| 3070 | + | |
3069 | 3071 | | |
3070 | 3072 | | |
3071 | 3073 | | |
| |||
3074 | 3076 | | |
3075 | 3077 | | |
3076 | 3078 | | |
3077 | | - | |
3078 | | - | |
3079 | | - | |
| 3079 | + | |
| 3080 | + | |
3080 | 3081 | | |
3081 | 3082 | | |
3082 | 3083 | | |
| |||
0 commit comments