]> www.infradead.org Git - users/jedix/linux-maple.git/commit
virtio-pci: Fix result size returned for the admin command completion
authorIsrael Rukshin <israelr@nvidia.com>
Tue, 22 Apr 2025 10:33:45 +0000 (13:33 +0300)
committerMichael S. Tsirkin <mst@redhat.com>
Tue, 27 May 2025 14:27:53 +0000 (10:27 -0400)
commit9ef41ebf787fcbde99ac404ae473f8467641f983
treef17d999074e7c640684d935d528ac5c91461ce68
parenteec812774d307f0beee12f7129a440ad314a544a
virtio-pci: Fix result size returned for the admin command completion

The result size returned by virtio_pci_admin_dev_parts_get() is 8 bytes
larger than the actual result data size. This occurs because the
result_sg_size field of the command is filled with the result length
from virtqueue_get_buf(), which includes both the data size and an
additional 8 bytes of status.

This oversized result size causes two issues:
1. The state transferred to the destination includes 8 bytes of extra
   data at the end.
2. The allocated buffer in the kernel may be smaller than the returned
   size, leading to failures when reading beyond the allocated size.

The commit fixes this by subtracting the status size from the result of
virtqueue_get_buf().

This fix has been tested through live migrations with virtio-net,
virtio-net-transitional, and virtio-blk devices.

Fixes: 704806ca400e ("virtio: Extend the admin command to include the result size")
Signed-off-by: Israel Rukshin <israelr@nvidia.com>
Reviewed-by: Parav Pandit <parav@nvidia.com>
Reviewed-by: Max Gurtovoy <mgurtovoy@nvidia.com>
Message-Id: <1745318025-23103-1-git-send-email-israelr@nvidia.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/virtio/virtio_pci_modern.c