Received: from eggs.gnu.org ([2001:4830:134:3::10]:48951) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YMp1B-00058S-LC for qemu-devel@nongnu.org; Sat, 14 Feb 2015 21:33:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YMp16-0008BG-T8 for qemu-devel@nongnu.org; Sat, 14 Feb 2015 21:33:09 -0500 Date: Sun, 15 Feb 2015 02:40:55 +0008 From: Jason Wang Message-Id: <1423967575.10674.0@smtp.corp.redhat.com> In-Reply-To: <20150213151827.1ab64371b8f342c7e806c7d1@verizon.com> References: <1423710317-15832-1-git-send-email-jasowang@redhat.com> <20150213151827.1ab64371b8f342c7e806c7d1@verizon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Subject: Re: [Qemu-devel] [PATCH] virtio: validate the existence of handle_output before calling it List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Don Koch Cc: "Michael S. Tsirkin" , qemu-devel@nongnu.org, Anthony Liguori , qemu-stable@nongnu.org On Sat, Feb 14, 2015 at 4:18 AM, Don Koch wrote: > On Thu, 12 Feb 2015 11:05:17 +0800 > Jason Wang wrote: > >> 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 >> --- >> 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; >> + } > > Maybe better to just change line 762 to: > if (vq->vring.desc && vq->handle_output) { > > -d Yes, better. > > >> trace_virtio_queue_notify(vdev, vq - vdev->vq, vq); >> vq->handle_output(vdev, vq); >> } >> -- >> 1.9.1 >> >>