From nobody Mon Feb 9 23:01:03 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529374243647518.8288588098858; Mon, 18 Jun 2018 19:10:43 -0700 (PDT) Received: from localhost ([::1]:38512 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV66U-0003QY-RJ for importer@patchew.org; Mon, 18 Jun 2018 22:10:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44765) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5gw-0000P0-NR for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5gv-0007oS-Oj for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:18 -0400 Received: from mail-ot0-x244.google.com ([2607:f8b0:4003:c0f::244]:46074) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5gv-0007oA-JU; Mon, 18 Jun 2018 21:44:17 -0400 Received: by mail-ot0-x244.google.com with SMTP id a5-v6so20748240otf.12; Mon, 18 Jun 2018 18:44:17 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id t7-v6sm7580557oth.12.2018.06.18.18.44.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:44:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=5akm9SE4DeR5ga9eSIpkTz5wyTY6TDdn5ScKcOhfyqE=; b=Jt2cJrlgWsMiAu2P8UVNB4KFle4aW/SH6G3GoVOHpzukY4jEWl307HtJXBz9SkXFMF S6o7/+FKAY8DzuE8Kq3gm0zqdaAWE93wxk24Hp0Y13zwwkOFB1fz6QrMqtfLTC5fFsrX dlOPCGChocLxmvauWT7kO78TqoZxAXW2Y689hXJmTE/89QXM5LjtjexaRfmV25DothTs Iz69Dl5F+Q1HUnZWfI6MeI8wL/0933njBiSUNAL+cnzOLrmix8H/XdkpdCw1XJpVxyix I/7XUdatVIgJzTlxp+HLE3Y9juASuquNvYtFxlNKlRqYq78wG8MLxanoInqji3YBOMM5 8mJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=5akm9SE4DeR5ga9eSIpkTz5wyTY6TDdn5ScKcOhfyqE=; b=eF5zi3IyGbdNlX4Tjyt4IOmyLrE0HNqmOZGw4QBi4vFjW1PlbuvX9nxUmay05C0Mew uKZljlPkbWWH9eO57FmF1GrvZtmHpzY3mDgvYOzbDFMN8EmKnbuuAkZzO1g6oyGCRShk B8DF631ElVBFYYw4pPNEUCkiJZpqHwPGuKPckOtxCtQo8gbEa8uFgE0AUt/KS8rDv65v QZ9xt4eTr3eFVoqV174FkhDaIiH+kX4ZAhAooAuNGAPfKXgEXDv3RLy4FcCYNTSroDQG 70+NzHUtIWyWS09ixTRj/gBgEBWN8cp0I1gol4F1Lgggls1rmSHMNzoS3o0XUivgg2/j IvaA== X-Gm-Message-State: APt69E1rYzep85nqDWndx8ga7Q3+ofj1HnVaaqvZeb0hHq4h2Dq9n0xF YjQGMDbYjOT0hwqCnwxIfNtlZ4gG X-Google-Smtp-Source: ADUXVKKrBXDnxLpDN3OcXoQPuSx+x4cPcGBxDTzS5Lg4zsCh+qpgnaLIEpLagK2+oZEQYa8eqzNFWA== X-Received: by 2002:a9d:1a0b:: with SMTP id a11-v6mr8551503ote.205.1529372656304; Mon, 18 Jun 2018 18:44:16 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:43:17 -0500 Message-Id: <20180619014319.28272-112-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c0f::244 Subject: [Qemu-devel] [PATCH 111/113] qemu-img: Fix assert when mapping unaligned raw file 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: Kevin Wolf , qemu-stable@nongnu.org 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: Eric Blake Commit a290f085 exposed a latent bug in qemu-img map introduced during the conversion of block status to be byte-based. Earlier in commit 5e344dd8, the internal interface get_block_status() switched to take byte-based parameters, but still called a sector-based block layer function; as such, rounding was added in the lone caller to obey the contract. However, commit 237d78f8 changed get_block_status() to truly be byte-based, at which point rounding to sector boundaries can result in calling bdrv_block_status() with 'bytes =3D=3D 0' (a coding error) when the boundary between data and a hole falls mid-sector (true for the past-EOF implicit hole present in POSIX files). Fix things by removing the rounding that is now no longer necessary. See also https://bugzilla.redhat.com/1589738 Fixes: 237d78f8 Reported-by: Dan Kenigsberg Reported-by: Nir Soffer Reported-by: Maor Lipchuk CC: qemu-stable@nongnu.org Signed-off-by: Eric Blake Signed-off-by: Kevin Wolf (cherry picked from commit e0b371ed5e2db079051139136fd0478728b6a58f) Signed-off-by: Michael Roth --- qemu-img.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qemu-img.c b/qemu-img.c index 86060aab71..bf9de27893 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -2826,7 +2826,7 @@ static int img_map(int argc, char **argv) int64_t n; =20 /* Probe up to 1 GiB at a time. */ - n =3D QEMU_ALIGN_DOWN(MIN(1 << 30, length - offset), BDRV_SECTOR_S= IZE); + n =3D MIN(1 << 30, length - offset); ret =3D get_block_status(bs, offset, n, &next); =20 if (ret < 0) { --=20 2.11.0