diff options
| author | Jason Wang <jasowang@redhat.com> | 2015-03-12 17:50:18 +0800 |
|---|---|---|
| committer | Michael S. Tsirkin <mst@redhat.com> | 2015-03-16 15:29:51 +0100 |
| commit | 9e0f5b8108e248b78444c9a2ec41a8309825736c (patch) | |
| tree | 9d7fc2634b52a92d6a34861b8a362c0afd05fc6f /hw/virtio/virtio.c | |
| parent | 18bf9e2f379334306530cbfd44218748eceaf67d (diff) | |
| download | focaccia-qemu-9e0f5b8108e248b78444c9a2ec41a8309825736c.tar.gz focaccia-qemu-9e0f5b8108e248b78444c9a2ec41a8309825736c.zip | |
virtio: validate the existence of handle_output before calling it
We don't validate the existence of handle_output which may let a buggy guest to trigger a SIGSEV easily. E.g: 1) write 10 to queue_sel to a virtio net device with only 1 queue 2) setup an arbitrary pfn 3) then notify queue 10 Fixing this by validating the existence of handle_output before. Cc: qemu-stable@nongnu.org Cc: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Jason Wang <jasowang@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Don Koch <dkoch@verizon.com> Reviewed-by: Fam Zheng <famz@redhat.com>
Diffstat (limited to 'hw/virtio/virtio.c')
| -rw-r--r-- | hw/virtio/virtio.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 3c6e430048..17c1260c0d 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -759,8 +759,9 @@ void virtio_queue_set_align(VirtIODevice *vdev, int n, int align) void virtio_queue_notify_vq(VirtQueue *vq) { - if (vq->vring.desc) { + if (vq->vring.desc && vq->handle_output) { VirtIODevice *vdev = vq->vdev; + trace_virtio_queue_notify(vdev, vq - vdev->vq, vq); vq->handle_output(vdev, vq); } |