From nobody Tue Feb 10 21:19:09 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1522095804090593.7926073684384; Mon, 26 Mar 2018 13:23:24 -0700 (PDT) Received: from localhost ([::1]:58981 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0YeJ-0005Wh-4Y for importer@patchew.org; Mon, 26 Mar 2018 16:23:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51855) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0Ybu-0003zl-Lq for qemu-devel@nongnu.org; Mon, 26 Mar 2018 16:20:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f0Ybt-0000Ie-Qx for qemu-devel@nongnu.org; Mon, 26 Mar 2018 16:20:54 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:33810 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f0Ybr-0000HC-Ku; Mon, 26 Mar 2018 16:20:51 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4ED0E813F73E; Mon, 26 Mar 2018 20:20:51 +0000 (UTC) Received: from localhost (ovpn-204-80.brq.redhat.com [10.40.204.80]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EB01C215CDAE; Mon, 26 Mar 2018 20:20:50 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 26 Mar 2018 22:20:39 +0200 Message-Id: <20180326202039.21070-5-mreitz@redhat.com> In-Reply-To: <20180326202039.21070-1-mreitz@redhat.com> References: <20180326202039.21070-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 26 Mar 2018 20:20:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 26 Mar 2018 20:20:51 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mreitz@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 4/4] vmdk: return ERROR when cluster sector is larger than vmdk limitation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: yuchenlin VMDK has a hard limitation of extent size, which is due to the size of grain table entry is 32 bits. It means it can only point to a grain located at offset =3D 2^32. To avoid writing the user data beyond limitation and recor= d a useless offset in grain table. We should return ERROR here. Signed-off-by: yuchenlin Message-id: 20180322133337.28024-1-yuchenlin@synology.com Reviewed-by: Fam Zheng Signed-off-by: Max Reitz --- block/vmdk.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/block/vmdk.c b/block/vmdk.c index f94c49a9c0..84f8bbe480 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -47,6 +47,8 @@ #define VMDK4_FLAG_MARKER (1 << 17) #define VMDK4_GD_AT_END 0xffffffffffffffffULL =20 +#define VMDK_EXTENT_MAX_SECTORS (1ULL << 32) + #define VMDK_GTE_ZEROED 0x1 =20 /* VMDK internal error codes */ @@ -1250,6 +1252,10 @@ static int get_cluster_offset(BlockDriverState *bs, return zeroed ? VMDK_ZEROED : VMDK_UNALLOC; } =20 + if (extent->next_cluster_sector >=3D VMDK_EXTENT_MAX_SECTORS) { + return VMDK_ERROR; + } + cluster_sector =3D extent->next_cluster_sector; extent->next_cluster_sector +=3D extent->cluster_sectors; =20 --=20 2.14.3