Skip to content

Commit d1e7f16

Browse files
committed
Merge: CVE-2025-21666: vsock: prevent null-ptr-deref in vsock_*has_data|has_space]
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/6315 JIRA: https://issues.redhat.com/browse/RHEL-77211 CVE: CVE-2025-21666 ``` 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> (cherry picked from commit 91751e2) ``` Signed-off-by: CKI Backport Bot <cki-ci-bot+cki-gitlab-backport-bot@redhat.com> --- <small>Created 2025-01-31 18:32 UTC by backporter - [KWF FAQ](https://red.ht/kernel_workflow_doc) - [Slack #team-kernel-workflow](https://redhat-internal.slack.com/archives/C04LRUPMJQ5) - [Source](https://gitlab.com/cki-project/kernel-workflow/-/blob/main/webhook/utils/backporter.py) - [Documentation](https://gitlab.com/cki-project/kernel-workflow/-/blob/main/docs/README.backporter.md) - [Report an issue](https://gitlab.com/cki-project/kernel-workflow/-/issues/new?issue%5Btitle%5D=backporter%20webhook%20issue)</small> Approved-by: Jon Maloy <jmaloy@redhat.com> Approved-by: Stefano Garzarella <sgarzare@redhat.com> Approved-by: Stefan Hajnoczi <stefanha@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Patrick Talbert <ptalbert@redhat.com>
2 parents a6c3766 + cc9fa15 commit d1e7f16

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)