From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45499) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YYDBO-00028P-V6 for qemu-devel@nongnu.org; Wed, 18 Mar 2015 08:34:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YYDBK-0001yp-Ha for qemu-devel@nongnu.org; Wed, 18 Mar 2015 08:34:46 -0400 Date: Wed, 18 Mar 2015 13:34:35 +0100 From: "Michael S. Tsirkin" Message-ID: <1426682025-20844-2-git-send-email-mst@redhat.com> References: <1426682025-20844-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1426682025-20844-1-git-send-email-mst@redhat.com> Subject: [Qemu-devel] [PULL 1/8] virtio: validate the existence of handle_output before calling it List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Jason Wang , Fam Zheng , qemu-stable@nongnu.org, Don Koch From: Jason Wang 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 Signed-off-by: Jason Wang Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Don Koch Reviewed-by: Fam Zheng --- 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); } -- MST