[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z8indgh3Gv0ChOIX@mini-arch>
Date: Wed, 5 Mar 2025 11:35:18 -0800
From: Stanislav Fomichev <stfomichev@...il.com>
To: Cong Wang <xiyou.wangcong@...il.com>
Cc: Dong Chenchen <dongchenchen2@...wei.com>, edumazet@...gle.com,
kuniyu@...zon.com, pabeni@...hat.com, willemb@...gle.com,
john.fastabend@...il.com, jakub@...udflare.com, davem@...emloft.net,
kuba@...nel.org, horms@...nel.org, daniel@...earbox.net,
netdev@...r.kernel.org, bpf@...r.kernel.org,
zhangchangzhong@...wei.com, weiyongjun1@...wei.com
Subject: Re: [PATCH net] bpf, sockmap: Restore sk_prot ops when psock is
removed from sockmap
On 03/05, Cong Wang wrote:
> On Wed, Mar 05, 2025 at 10:02:34PM +0800, Dong Chenchen wrote:
> > 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+ #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:
> > sock_hash_update_common
> > sock_map_unref
> > sock_map_del_link
> > psock->psock_update_sk_prot(sk, psock, false);
> > //false won't restore proto
> > sk_psock_put
> > rcu_assign_sk_user_data(sk, NULL);
> > inet_release
> > sk->sk_prot->close
> > sock_map_close
> > WARN(sk->sk_prot->close == sock_map_close)
> >
> > When psock is removed from sockmap, sock_map_del_link() still set
> > sk->sk_prot to bpf proto instead of restore it (for incorrect restore
> > value). sock release will triger warning of sock_map_close() for
> > recurse after psock drop.
>
> But sk_psock_drop() restores it with sk_psock_restore_proto() after the
> psock reference count goes to zero. So how could the above happen?
[..]
> By the way, it would be perfect if you could add a test case for it
> together with this patch (a followup patch is fine too).
There is tools/testing/selftests/bpf/test_maps.c that gets broken by this
patch:
Failed map_fd_msg update sockmap -16
---
pw-bot: cr
Powered by blists - more mailing lists