76 lines
2.8 KiB
Diff
76 lines
2.8 KiB
Diff
|
From 9142072649d593acbd118e71f5d257bd9996ab36 Mon Sep 17 00:00:00 2001
|
||
|
From: eperezma <eperezma@redhat.com>
|
||
|
Date: Fri, 19 Feb 2021 08:49:50 -0300
|
||
|
Subject: [PATCH 12/54] vhost: Check for valid vdev in
|
||
|
vhost_backend_handle_iotlb_msg
|
||
|
MIME-Version: 1.0
|
||
|
Content-Type: text/plain; charset=UTF-8
|
||
|
Content-Transfer-Encoding: 8bit
|
||
|
|
||
|
RH-Author: eperezma <eperezma@redhat.com>
|
||
|
Message-id: <20210219084950.2159701-1-eperezma@redhat.com>
|
||
|
Patchwork-id: 101110
|
||
|
O-Subject: [RHEL-AV-8.4.0 qemu-kvm PATCH] vhost: Check for valid vdev in vhost_backend_handle_iotlb_msg
|
||
|
Bugzilla: 1880299
|
||
|
RH-Acked-by: Peter Xu <peterx@redhat.com>
|
||
|
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
|
||
|
RH-Acked-by: Xiao Wang <jasowang@redhat.com>
|
||
|
|
||
|
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1880299
|
||
|
BRANCH: rhel-av-8.4.0
|
||
|
UPSTREAM: Merged
|
||
|
BREW: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=35031170
|
||
|
|
||
|
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>
|
||
|
(cherry picked from commit 4d1ccc17f40f73313e13c84914f70ec3d40ac738)
|
||
|
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
|
||
|
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@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,
|
||
|
--
|
||
|
2.27.0
|
||
|
|