Received: from eggs.gnu.org ([140.186.70.92]:42275) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RbBxW-00013p-Al for qemu-devel@nongnu.org; Thu, 15 Dec 2011 09:07:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RbBxL-0004hE-Cr for qemu-devel@nongnu.org; Thu, 15 Dec 2011 09:06:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:5483) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RbBxK-0004go-Sf for qemu-devel@nongnu.org; Thu, 15 Dec 2011 09:06:43 -0500 From: Kevin Wolf Date: Thu, 15 Dec 2011 15:09:29 +0100 Message-Id: <1323958169-8333-15-git-send-email-kwolf@redhat.com> In-Reply-To: <1323958169-8333-1-git-send-email-kwolf@redhat.com> References: <1323958169-8333-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 14/14] qiov: prevent double free or use-after-free List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Paolo Bonzini qemu_iovec_destroy does not clear the QEMUIOVector fully, and the data could thus be used after free or freed again. While I do not know any example in the tree, I observed this using virtio-scsi (and SCSI scatter/gather) when canceling DMA requests. Signed-off-by: Paolo Bonzini Signed-off-by: Kevin Wolf --- cutils.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/cutils.c b/cutils.c index 6db6304..24b3fe3 100644 --- a/cutils.c +++ b/cutils.c @@ -217,7 +217,10 @@ void qemu_iovec_destroy(QEMUIOVector *qiov) { assert(qiov->nalloc != -1); + qemu_iovec_reset(qiov); g_free(qiov->iov); + qiov->nalloc = 0; + qiov->iov = NULL; } void qemu_iovec_reset(QEMUIOVector *qiov) -- 1.7.6.4