From patchwork Thu Feb 12 03:05:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 439010 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 87C06140129 for ; Thu, 12 Feb 2015 14:10:33 +1100 (AEDT) Received: from localhost ([::1]:48015 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLkAh-000284-Cr for incoming@patchwork.ozlabs.org; Wed, 11 Feb 2015 22:10:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32774) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLk5p-0002A2-Qu for qemu-devel@nongnu.org; Wed, 11 Feb 2015 22:05:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YLk5l-00018v-HB for qemu-devel@nongnu.org; Wed, 11 Feb 2015 22:05:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59850) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLk5l-00018G-B0; Wed, 11 Feb 2015 22:05:25 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t1C35MH7001898 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 11 Feb 2015 22:05:22 -0500 Received: from jason-ThinkPad-T430s.nay.redhat.com (dhcp-66-71-84.eng.nay.redhat.com [10.66.71.84] (may be forged)) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t1C35IKN009733; Wed, 11 Feb 2015 22:05:19 -0500 From: Jason Wang To: qemu-devel@nongnu.org Date: Thu, 12 Feb 2015 11:05:17 +0800 Message-Id: <1423710317-15832-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Jason Wang , qemu-stable@nongnu.org, Anthony Liguori , "Michael S. Tsirkin" Subject: [Qemu-devel] [PATCH] virtio: validate the existence of handle_output before calling it X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org We don't validate the existence of handle_output which may let a buggy guest to trigger a SIGSEV easily. Fix this by validate its existence before. Cc: qemu-stable@nongnu.org Cc: Anthony Liguori Cc: Michael S. Tsirkin Signed-off-by: Jason Wang Reviewed-by: Paolo Bonzini --- hw/virtio/virtio.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index d735343..ffc22e8 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -761,6 +761,10 @@ void virtio_queue_notify_vq(VirtQueue *vq) { if (vq->vring.desc) { VirtIODevice *vdev = vq->vdev; + + if (!vq->handle_output) { + return; + } trace_virtio_queue_notify(vdev, vq - vdev->vq, vq); vq->handle_output(vdev, vq); }