From patchwork Wed Dec 2 16:20:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 551447 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 B843614031B for ; Thu, 3 Dec 2015 03:21:36 +1100 (AEDT) Received: from localhost ([::1]:59094 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4A9u-0002ZC-OH for incoming@patchwork.ozlabs.org; Wed, 02 Dec 2015 11:21:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4A9W-0001x5-Nt for qemu-devel@nongnu.org; Wed, 02 Dec 2015 11:21:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a4A9V-0006ze-VS for qemu-devel@nongnu.org; Wed, 02 Dec 2015 11:21:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52139) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4A9S-0006yL-1a; Wed, 02 Dec 2015 11:21:06 -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 (Postfix) with ESMTPS id 9A5D8C0CC63B; Wed, 2 Dec 2015 16:21:05 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-47.ams2.redhat.com [10.36.116.47]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tB2GL1Zh028954; Wed, 2 Dec 2015 11:21:04 -0500 From: Kevin Wolf To: qemu-block@nongnu.org Date: Wed, 2 Dec 2015 17:20:59 +0100 Message-Id: <1449073260-12483-2-git-send-email-kwolf@redhat.com> In-Reply-To: <1449073260-12483-1-git-send-email-kwolf@redhat.com> References: <1449073260-12483-1-git-send-email-kwolf@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: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PULL 1/2] qcow2: Fix potential qemu-img check crash on 32 bit hosts 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 This crash was caught with qemu-iotests test case 138. Commit b6d36de already fixed a few 32 bit truncation bugs that could cause qemu-img check to allocate too little memory and consequently it would segfault. On 32 bit hosts, there is one more place that needs to be fixed because size_t was involved in the calculation and is a 32 bit type there. Cc: qemu-stable@nongnu.org Reported-by: Michael S. Tsirkin Signed-off-by: Kevin Wolf Tested-by: Michael S. Tsirkin --- block/qcow2-refcount.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 6e0e5bd..820f412 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1244,7 +1244,7 @@ fail: /* refcount checking functions */ -static size_t refcount_array_byte_size(BDRVQcow2State *s, uint64_t entries) +static uint64_t refcount_array_byte_size(BDRVQcow2State *s, uint64_t entries) { /* This assertion holds because there is no way we can address more than * 2^(64 - 9) clusters at once (with cluster size 512 = 2^9, and because