From nobody Mon Feb 9 02:13:55 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; 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; dmarc=fail(p=none dis=none) header.from=oracle.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1535739748714775.5850226761327; Fri, 31 Aug 2018 11:22:28 -0700 (PDT) Received: from localhost ([::1]:56135 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvo3t-0007Sd-Qn for importer@patchew.org; Fri, 31 Aug 2018 14:22:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50118) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvnwK-0007J4-Le for qemu-devel@nongnu.org; Fri, 31 Aug 2018 14:14:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fvnwH-0005wC-Un for qemu-devel@nongnu.org; Fri, 31 Aug 2018 14:14:36 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:40822) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fvnwH-0005vo-MG for qemu-devel@nongnu.org; Fri, 31 Aug 2018 14:14:33 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w7VIEW8V049799 for ; Fri, 31 Aug 2018 18:14:32 GMT Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2120.oracle.com with ESMTP id 2m2yrqvs6t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 31 Aug 2018 18:14:32 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w7VIEWiV026035 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 31 Aug 2018 18:14:32 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w7VIEW3D023713 for ; Fri, 31 Aug 2018 18:14:32 GMT Received: from ol7.nl.oracle.com (/10.175.61.138) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 31 Aug 2018 11:14:31 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=R4G6udPkyEsTbPJ+U+A8Ix4+gdtgvAduxrM6UId9wr4=; b=e1P0nfKrA7teWvap2pKNixIDwiqNIE2kuI+77Ls5beiOwMEZubJgZbU1LjDV6Xw9CZrs 6JYGgkIKeFXi+UcGrXYwUHaQYY7Wv6twYAjQGcU5nJytCShVivSu6S8QSUTCut+pAj5+ Rvci8tsPyvKZaagPcAa1TYf7g8qrWGAvRy4XnFct+h1R0QJV+2trfuxShqymzmaCdV3+ y3prAwUKUvXg+V8ypNrYVqywEabbAV+1d5pHpWSY4JdZE7QvGXL+zcVYtEIWg6+jf6/d IdI0+sHgQ81k6Sxkbbg3FLDhHodN7ZT/Oa0vOFMscOksJ3hJylJsa+bL4UAvf/Tnsv2K 0Q== From: Liam Merwick To: qemu-devel@nongnu.org Date: Fri, 31 Aug 2018 19:16:12 +0100 Message-Id: <1535739372-24454-9-git-send-email-Liam.Merwick@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1535739372-24454-1-git-send-email-Liam.Merwick@oracle.com> References: <1535739372-24454-1-git-send-email-Liam.Merwick@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9001 signatures=668708 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=820 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1808310183 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [PATCH v3 8/8] qcow2: Read outside array bounds in qcow2_pre_write_overlap_check() 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The commit for 0e4e4318eaa5 increments QCOW2_OL_MAX_BITNR but does not add an array entry for QCOW2_OL_BITMAP_DIRECTORY_BITNR to metadata_ol_names= []. As a result, an array dereference of metadata_ol_names[8] in qcow2_pre_write_overlap_check() could result in a read outside of the array= bounds. Fixes: 0e4e4318eaa5 ('qcow2: add overlap check for bitmap directory') Cc: Vladimir Sementsov-Ogievskiy Signed-off-by: Liam Merwick Reviewed-by: Eric Blake Reviewed-by: Max Reitz --- block/qcow2-refcount.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 3c539f02e5ec..46082aeac1d6 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -2719,15 +2719,17 @@ int qcow2_check_metadata_overlap(BlockDriverState *= bs, int ign, int64_t offset, } =20 static const char *metadata_ol_names[] =3D { - [QCOW2_OL_MAIN_HEADER_BITNR] =3D "qcow2_header", - [QCOW2_OL_ACTIVE_L1_BITNR] =3D "active L1 table", - [QCOW2_OL_ACTIVE_L2_BITNR] =3D "active L2 table", - [QCOW2_OL_REFCOUNT_TABLE_BITNR] =3D "refcount table", - [QCOW2_OL_REFCOUNT_BLOCK_BITNR] =3D "refcount block", - [QCOW2_OL_SNAPSHOT_TABLE_BITNR] =3D "snapshot table", - [QCOW2_OL_INACTIVE_L1_BITNR] =3D "inactive L1 table", - [QCOW2_OL_INACTIVE_L2_BITNR] =3D "inactive L2 table", + [QCOW2_OL_MAIN_HEADER_BITNR] =3D "qcow2_header", + [QCOW2_OL_ACTIVE_L1_BITNR] =3D "active L1 table", + [QCOW2_OL_ACTIVE_L2_BITNR] =3D "active L2 table", + [QCOW2_OL_REFCOUNT_TABLE_BITNR] =3D "refcount table", + [QCOW2_OL_REFCOUNT_BLOCK_BITNR] =3D "refcount block", + [QCOW2_OL_SNAPSHOT_TABLE_BITNR] =3D "snapshot table", + [QCOW2_OL_INACTIVE_L1_BITNR] =3D "inactive L1 table", + [QCOW2_OL_INACTIVE_L2_BITNR] =3D "inactive L2 table", + [QCOW2_OL_BITMAP_DIRECTORY_BITNR] =3D "bitmap directory", }; +QEMU_BUILD_BUG_ON(QCOW2_OL_MAX_BITNR !=3D ARRAY_SIZE(metadata_ol_names)); =20 /* * First performs a check for metadata overlaps (through --=20 1.8.3.1