Skip to content

Commit cc9fa15

Browse files
author
CKI Backport Bot
committed
vsock: prevent null-ptr-deref in vsock_*[has_data|has_space]
JIRA: https://issues.redhat.com/browse/RHEL-77211 CVE: CVE-2025-21666 commit 91751e2 Author: Stefano Garzarella <sgarzare@redhat.com> Date: Fri Jan 10 09:35:11 2025 +0100 vsock: prevent null-ptr-deref in vsock_*[has_data|has_space] Recent reports have shown how we sometimes call vsock_*_has_data() when a vsock socket has been de-assigned from a transport (see attached links), but we shouldn't. Previous commits should have solved the real problems, but we may have more in the future, so to avoid null-ptr-deref, we can return 0 (no space, no data available) but with a warning. This way the code should continue to run in a nearly consistent state and have a warning that allows us to debug future problems. Fixes: c0cfa2d ("vsock: add multi-transports support") Cc: stable@vger.kernel.org Link: https://lore.kernel.org/netdev/Z2K%2FI4nlHdfMRTZC@v4bel-B760M-AORUS-ELITE-AX/ Link: https://lore.kernel.org/netdev/5ca20d4c-1017-49c2-9516-f6f75fd331e9@rbox.co/ Link: https://lore.kernel.org/netdev/677f84a8.050a0220.25a300.01b3.GAE@google.com/ Co-developed-by: Hyunwoo Kim <v4bel@theori.io> Signed-off-by: Hyunwoo Kim <v4bel@theori.io> Co-developed-by: Wongi Lee <qwerty@theori.io> Signed-off-by: Wongi Lee <qwerty@theori.io> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> Reviewed-by: Luigi Leonardi <leonardi@redhat.com> Reviewed-by: Hyunwoo Kim <v4bel@theori.io> Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: CKI Backport Bot <cki-ci-bot+cki-gitlab-backport-bot@redhat.com>
1 parent e7bc4c4 commit cc9fa15

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

net/vmw_vsock/af_vsock.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,9 @@ EXPORT_SYMBOL_GPL(vsock_create_connected);
870870

871871
s64 vsock_stream_has_data(struct vsock_sock *vsk)
872872
{
873+
if (WARN_ON(!vsk->transport))
874+
return 0;
875+
873876
return vsk->transport->stream_has_data(vsk);
874877
}
875878
EXPORT_SYMBOL_GPL(vsock_stream_has_data);
@@ -878,6 +881,9 @@ s64 vsock_connectible_has_data(struct vsock_sock *vsk)
878881
{
879882
struct sock *sk = sk_vsock(vsk);
880883

884+
if (WARN_ON(!vsk->transport))
885+
return 0;
886+
881887
if (sk->sk_type == SOCK_SEQPACKET)
882888
return vsk->transport->seqpacket_has_data(vsk);
883889
else
@@ -887,6 +893,9 @@ EXPORT_SYMBOL_GPL(vsock_connectible_has_data);
887893

888894
s64 vsock_stream_has_space(struct vsock_sock *vsk)
889895
{
896+
if (WARN_ON(!vsk->transport))
897+
return 0;
898+
890899
return vsk->transport->stream_has_space(vsk);
891900
}
892901
EXPORT_SYMBOL_GPL(vsock_stream_has_space);

0 commit comments

Comments
 (0)