[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 10/16] vhost: Check for valid vdev in vhost_backend_handle_iotl
From: |
Michael S. Tsirkin |
Subject: |
[PULL v2 10/16] vhost: Check for valid vdev in vhost_backend_handle_iotlb_msg |
Date: |
Fri, 5 Feb 2021 10:03:57 -0500 |
From: Eugenio Pérez <eperezma@redhat.com>
Not checking this can lead to invalid dev->vdev member access in
vhost_device_iotlb_miss if backend issue an iotlb message in a bad
timing, either maliciously or by a bug.
Reproduced rebooting a guest with testpmd in txonly forward mode.
#0 0x0000559ffff94394 in vhost_device_iotlb_miss (
dev=dev@entry=0x55a0012f6680, iova=10245279744, write=1)
at ../hw/virtio/vhost.c:1013
#1 0x0000559ffff9ac31 in vhost_backend_handle_iotlb_msg (
imsg=0x7ffddcfd32c0, dev=0x55a0012f6680)
at ../hw/virtio/vhost-backend.c:411
#2 vhost_backend_handle_iotlb_msg (dev=dev@entry=0x55a0012f6680,
imsg=imsg@entry=0x7ffddcfd32c0)
at ../hw/virtio/vhost-backend.c:404
#3 0x0000559fffeded7b in slave_read (opaque=0x55a0012f6680)
at ../hw/virtio/vhost-user.c:1464
#4 0x000055a0000c541b in aio_dispatch_handler (
ctx=ctx@entry=0x55a0010a2120, node=0x55a0012d9e00)
at ../util/aio-posix.c:329
Fixes: 020e571b8b ("vhost: rework IOTLB messaging")
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
Message-Id: <20210129090728.831208-1-eperezma@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/virtio/vhost-backend.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c
index 222bbcc62d..31b33bde37 100644
--- a/hw/virtio/vhost-backend.c
+++ b/hw/virtio/vhost-backend.c
@@ -406,6 +406,11 @@ int vhost_backend_handle_iotlb_msg(struct vhost_dev *dev,
{
int ret = 0;
+ if (unlikely(!dev->vdev)) {
+ error_report("Unexpected IOTLB message when virtio device is stopped");
+ return -EINVAL;
+ }
+
switch (imsg->type) {
case VHOST_IOTLB_MISS:
ret = vhost_device_iotlb_miss(dev, imsg->iova,
--
MST
- [PULL v2 00/16] pc,virtio,pci: fixes, features,code removal, Michael S. Tsirkin, 2021/02/05
- [PULL v2 01/16] pci: reject too large ROMs, Michael S. Tsirkin, 2021/02/05
- [PULL v2 03/16] virtio: move 'use-disabled-flag' property to hw_compat_4_2, Michael S. Tsirkin, 2021/02/05
- [PULL v2 02/16] pci: add romsize property, Michael S. Tsirkin, 2021/02/05
- [PULL v2 04/16] virtio-mmio: fix guest kernel crash with SHM regions, Michael S. Tsirkin, 2021/02/05
- [PULL v2 05/16] virtio: Add corresponding memory_listener_unregister to unrealize, Michael S. Tsirkin, 2021/02/05
- [PULL v2 06/16] virtio-pmem: add trace events, Michael S. Tsirkin, 2021/02/05
- [PULL v2 07/16] vhost: Unbreak SMMU and virtio-iommu on dev-iotlb support, Michael S. Tsirkin, 2021/02/05
- [PULL v2 08/16] hw/i386: Remove the deprecated pc-1.x machine types, Michael S. Tsirkin, 2021/02/05
- [PULL v2 10/16] vhost: Check for valid vdev in vhost_backend_handle_iotlb_msg,
Michael S. Tsirkin <=
- [PULL v2 11/16] tests/acpi: allow updates for expected data files, Michael S. Tsirkin, 2021/02/05
- [PULL v2 12/16] acpi: Permit OEM ID and OEM table ID fields to be changed, Michael S. Tsirkin, 2021/02/05
- [PULL v2 13/16] acpi: use constants as strncpy limit, Michael S. Tsirkin, 2021/02/05
- [PULL v2 16/16] tests/acpi: disallow updates for expected data files, Michael S. Tsirkin, 2021/02/05
- [PULL v2 15/16] tests/acpi: update expected data files, Michael S. Tsirkin, 2021/02/05
- [PULL v2 14/16] tests/acpi: add OEM ID and OEM TABLE ID test, Michael S. Tsirkin, 2021/02/05
- [PULL v2 09/16] hw/virtio/virtio-balloon: Remove the "class" property, Michael S. Tsirkin, 2021/02/05
- Re: [PULL v2 00/16] pc,virtio,pci: fixes, features,code removal, Peter Maydell, 2021/02/05