[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-stable] [PATCH V2] virtio: validate the existence of handle_ou
From: |
Fam Zheng |
Subject: |
Re: [Qemu-stable] [PATCH V2] virtio: validate the existence of handle_output before calling it |
Date: |
Fri, 13 Mar 2015 11:03:02 +0800 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Thu, 03/12 17:50, Jason Wang wrote:
> 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: address@hidden
> Cc: Michael S. Tsirkin <address@hidden>
> Signed-off-by: Jason Wang <address@hidden>
Reviewed-by: Fam Zheng <address@hidden>
> ---
> Changes from V1:
> - check the existence of both vring.desc and handle_output in the same
> line
> - describe the reproducer in the commit log
> ---
> hw/virtio/virtio.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> index 3c6e430..17c1260 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);
> }
> --
> 2.1.0
>
>