From patchwork Mon Feb 27 16:27:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 143223 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 164DDB6EE8 for ; Tue, 28 Feb 2012 03:24:39 +1100 (EST) Received: from localhost ([::1]:56294 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S23NN-0002VG-3x for incoming@patchwork.ozlabs.org; Mon, 27 Feb 2012 11:24:37 -0500 Received: from eggs.gnu.org ([208.118.235.92]:41932) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S23N8-0002Sn-Km for qemu-devel@nongnu.org; Mon, 27 Feb 2012 11:24:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S23N2-00012p-Nq for qemu-devel@nongnu.org; Mon, 27 Feb 2012 11:24:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:7538) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S23N2-00012j-Fe for qemu-devel@nongnu.org; Mon, 27 Feb 2012 11:24:16 -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 q1RGOF8t030133 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 27 Feb 2012 11:24:15 -0500 Received: from dhcp-5-188.str.redhat.com (vpn1-6-95.ams2.redhat.com [10.36.6.95]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q1RGOEYi022142; Mon, 27 Feb 2012 11:24:14 -0500 From: Kevin Wolf To: qemu-devel@nongnu.org Date: Mon, 27 Feb 2012 17:27:45 +0100 Message-Id: <1330360065-27334-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com Subject: [Qemu-devel] [PATCH] qcow2: Reject unrealistically large header extensions 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 Image files that make qemu-img info read several gigabytes into the unknown header extensions list are bad. Just fail opening the image if an extension claims to be large. Signed-off-by: Kevin Wolf Reviewed-by: Stefan Hajnoczi --- block/qcow2.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index f68f0e1..077fe05 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -108,6 +108,11 @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset, #ifdef DEBUG_EXT printf("ext.magic = 0x%x\n", ext.magic); #endif + if (ext.len > 65536) { + error_report("Header extension larger than 64k - this looks wrong"); + return -ENOTSUP; + } + switch (ext.magic) { case QCOW2_EXT_MAGIC_END: return 0;