Skip to content

Commit

Permalink
virtio: validate the existence of handle_output before calling it
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
jasowang authored and mstsirkin committed Mar 16, 2015
1 parent 18bf9e2 commit 9e0f5b8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion hw/virtio/virtio.c
Expand Up @@ -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);
}
Expand Down

0 comments on commit 9e0f5b8

Please sign in to comment.