yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
34b321
From 612017cc4834cd5eabc12afc7dd6cebf890b42e5 Mon Sep 17 00:00:00 2001
34b321
From: Xiao Wang <jasowang@redhat.com>
34b321
Date: Fri, 19 Aug 2016 09:24:25 +0200
34b321
Subject: [PATCH] virtio: validate the existence of handle_output before
34b321
 calling it
34b321
34b321
RH-Author: Xiao Wang <jasowang@redhat.com>
34b321
Message-id: <1471598665-23846-1-git-send-email-jasowang@redhat.com>
34b321
Patchwork-id: 72021
34b321
O-Subject: [RHEL7.3 qemu-kvm PATCH] virtio: validate the existence of handle_output before calling it
34b321
Bugzilla: 1367040
34b321
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
34b321
RH-Acked-by: Fam Zheng <famz@redhat.com>
34b321
RH-Acked-by: Pankaj Gupta <pagupta@redhat.com>
34b321
34b321
Bugzilla: 1367040
34b321
Brew Build: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=11620539
34b321
Test status: Tested by myself.
34b321
34b321
We don't validate the existence of handle_output which may let a buggy
34b321
guest to trigger a SIGSEV easily. E.g:
34b321
34b321
1) write 10 to queue_sel to a virtio net device with only 1 queue
34b321
2) setup an arbitrary pfn
34b321
3) then notify queue 10
34b321
34b321
Fixing this by validating the existence of handle_output before.
34b321
34b321
Cc: qemu-stable@nongnu.org
34b321
Cc: Michael S. Tsirkin <mst@redhat.com>
34b321
Signed-off-by: Jason Wang <jasowang@redhat.com>
34b321
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
34b321
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
34b321
Reviewed-by: Don Koch <dkoch@verizon.com>
34b321
Reviewed-by: Fam Zheng <famz@redhat.com>
34b321
(cherry picked from commit 9e0f5b8108e248b78444c9a2ec41a8309825736c)
34b321
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
34b321
---
34b321
 hw/virtio/virtio.c | 3 ++-
34b321
 1 file changed, 2 insertions(+), 1 deletion(-)
34b321
34b321
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
34b321
index a861870..e67337b 100644
34b321
--- a/hw/virtio/virtio.c
34b321
+++ b/hw/virtio/virtio.c
34b321
@@ -692,8 +692,9 @@ int virtio_queue_get_id(VirtQueue *vq)
34b321
 
34b321
 void virtio_queue_notify_vq(VirtQueue *vq)
34b321
 {
34b321
-    if (vq->vring.desc) {
34b321
+    if (vq->vring.desc && vq->handle_output) {
34b321
         VirtIODevice *vdev = vq->vdev;
34b321
+
34b321
         trace_virtio_queue_notify(vdev, vq - vdev->vq, vq);
34b321
         vq->handle_output(vdev, vq);
34b321
     }
34b321
-- 
34b321
1.8.3.1
34b321