diff options
| author | Michal Luczaj <mhal@rbox.co> | 2025-02-13 12:58:50 +0100 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-02-27 04:30:17 -0800 |
| commit | 478a46f1122f0830392bef2a46a8d91d8abc354e (patch) | |
| tree | 30e0fa216f2809c08fd5c6a57aad953e7a4a0410 | |
| parent | 22b683217ad2112791a708693cb236507abd637a (diff) | |
| download | linux-478a46f1122f0830392bef2a46a8d91d8abc354e.tar.gz linux-478a46f1122f0830392bef2a46a8d91d8abc354e.tar.bz2 linux-478a46f1122f0830392bef2a46a8d91d8abc354e.zip | |
vsock/bpf: Warn on socket without transport
[ Upstream commit 857ae05549ee2542317e7084ecaa5f8536634dd9 ]
In the spirit of commit 91751e248256 ("vsock: prevent null-ptr-deref in
vsock_*[has_data|has_space]"), armorize the "impossible" cases with a
warning.
Fixes: 634f1a7110b4 ("vsock: support sockmap")
Signed-off-by: Michal Luczaj <mhal@rbox.co>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
| -rw-r--r-- | net/vmw_vsock/af_vsock.c | 3 | ||||
| -rw-r--r-- | net/vmw_vsock/vsock_bpf.c | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c index 37299a7ca187..eb6ea26b390e 100644 --- a/net/vmw_vsock/af_vsock.c +++ b/net/vmw_vsock/af_vsock.c @@ -1189,6 +1189,9 @@ static int vsock_read_skb(struct sock *sk, skb_read_actor_t read_actor) { struct vsock_sock *vsk = vsock_sk(sk); + if (WARN_ON_ONCE(!vsk->transport)) + return -ENODEV; + return vsk->transport->read_skb(vsk, read_actor); } diff --git a/net/vmw_vsock/vsock_bpf.c b/net/vmw_vsock/vsock_bpf.c index f201d9eca1df..07b96d56f3a5 100644 --- a/net/vmw_vsock/vsock_bpf.c +++ b/net/vmw_vsock/vsock_bpf.c @@ -87,7 +87,7 @@ static int vsock_bpf_recvmsg(struct sock *sk, struct msghdr *msg, lock_sock(sk); vsk = vsock_sk(sk); - if (!vsk->transport) { + if (WARN_ON_ONCE(!vsk->transport)) { copied = -ENODEV; goto out; } |
