Skip to content

Commit e8a3beb

Browse files
author
CKI KWF Bot
committed
Merge: vsock/virtio: Validate length in packet header before skb_put()
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/7459 vsock/virtio: Validate length in packet header before skb_put() JIRA: https://issues.redhat.com/browse/RHEL-114300 CVE: CVE-2025-39718 commit 0dab924 Author: Will Deacon <will@kernel.org> Date: Thu Jul 17 10:01:09 2025 +0100 sock/virtio: Validate length in packet header before skb_put() When receiving a vsock packet in the guest, only the virtqueue buffer size is validated prior to virtio_vsock_skb_rx_put(). Unfortunately, virtio_vsock_skb_rx_put() uses the length from the packet header as the length argument to skb_put(), potentially resulting in SKB overflow if the host has gone wonky. Validate the length as advertised by the packet header before calling virtio_vsock_skb_rx_put(). Cc: <stable@vger.kernel.org> Fixes: 71dc9ec ("virtio/vsock: replace virtio_vsock_pkt with sk_buff") Signed-off-by: Will Deacon <will@kernel.org> Message-Id: <20250717090116.11987-3-will@kernel.org> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> Signed-off-by: Jon Maloy <jmaloy@redhat.com> Approved-by: Stefano Garzarella <sgarzare@redhat.com> Approved-by: Vitaly Kuznetsov <vkuznets@redhat.com> Approved-by: Stefan Hajnoczi <stefanha@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: CKI GitLab Kmaint Pipeline Bot <26919896-cki-kmaint-pipeline-bot@users.noreply.gitlab.com>
2 parents 268d92c + bc7e98b commit e8a3beb

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

net/vmw_vsock/virtio_transport.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,8 +582,9 @@ static void virtio_transport_rx_work(struct work_struct *work)
582582
do {
583583
virtqueue_disable_cb(vq);
584584
for (;;) {
585+
unsigned int len, payload_len;
586+
struct virtio_vsock_hdr *hdr;
585587
struct sk_buff *skb;
586-
unsigned int len;
587588

588589
if (!virtio_transport_more_replies(vsock)) {
589590
/* Stop rx until the device processes already
@@ -600,12 +601,19 @@ static void virtio_transport_rx_work(struct work_struct *work)
600601
vsock->rx_buf_nr--;
601602

602603
/* Drop short/long packets */
603-
if (unlikely(len < sizeof(struct virtio_vsock_hdr) ||
604+
if (unlikely(len < sizeof(*hdr) ||
604605
len > virtio_vsock_skb_len(skb))) {
605606
kfree_skb(skb);
606607
continue;
607608
}
608609

610+
hdr = virtio_vsock_hdr(skb);
611+
payload_len = le32_to_cpu(hdr->len);
612+
if (unlikely(payload_len > len - sizeof(*hdr))) {
613+
kfree_skb(skb);
614+
continue;
615+
}
616+
609617
virtio_vsock_skb_rx_put(skb);
610618
virtio_transport_deliver_tap_pkt(skb);
611619
virtio_transport_recv_pkt(&virtio_transport, skb);

0 commit comments

Comments
 (0)