From nobody Sat Oct 25 21:46:08 2025 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; dkim=fail; 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1521725755286238.54618275894643; Thu, 22 Mar 2018 06:35:55 -0700 (PDT) Received: from localhost ([::1]:60842 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ez0Nh-0006ZS-2V for importer@patchew.org; Thu, 22 Mar 2018 09:35:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43140) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ez0MZ-00064u-Jf for qemu-devel@nongnu.org; Thu, 22 Mar 2018 09:34:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ez0MY-0006ml-Os for qemu-devel@nongnu.org; Thu, 22 Mar 2018 09:34:39 -0400 Received: from synology.com ([59.124.61.242]:51151) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ez0MR-0006de-75; Thu, 22 Mar 2018 09:34:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synology.com; s=123; t=1521725666; bh=EAKi3gl1dgOVoCb80ONZLUwYwLf1FvjEysj7OC0Lvmw=; h=From:To:Cc:Subject:Date; b=I3TZIQgVFyLwBuwhByH6thq3AFVY+PEv6HL+V0kAtLpeV/+U8s9WNtLkx9G0HqOdH thkTNGSZ21lD6zyGZlbBQg+u5di5gCzJq7XjwEd/9MJQN5WMwal9O6E4eH2lwteI4K W7U0H4aS2Ugy2sng1GVMnH5oW1Tn+cIIHZ7S3do4= To: qemu-devel@nongnu.org Date: Thu, 22 Mar 2018 21:33:37 +0800 Message-Id: <20180322133337.28024-1-yuchenlin@synology.com> X-Synology-MCP-Status: no X-Synology-Spam-Flag: no X-Synology-Spam-Status: score=0, required 5, WHITELIST_FROM_ADDRESS 0 X-Synology-Virus-Status: no X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 59.124.61.242 Subject: [Qemu-devel] [PATCH v3] 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: , From: yuchenlin--- via Qemu-devel Reply-To: yuchenlin@synology.com Cc: kwolf@redhat.com, famz@redhat.com, qemu-block@nongnu.org, yuchenlin , mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 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 --- v2->v3: - use (1ULL << 32) to clearly show the limitation of offset is 2^32. thanks 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.16.2