From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47036) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xu20l-0006FD-8W for qemu-devel@nongnu.org; Thu, 27 Nov 2014 11:33:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xu20f-0000CQ-35 for qemu-devel@nongnu.org; Thu, 27 Nov 2014 11:33:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60502) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xu20e-0000CD-Rc for qemu-devel@nongnu.org; Thu, 27 Nov 2014 11:33:37 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sARGXZ3m028566 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 27 Nov 2014 11:33:35 -0500 Date: Thu, 27 Nov 2014 18:33:33 +0200 From: "Michael S. Tsirkin" Message-ID: <1417105946-27374-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] [PATCH RFC for-2.2] virtio-blk: force 1st s/g to match header List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi We leak cpu mappings when 1st s/g is not exactly the header. As we don't set ANY_LAYOUT, we can at this point simply assert the correct length. This will have to be fixed once ANY_LAYOUT is set. Signed-off-by: Michael S. Tsirkin --- Untested: posting for early feedback. hw/block/virtio-blk.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index b19b102..1404b3f 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -381,6 +381,12 @@ void virtio_blk_handle_request(VirtIOBlockReq *req, MultiReqBuffer *mrb) exit(1); } + /* We don't advertize ANY_LAYOUT, so first s/g is exactly the header. */ + if (iov[0].iov_len != sizeof(req->out)) { + error_report("virtio-blk request outhdr too long"); + exit(1); + } + iov_discard_front(&iov, &out_num, sizeof(req->out)); if (in_num < 1 || -- MST