vsock/bpf: Warn on socket without transport

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>
This commit is contained in:
Michal Luczaj 2025-02-13 12:58:50 +01:00 committed by Paolo Abeni
parent 8fb5bb169d
commit 857ae05549
2 changed files with 4 additions and 1 deletions

View File

@ -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);
}

View File

@ -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;
}