Skip to content

Commit cf7d012

Browse files
mmhaljfvogel
authored andcommitted
vsock/bpf: Warn on socket without transport
[ Upstream commit 857ae05 ] In the spirit of commit 91751e2 ("vsock: prevent null-ptr-deref in vsock_*[has_data|has_space]"), armorize the "impossible" cases with a warning. Fixes: 634f1a7 ("vsock: support sockmap") Signed-off-by: Michal Luczaj <[email protected]> Reviewed-by: Stefano Garzarella <[email protected]> Signed-off-by: Paolo Abeni <[email protected]> Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit 478a46f1122f0830392bef2a46a8d91d8abc354e) Signed-off-by: Jack Vogel <[email protected]>
1 parent f54172c commit cf7d012

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

net/vmw_vsock/af_vsock.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,6 +1189,9 @@ static int vsock_read_skb(struct sock *sk, skb_read_actor_t read_actor)
11891189
{
11901190
struct vsock_sock *vsk = vsock_sk(sk);
11911191

1192+
if (WARN_ON_ONCE(!vsk->transport))
1193+
return -ENODEV;
1194+
11921195
return vsk->transport->read_skb(vsk, read_actor);
11931196
}
11941197

net/vmw_vsock/vsock_bpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static int vsock_bpf_recvmsg(struct sock *sk, struct msghdr *msg,
8787
lock_sock(sk);
8888
vsk = vsock_sk(sk);
8989

90-
if (!vsk->transport) {
90+
if (WARN_ON_ONCE(!vsk->transport)) {
9191
copied = -ENODEV;
9292
goto out;
9393
}

0 commit comments

Comments
 (0)