Skip to content

Commit b206d6d

Browse files
vsock/virtio: Validate length in packet header before skb_put()
jira VULN-136554 cve CVE-2025-39718 commit-author Will Deacon <will@kernel.org> commit 0dab924 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> (cherry picked from commit 0dab924) Signed-off-by: Shreeya Patel <spatel@ciq.com>
1 parent 0eb801e commit b206d6d

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
@@ -581,8 +581,9 @@ static void virtio_transport_rx_work(struct work_struct *work)
581581
do {
582582
virtqueue_disable_cb(vq);
583583
for (;;) {
584+
unsigned int len, payload_len;
585+
struct virtio_vsock_hdr *hdr;
584586
struct sk_buff *skb;
585-
unsigned int len;
586587

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

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

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

0 commit comments

Comments
 (0)