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: 634f1a7110 ("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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
22b683217a
commit
478a46f112
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user