From: Maxime Coquelin <maxime.coquelin@redhat.com>
To: jasowang@redhat.com, mlureau@redhat.com, qemu-devel@nongnu.org,
mst@redhat.com
Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
Subject: [Qemu-devel] [PATCH 1/2] vhost: ensure vhost_ops are set before calling iotlb callback
Date: Fri, 30 Jun 2017 18:04:21 +0200 [thread overview]
Message-ID: <20170630160422.14842-2-maxime.coquelin@redhat.com> (raw)
In-Reply-To: <20170630160422.14842-1-maxime.coquelin@redhat.com>
This patch fixes a crash that happens when vhost-user iommu
support is enabled and vhost-user socket is closed.
When it happens, if an IOTLB invalidation notification is sent
by the IOMMU, vhost_ops's NULL pointer is dereferenced.
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
hw/virtio/vhost-backend.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c
index 4e31de1..cb055e8 100644
--- a/hw/virtio/vhost-backend.c
+++ b/hw/virtio/vhost-backend.c
@@ -309,7 +309,10 @@ int vhost_backend_update_device_iotlb(struct vhost_dev *dev,
return -EINVAL;
}
- return dev->vhost_ops->vhost_send_device_iotlb_msg(dev, &imsg);
+ if (dev->vhost_ops && dev->vhost_ops->vhost_send_device_iotlb_msg)
+ return dev->vhost_ops->vhost_send_device_iotlb_msg(dev, &imsg);
+
+ return -ENODEV;
}
int vhost_backend_invalidate_device_iotlb(struct vhost_dev *dev,
@@ -321,7 +324,10 @@ int vhost_backend_invalidate_device_iotlb(struct vhost_dev *dev,
imsg.size = len;
imsg.type = VHOST_IOTLB_INVALIDATE;
- return dev->vhost_ops->vhost_send_device_iotlb_msg(dev, &imsg);
+ if (dev->vhost_ops && dev->vhost_ops->vhost_send_device_iotlb_msg)
+ return dev->vhost_ops->vhost_send_device_iotlb_msg(dev, &imsg);
+
+ return -ENODEV;
}
int vhost_backend_handle_iotlb_msg(struct vhost_dev *dev,
--
2.9.4
next prev parent reply other threads:[~2017-06-30 16:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-30 16:04 [Qemu-devel] [PATCH 0/2] vhost-user: fix crashes on disconnect when iommu is on Maxime Coquelin
2017-06-30 16:04 ` Maxime Coquelin [this message]
2017-06-30 16:33 ` [Qemu-devel] [PATCH 1/2] vhost: ensure vhost_ops are set before calling iotlb callback Marc-André Lureau
2017-06-30 16:04 ` [Qemu-devel] [PATCH 2/2] vhost-user: unregister slave req handler at cleanup time Maxime Coquelin
2017-06-30 16:23 ` Marc-André Lureau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170630160422.14842-2-maxime.coquelin@redhat.com \
--to=maxime.coquelin@redhat.com \
--cc=jasowang@redhat.com \
--cc=mlureau@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).