[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] virtio: skip guest index check on device load
From: |
Felipe Franciosi |
Subject: |
[PATCH] virtio: skip guest index check on device load |
Date: |
Mon, 26 Oct 2020 15:13:32 +0000 (UTC) |
QEMU must be careful when loading device state off migration streams to
prevent a malicious source from exploiting the emulator. Overdoing these
checks has the side effect of allowing a guest to "pin itself" in cloud
environments by messing with state which is entirely in its control.
Similarly to what f3081539 achieved in usb_device_post_load(), this
commit removes such a check from virtio_load(). Worth noting, the result
of a load without this check is the same as if a guest enables a VQ with
invalid indexes to begin with. That is, the virtual device is set in a
broken state (by the datapath handler) and must be reset.
Signed-off-by: Felipe Franciosi <felipe@nutanix.com>
---
hw/virtio/virtio.c | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 6f8f865aff..0561bdb857 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -3136,8 +3136,6 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int
version_id)
RCU_READ_LOCK_GUARD();
for (i = 0; i < num; i++) {
if (vdev->vq[i].vring.desc) {
- uint16_t nheads;
-
/*
* VIRTIO-1 devices migrate desc, used, and avail ring addresses so
* only the region cache needs to be set up. Legacy devices need
@@ -3157,16 +3155,6 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int
version_id)
continue;
}
- nheads = vring_avail_idx(&vdev->vq[i]) -
vdev->vq[i].last_avail_idx;
- /* Check it isn't doing strange things with descriptor numbers. */
- if (nheads > vdev->vq[i].vring.num) {
- error_report("VQ %d size 0x%x Guest index 0x%x "
- "inconsistent with Host index 0x%x: delta 0x%x",
- i, vdev->vq[i].vring.num,
- vring_avail_idx(&vdev->vq[i]),
- vdev->vq[i].last_avail_idx, nheads);
- return -1;
- }
vdev->vq[i].used_idx = vring_used_idx(&vdev->vq[i]);
vdev->vq[i].shadow_avail_idx = vring_avail_idx(&vdev->vq[i]);
--
2.18.4
- [PATCH] virtio: skip guest index check on device load,
Felipe Franciosi <=
- Re: [PATCH] virtio: skip guest index check on device load, Stefan Hajnoczi, 2020/10/27
- Re: [PATCH] virtio: skip guest index check on device load, Michael S. Tsirkin, 2020/10/27
- Re: [PATCH] virtio: skip guest index check on device load, Felipe Franciosi, 2020/10/27
- Re: [PATCH] virtio: skip guest index check on device load, Michael S. Tsirkin, 2020/10/27
- Re: [PATCH] virtio: skip guest index check on device load, Felipe Franciosi, 2020/10/27
- Re: [PATCH] virtio: skip guest index check on device load, Michael S. Tsirkin, 2020/10/27
- Re: [PATCH] virtio: skip guest index check on device load, Stefan Hajnoczi, 2020/10/28
- Re: [PATCH] virtio: skip guest index check on device load, Michael S. Tsirkin, 2020/10/28
- Re: [PATCH] virtio: skip guest index check on device load, Stefan Hajnoczi, 2020/10/28