Commit 8bb7829
bpf, sockmap: Avoid sk_prot reset on sockmap unlink with ULP set
WARNING: CPU: 0 PID: 6558 at net/core/sock_map.c:1703 sock_map_close+0x3c4/0x480
Modules linked in:
CPU: 0 UID: 0 PID: 6558 Comm: syz-executor.14 Not tainted 6.14.0-rc5+ kernel-patches#238
RIP: 0010:sock_map_close+0x3c4/0x480
Call Trace:
<TASK>
inet_release+0x144/0x280
__sock_release+0xb8/0x270
sock_close+0x1e/0x30
__fput+0x3c6/0xb30
__fput_sync+0x7b/0x90
__x64_sys_close+0x90/0x120
do_syscall_64+0x5d/0x170
entry_SYSCALL_64_after_hwframe+0x76/0x7e
The root cause is:
bpf_prog_attach(BPF_SK_SKB_STREAM_VERDICT)
tcp_set_ulp //set ulp after sockmap add
icsk->icsk_ulp_ops = ulp_ops;
sock_hash_update_common
sock_map_unref
sock_map_del_link
psock->psock_update_sk_prot(sk, psock, false);
sk->sk_prot->close = sock_map_close
sk_psock_drop
sk_psock_restore_proto
tcp_bpf_update_proto
tls_update //not redo sk_prot to tcp prot
inet_release
sk->sk_prot->close
sock_map_close
WARN(sk->sk_prot->close == sock_map_close)
commit e34a07c ("sock: redo the psock vs ULP protection check")
has moved ulp check from tcp_bpf_update_proto() to psock init.
If sk sets ulp after being added to sockmap, it will reset sk_prot to
BPF_BASE when removed from sockmap. After the psock is dropped, it will
not reset sk_prot back to the tcp prot, only tls context update is
performed. This can trigger a warning in sock_map_close() due to
recursion of sk->sk_prot->close.
To fix this issue, skip the sk_prot operations redo when deleting link
from sockmap if ULP is set.
Fixes: e34a07c ("sock: redo the psock vs ULP protection check")
Fixes: c0d95d3 ("bpf, sockmap: Re-evaluate proto ops when psock is removed from sockmap")
Suggested-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Dong Chenchen <dongchenchen2@huawei.com>
Signed-off-by: NipaLocal <nipa@local>1 parent bc2433b commit 8bb7829
1 file changed
+3
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
708 | 708 | | |
709 | 709 | | |
710 | 710 | | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
711 | 714 | | |
712 | 715 | | |
713 | 716 | | |
| |||
0 commit comments