From nobody Mon Nov 23 04:26:29 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794935997; cv=none; d=zohomail.com; s=zohoarc; b=AtiAqBtfhWO5fI91OSNd86bHhJ2phYEWFP+aY7a8mkLTl55QFExi4u1T9A8RtDHEelKM63tVITdGyHi7QuOy8VJMU3zrWKDVABIbLbN/rokB/WzlJN2Skdz/x5FTqKbHr6MIAGBLi2FBj0Gal5XdnE3Hr4SuP5yS42Revb8dZO4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794935997; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=oiebR+41tfkDis4dKbv6PVhs3ti6+XQM//Yxopo4Kng=; b=Qu+O3j16pDgqvpzGjLKdKG+ji4ikCoUxXEbN9O+yrK4t2vyytsOcZJR23bq2HnsbLYZUop9CBUitryBhe6eei6MiOe7wuRMjML98uI/kVqddzy03YyrnIQePZInQNnoqT3tSmwIcH+XamEFcSLDqzL0XCNBpShXkiEu7HYrejRk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794935997401912.3620976526266; Tue, 17 Nov 2026 09:19:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTMp3-0006XP-Bc; Tue, 17 Nov 2026 12:18:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTMou-0006VZ-QX for qemu-devel@nongnu.org; Tue, 17 Nov 2026 12:18:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTMot-0006Xu-C7 for qemu-devel@nongnu.org; Tue, 17 Nov 2026 12:18:12 -0500 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-396-oa0Rdg12MhaovJ4GD_Hhuw-1; Tue, 17 Nov 2026 12:18:07 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 16A73180059B; Tue, 17 Nov 2026 17:18:06 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.44.32.7]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8512C195B3C6; Tue, 17 Nov 2026 17:18:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794935890; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oiebR+41tfkDis4dKbv6PVhs3ti6+XQM//Yxopo4Kng=; b=BhbDXLtJ5f8+QS6/28QnC7kP7FmGw7RpIJyYc3bFcH1c9m5mbzkEC4gXe02GQnCjh/en9q 54qSOHIfDbCliL4FvDZfThDtZL0ItyZbnWzoOb5xLVuoxbuMZ+IT3jSKb6maCihE2KSgln rY3+3+gcxH+fUuZqQq8NMLVcU+/69/U= X-MC-Unique: oa0Rdg12MhaovJ4GD_Hhuw-1 X-Mimecast-MFC-AGG-ID: oa0Rdg12MhaovJ4GD_Hhuw_1794935886 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 1/8] block/bochs: validate bitmap size and compute extent_blocks after validation Date: Tue, 17 Nov 2026 18:17:51 +0100 Message-ID: <20261117171758.237462-2-kwolf@redhat.com> In-Reply-To: <20261117171758.237462-1-kwolf@redhat.com> References: <20261117171758.237462-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1794935998382158500 Content-Type: text/plain; charset="utf-8" From: malike bochs_open() computes bitmap_blocks using the formula "1 + (le32_to_cpu(bochs.bitmap) - 1) / 512". le32_to_cpu() returns uint32_t, so when bochs.bitmap is zero the subtraction wraps to UINT32_MAX (0xFFFFFFFF) in unsigned arithmetic, yielding bitmap_blocks =3D 8388608 instead of 1. The bitmap field is read directly from the on-disk image header and was never validated. The overflowed bitmap_blocks propagates into seek_to_sector()'s bitmap_offset calculation, causing reads to target wrong offsets and return I/O errors or incorrect data. Add an explicit zero check for bochs.bitmap before the formula. Also move the extent_blocks calculation to after the existing extent_size validation. The same "1 + (x - 1) / 512" pattern applies to extent, but extent=3D=3D0 is already caught by the "extent_size < BDRV_SECTOR_SIZE" check; the calculation is moved after that check for clarity and robustness, and uses the already-validated s->extent_size instead of re-reading the header field. Cc: qemu-stable@nongnu.org Fixes: a8753c3466dc ("Bochs disk image support") Signed-off-by: malike Message-ID: <20261014033419.236057-1-malike@kylinos.cn> Signed-off-by: Kevin Wolf --- block/bochs.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/block/bochs.c b/block/bochs.c index bfda88017d9..7a8091d47d9 100644 --- a/block/bochs.c +++ b/block/bochs.c @@ -167,8 +167,13 @@ static int bochs_open(BlockDriverState *bs, QDict *opt= ions, int flags, =20 s->data_offset =3D le32_to_cpu(bochs.header) + (s->catalog_size * 4); =20 + if (le32_to_cpu(bochs.bitmap) =3D=3D 0) { + error_setg(errp, "Bitmap size must not be zero"); + ret =3D -EINVAL; + goto fail; + } + s->bitmap_blocks =3D 1 + (le32_to_cpu(bochs.bitmap) - 1) / 512; - s->extent_blocks =3D 1 + (le32_to_cpu(bochs.extent) - 1) / 512; =20 s->extent_size =3D le32_to_cpu(bochs.extent); if (s->extent_size < BDRV_SECTOR_SIZE) { @@ -188,6 +193,8 @@ static int bochs_open(BlockDriverState *bs, QDict *opti= ons, int flags, goto fail; } =20 + s->extent_blocks =3D 1 + (s->extent_size - 1) / 512; + if (s->catalog_size < DIV_ROUND_UP(bs->total_sectors, s->extent_size / BDRV_SECTOR_SIZE)) { --=20 2.56.1 From nobody Mon Nov 23 04:26:29 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794936001; cv=none; d=zohomail.com; s=zohoarc; b=dkthXiqrBIvyJTotFZyew7brErfFv1YwZ5fAFrq7JfeK9iLS9EbtWyyuk0MgvKUUzjE9f9cx8m3iL7KgL4N7m8ZWGtgmjl5NR51OYzkbQ4eS/woA2One7Ir8io10H9+1BthY4rJFICMFegf0UqcslSiqEWHmILzHfEEzPyZRCpI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794936001; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=H7n4HMLDs/xYbDygQnwx2QyXZ9lldiwCKEx7gLp8PnY=; b=OAZCa5ytgqPA4sg46K5xmOzdQ6F5fXcswSx6HGPT+KK+7mn95zijx5WTHaV09whFvD4/b32JeYCwGNhpHP10xpU1JwiEQlEi4jN0WieBqoaCn4d22a0rckt2EDiqtRX1ipefjsM+WjL68zoUxt0emYy7yH+oYg/RNAJy9a7IvYw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794936001304689.3701101584909; Tue, 17 Nov 2026 09:20:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTMp3-0006XQ-BQ; Tue, 17 Nov 2026 12:18:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTMoy-0006Vn-Uk for qemu-devel@nongnu.org; Tue, 17 Nov 2026 12:18:18 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTMow-0006YT-Ub for qemu-devel@nongnu.org; Tue, 17 Nov 2026 12:18:16 -0500 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-180-zyU_9jPnMAuBnQ8AdYCVkQ-1; Tue, 17 Nov 2026 12:18:09 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0098C1955DBF; Tue, 17 Nov 2026 17:18:08 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.44.32.7]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7C31B195B3C5; Tue, 17 Nov 2026 17:18:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794935892; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=H7n4HMLDs/xYbDygQnwx2QyXZ9lldiwCKEx7gLp8PnY=; b=byfeQ4HAcGovDqgKa0mufl7d1/RyTgat/pTZ+6t713S5wDt0Q8hgcP0ijLdyq7xKfHwiDI xTr6Fl2D8cgCLcjBGDpKFRfpPdWIEuc4BKKr41fBlExzUiopCamGdh646pTAI7iMdzZZIA 0IiHPxi4ddTK9mhe31LpinUjJmj6s0k= X-MC-Unique: zyU_9jPnMAuBnQ8AdYCVkQ-1 X-Mimecast-MFC-AGG-ID: zyU_9jPnMAuBnQ8AdYCVkQ_1794935888 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 2/8] iotests: better heuristics to find I/O tests build/source dirs Date: Tue, 17 Nov 2026 18:17:52 +0100 Message-ID: <20261117171758.237462-3-kwolf@redhat.com> In-Reply-To: <20261117171758.237462-1-kwolf@redhat.com> References: <20261117171758.237462-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1794936002341158500 From: Daniel P. Berrang=C3=A9 Currently the I/O tests cannot be run if executing directly from the source directory, even when wrapped by the 'run' script, due to inadequate heuristics to guess the directories. If using the 'run' script, meson can tell us exactly where the top level build and source directories are, so we don't need to guess. Just read MESON_BUILD_ROOT and MESON_SOURCE_ROOT env variables if present. If not using the 'run' script, we can do a bit better at guessing the path from the 'check' filename. Always resolve from sys.argv[0], even when it is not a symlink, instead of falling back to 'cwd()' which doesn't work since we stopped having in-tree builds. If invoked directly from the source tree, guess that the build root is the default 'build' name which often works. With this change the following all work: 1. From root of build dir, with run script cd build ./run tests/qemu-iotests/check 5 2. From root of build dir, without run script cd build tests/qemu-iotests/check 5 3. From I/O tests subdir of build dir, with run script cd build/tests/qemu-iotests ../../run ./check 5 4. From I/O tests subdir of build dir, without run script cd build/tests/qemu-iotests ./check 5 5. From root of source dir, with run script ./build/run tests/qemu-iotests/check 5 6. From root of source dir, without run script tests/qemu-iotests/check 5 7. From I/O tests subdir of source dir, with run script cd tests/qemu-iotests ../../build/run ./check 5 8. From I/O tests subdir of source dir, without run script cd tests/qemu-iotests ./check 5 Before this commit, items 5-8 would always fail. Items 6 and 8 will not work if using a build directory with a name other than the default 'build'. For those scenarios use one of the other 6 possible variants. Signed-off-by: Daniel P. Berrang=C3=A9 Message-ID: <20261111091133.3527549-1-berrange@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- meson.build | 1 + tests/qemu-iotests/check | 52 +++++++++++++++++++++++++++++----------- 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/meson.build b/meson.build index d7bcb581c18..9d15f2e9551 100644 --- a/meson.build +++ b/meson.build @@ -3502,6 +3502,7 @@ genh +=3D config_host_h =20 devenv =3D environment() devenv.set('MESON_BUILD_ROOT', meson.project_build_root()) +devenv.set('MESON_SOURCE_ROOT', meson.project_source_root()) devenv.set('VIRTUAL_ENV', meson.project_build_root() / 'pyvenv') devenv.prepend('PATH', meson.project_build_root() / 'pyvenv'/ 'bin') devenv.prepend('PYTHONPATH', meson.current_source_dir() / 'tests' / 'funct= ional') diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check index c8ba536970c..40baa2b4107 100755 --- a/tests/qemu-iotests/check +++ b/tests/qemu-iotests/check @@ -28,18 +28,42 @@ from findtests import TestFinder from testenv import TestEnv from testrunner import TestRunner =20 -def get_default_path(follow_link=3DFalse): - """ - Try to automagically figure out the path we are running from. - """ - # called from the build tree? - if os.path.islink(sys.argv[0]): - if follow_link: - return os.path.dirname(os.readlink(sys.argv[0])) + +def get_build_dir(): + if "MESON_BUILD_ROOT" in os.environ: + br =3D os.environ["MESON_BUILD_ROOT"] + return os.path.join(br, "tests", "qemu-iotests") + else: + if os.path.islink(sys.argv[0]): + iobr =3D os.path.dirname(sys.argv[0]) + else: + iobr =3D os.path.join(os.path.dirname(sys.argv[0]), + "..", "..", "build", "tests", "qemu-iotest= s") + if (not os.path.exists(os.path.join(iobr, "check")) or + os.path.exists(os.path.join(iobr, "testenv.py"))): + raise Exception(f"MESON_BUILD_ROOT is not set, and guessed " + "I/O tests build root {iobr} does not look " + "valid. Please use the 'run' script to invoke " + "the I/O tests") + return os.path.abspath(iobr) + + +def get_source_dir(): + if "MESON_SOURCE_ROOT" in os.environ: + sr =3D os.environ["MESON_SOURCE_ROOT"] + return os.path.join(sr, "tests", "qemu-iotests") + else: + if os.path.islink(sys.argv[0]): + iosr =3D os.path.dirname(os.readlink(sys.argv[0])) else: - return os.path.dirname(os.path.abspath(sys.argv[0])) - else: # or source tree? - return os.getcwd() + iosr =3D os.path.dirname(sys.argv[0]) + if not os.path.exists(os.path.join(iosr, "testenv.py")): + raise Exception(f"MESON_SOURCE_ROOT is not set, and guessed " + "I/O tests source root {iosr} does not look " + "valid. Please use the 'run' script to invoke " + "the I/O tests") + return os.path.abspath(iosr) + =20 def make_argparser() -> argparse.ArgumentParser: p =3D argparse.ArgumentParser( @@ -131,11 +155,11 @@ def make_argparser() -> argparse.ArgumentParser: 'middle of the process.') g_sel.add_argument('tests', metavar=3D'TEST_FILES', nargs=3D'*', help=3D'tests to run, or "--" followed by a command= ') - g_sel.add_argument('--build-dir', default=3Dget_default_path(), + g_sel.add_argument('--build-dir', default=3Dget_build_dir(), help=3D'Path to iotests build directory') g_sel.add_argument('--source-dir', - default=3Dget_default_path(follow_link=3DTrue), - help=3D'Path to iotests build directory') + default=3Dget_source_dir(), + help=3D'Path to iotests source directory') =20 return p =20 --=20 2.56.1 From nobody Mon Nov 23 04:26:29 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794936034; cv=none; d=zohomail.com; s=zohoarc; b=gBOin1p0pUglSdfPP6cSqkuJqIVa8tyo2DVruYL2Xa2e7DkCoz3krVxmZTkZ+9Wr8KKzSSOGARaLhT4AXQ+mCaaQKC8T1HLLV1frKqSVbVrSg5ccaiNpOHH/6wFaLvbdy4BiCyMUMS6/1midoAYCQL6UlnGd2rmJmzZK9dwGHh4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794936034; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1EQqrFGoobwG5LLP2mGt/QvT3gv+i/QF4QGb/pWlems=; b=WFyKTkp2swUIloehQeDO+5/vL9Ay0uDDj92vT8uoNi2QLtzbNAhgCfVZJjbbH03uKk0VS29nOXMBZpUFivy374jDVxQbks+lS9mmlcHJ5ErprcFlWe+N+Tyr+1vw62T1uS8Ehf8YPYkm57Fx5CG0hBQIK5Y1IbYJqssR8oTDdMk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794936034262255.08696825022707; Tue, 17 Nov 2026 09:20:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTMp7-0006ZC-Af; Tue, 17 Nov 2026 12:18:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTMp0-0006W0-EU for qemu-devel@nongnu.org; Tue, 17 Nov 2026 12:18:18 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTMow-0006Ye-Ul for qemu-devel@nongnu.org; Tue, 17 Nov 2026 12:18:17 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-362-At2OZPlGOgCVRe8LWc4Zww-1; Tue, 17 Nov 2026 12:18:11 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3CAA419560B6; Tue, 17 Nov 2026 17:18:10 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.44.32.7]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 641D5195B3C5; Tue, 17 Nov 2026 17:18:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794935893; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1EQqrFGoobwG5LLP2mGt/QvT3gv+i/QF4QGb/pWlems=; b=Ou4yLcBLf6jy6LFn8DTV8NykMeR10stu8bCUVrlwI0iNDySa6K31/ulVYX3ipKmLEwUrLN 0GMwmZM3h+cOUtHmIbERRPhzNunLuTJ7LR8ZZxoUyc5YMXOmyZKM2CzR1yFigNKvS9lCXL WaqLHvduuDQSXbeq6jyQuT3II9EryMs= X-MC-Unique: At2OZPlGOgCVRe8LWc4Zww-1 X-Mimecast-MFC-AGG-ID: At2OZPlGOgCVRe8LWc4Zww_1794935890 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 3/8] block/vhdx-log: Improve sanity checks to avoid OOB accesses with bad images Date: Tue, 17 Nov 2026 18:17:53 +0100 Message-ID: <20261117171758.237462-4-kwolf@redhat.com> In-Reply-To: <20261117171758.237462-1-kwolf@redhat.com> References: <20261117171758.237462-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1794936036709158500 Content-Type: text/plain; charset="utf-8" From: Thomas Huth The multiplication "hdr->descriptor_count * sizeof(VHDXLogDescriptor)" in vhdx_log_hdr_is_valid() can overflow on 32-bit systems, so this function could mark bad images as valid when the truncated result is smaller than hdr->entry_length. Switch to a division on the right hand side instead to avoid the overflow problems. The second problem is in vhdx_log_read_desc(): desc_sectors is a 32-bit value, thus the multiplication "desc_sectors * VHDX_LOG_SECTOR_SIZE" is also done with 32 bit arithmetics, and the result is used as "size_t" parameter for qemu_try_blockalign(), i.e. the parameter here is also only 32 bits on 32-bit systems. Let's add a sanity check here to avoid the overflow problem that could lead to trouble later. Cc: qemu-stable@nongnu.org Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3860 Signed-off-by: Thomas Huth Message-ID: <20261111150659.253918-1-thuth@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/vhdx-log.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/block/vhdx-log.c b/block/vhdx-log.c index 4385a2d4f62..5c20468e1e6 100644 --- a/block/vhdx-log.c +++ b/block/vhdx-log.c @@ -246,7 +246,7 @@ static bool vhdx_log_hdr_is_valid(VHDXLogEntries *log, = VHDXLogEntryHeader *hdr, goto exit; } =20 - if (hdr->descriptor_count * sizeof(VHDXLogDescriptor) > hdr->entry_len= gth) { + if (hdr->descriptor_count > hdr->entry_length / sizeof(VHDXLogDescript= or)) { goto exit; } =20 @@ -360,6 +360,10 @@ vhdx_log_read_desc(BlockDriverState *bs, BDRVVHDXState= *s, VHDXLogEntries *log, } =20 desc_sectors =3D vhdx_compute_desc_sectors(hdr.descriptor_count); + if (desc_sectors > UINT32_MAX / VHDX_LOG_SECTOR_SIZE) { + ret =3D -EINVAL; + goto exit; + } desc_entries =3D qemu_try_blockalign(bs->file->bs, desc_sectors * VHDX_LOG_SECTOR_SIZE= ); if (desc_entries =3D=3D NULL) { --=20 2.56.1 From nobody Mon Nov 23 04:26:29 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794935972; cv=none; d=zohomail.com; s=zohoarc; b=gicnE4MfnnBRVc9uaP7zP6VnW7S5tTi8yN7l5lCM4SSkS4/Vz7K3U1JGyKkAFkTtBCnqvc+eqsthI5zL9QG565h73bnI59hQvQ5xaEeniqNYcjQS5E35EimGVNYMm2tXycULYtU3sz7PTcr2OUhgSQu8a2m1C4F2NdzJ2hPyzSg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794935972; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=saELs0qUN8zavZ/+gDE1WLNTY2lbQEdwwqFdlFAYCck=; b=csZiUIEAFlCi1c3lvDKuxaig/K78ps0ld85QuHcCKNV38AEU7H4XPpDKUt1CoCXvkqCu4L6jjb9s6Vlp/fomCaG159dVRdmCGHFAyhtXqwlWRC6ZenmzmhlaqTINRirab0I/Opb9axgFhD9oLuv/g4Fa0pdr/LdDSHjmj0scDaM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794935972456816.5686766247185; Tue, 17 Nov 2026 09:19:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTMpB-0006cL-Ot; Tue, 17 Nov 2026 12:18:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTMp0-0006W1-EQ for qemu-devel@nongnu.org; Tue, 17 Nov 2026 12:18:18 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTMox-0006Yq-2V for qemu-devel@nongnu.org; Tue, 17 Nov 2026 12:18:17 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-538-RiMtc5JWNmqypsNMuwPDCg-1; Tue, 17 Nov 2026 12:18:13 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F32D119560BB; Tue, 17 Nov 2026 17:18:11 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.44.32.7]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A21A6195B3C5; Tue, 17 Nov 2026 17:18:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794935894; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=saELs0qUN8zavZ/+gDE1WLNTY2lbQEdwwqFdlFAYCck=; b=eClNJ7ngAo+KrpMjyiMxx4H9tUTL23YX5fOyqMuVcRajKqVeAk6ZnGpD8VdUV/a20aaGNp Y0GRPRBlEhdfFjYTQxLHMD1cxWyBwt9EQAoQ9gXQ1asRpyeOjbjSAoe5YhLASlIq0Pa9DA mY5JscRQaA9V9Au0uJaX+kbjtzmV7b4= X-MC-Unique: RiMtc5JWNmqypsNMuwPDCg-1 X-Mimecast-MFC-AGG-ID: RiMtc5JWNmqypsNMuwPDCg_1794935892 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 4/8] iotests: fix false positive on running-outside-venv warning Date: Tue, 17 Nov 2026 18:17:54 +0100 Message-ID: <20261117171758.237462-5-kwolf@redhat.com> In-Reply-To: <20261117171758.237462-1-kwolf@redhat.com> References: <20261117171758.237462-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1794935974217158500 Content-Type: text/plain; charset="utf-8" From: John Snow Currently, iotests checks to see if you are running with the "correct" python interpreter by checking string equivalence between your current python and the configure-time venv python. Depending on exactly *how* you launch or configure your python, however, this warning may produce false positives because it treats "python" as different from "python3" as different from e.g. "python3.12", even though they are all actually the same exact interpreter. This patch fixes this by comparing only the parent directories; we will now be happy with any interpreter so long as it is located within build/pyvenv/bin/. Note that we cannot fix this by resolving symlinks, as python venv binaries are often (but not always) just symlinks to /usr/bin/, and full resolution would produce even more false negatives. Reported-by: Peter Maydell Signed-off-by: John Snow Message-ID: <20261007183338.1899422-1-jsnow@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- tests/qemu-iotests/testenv.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/qemu-iotests/testenv.py b/tests/qemu-iotests/testenv.py index 86bcdf7cfad..53c9b5d1968 100644 --- a/tests/qemu-iotests/testenv.py +++ b/tests/qemu-iotests/testenv.py @@ -86,7 +86,7 @@ def prepare_subprocess(self, args: List[str]) -> Dict[str= , str]: with open(args[0], encoding=3D"utf-8") as f: try: if f.readline().rstrip() =3D=3D '#!/usr/bin/env python3': - args.insert(0, self.python) + args.insert(0, str(self.python)) except UnicodeDecodeError: # binary test? for future. pass =20 @@ -141,14 +141,14 @@ def init_binaries(self) -> None: PYTHON (for bash tests) QEMU_PROG, QEMU_IMG_PROG, QEMU_IO_PROG, QEMU_NBD_PROG, QSD_PR= OG """ - self.python =3D str(Path(sys.executable).absolute()) + self.python =3D Path(sys.executable).absolute() =20 # QEMU configure-time venv python executable venv_python =3D Path( os.path.join(self.build_root, "pyvenv", "bin", "python3") ).absolute() =20 - if self.python !=3D str(venv_python): + if str(self.python.parent) !=3D str(venv_python.parent): runpath =3D os.path.join(self.build_root, "run") cmd =3D ' '.join(shlex.quote(x) for x in sys.argv) print( @@ -163,7 +163,7 @@ def init_binaries(self) -> None: f"\t{runpath} {cmd}\n", file=3Dsys.stderr ) - self.python =3D str(venv_python) + self.python =3D venv_python =20 def root(*names: str) -> str: return os.path.join(self.build_root, *names) --=20 2.56.1 From nobody Mon Nov 23 04:26:29 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794935972; cv=none; d=zohomail.com; s=zohoarc; b=kwsciijRoQD6D9JFzAtifTkrN4NeyqRVjl9Phi5za2YacHE3Dr8CoZFEw8yBf62cb5AE2nGn3bCfm0xtqYCk4tmO/dUm+wh6iOhkSP1oxV3kKQTgT80AohXfe8KRcglb58EoBXp1RmX8Dw8+RwxcUKAkqCKPBZnamSn/nenxRoQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794935972; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PTpRWT2bESwLS0+s3VKD+x7p2+QjMOw7dkDSTrY+dCs=; b=VOsC8PIRxrevxwdvtX4fGIFAKy2jm025LJC3NSGTzpBbZFoGJNgoTCWFNOh8bZHgMBhVDygIlgxzmwLlp8BXiHamFPHYQ0kWu8jhYjfY5kdpK9B2eCsK+83x0Tki1Y37AjlTdkk7R5WVePMa6PTxigsbwSJSORkp/Yhgq9vzw08= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794935972784116.44963529895563; Tue, 17 Nov 2026 09:19:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTMp7-0006a4-RQ; Tue, 17 Nov 2026 12:18:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTMp3-0006Xn-IN for qemu-devel@nongnu.org; Tue, 17 Nov 2026 12:18:21 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTMp1-0006Zs-5l for qemu-devel@nongnu.org; Tue, 17 Nov 2026 12:18:20 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-600-TqLBcRjeOKiFi_BdOwIAWQ-1; Tue, 17 Nov 2026 12:18:15 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1BC12195608D; Tue, 17 Nov 2026 17:18:14 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.44.32.7]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9CA36195B3C5; Tue, 17 Nov 2026 17:18:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794935898; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PTpRWT2bESwLS0+s3VKD+x7p2+QjMOw7dkDSTrY+dCs=; b=SO6/K5Cf6lYmmgrcax4Ssw0vvrQ4Ds1MWqimogVDuj+w1CQ9owqwsjfqn1XLzZTVTCbS9F Dbi5BTLl4ivueoSqxSJ+M4oqL9FxJy34bNT/CO8ZAi+4OdZZJlEtAMy8GlAEpilUB4WFmD AwEzBRuur4zdLqAT9+DeJkkWDEAawLY= X-MC-Unique: TqLBcRjeOKiFi_BdOwIAWQ-1 X-Mimecast-MFC-AGG-ID: TqLBcRjeOKiFi_BdOwIAWQ_1794935894 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 5/8] block/vhdx: Add alignment checks for region tables Date: Tue, 17 Nov 2026 18:17:55 +0100 Message-ID: <20261117171758.237462-6-kwolf@redhat.com> In-Reply-To: <20261117171758.237462-1-kwolf@redhat.com> References: <20261117171758.237462-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1794935974193158500 Content-Type: text/plain; charset="utf-8" From: Thomas Huth According to the VHDX specification: "The FileOffset and Length fields specify the 64-bit byte offset and 32-bit byte length of the object within the file. The values must be a multiple = of 1 MB, and FileOffset must be at least 1 MB." Thus let's add a sanity check to avoid that bad things could happen later. Cc: qemu-stable@nongnu.org Buglink: https://gitlab.com/qemu-project/qemu/-/work_items/3762 Reported-by: Daniel Wade Signed-off-by: Thomas Huth Message-ID: <20261113072336.46309-1-thuth@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/vhdx.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/block/vhdx.c b/block/vhdx.c index 8013a90a1a4..e71973cf525 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -566,6 +566,16 @@ vhdx_open_region_tables(BlockDriverState *bs, BDRVVHDX= State *s) =20 vhdx_region_entry_le_import(&rt_entry); =20 + /* + * According to the VHDX spec, offset and length must be multiple + * of 1 MiB and offset must be at least 1 MiB. + */ + if (!QEMU_IS_ALIGNED(rt_entry.file_offset, MiB) || + !QEMU_IS_ALIGNED(rt_entry.length, MiB) || !rt_entry.file_offse= t) { + ret =3D -EINVAL; + goto fail; + } + /* check for region overlap between these entries, and any * other memory regions in the file */ ret =3D vhdx_region_check(s, rt_entry.file_offset, rt_entry.length= ); --=20 2.56.1 From nobody Mon Nov 23 04:26:29 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794935948; cv=none; d=zohomail.com; s=zohoarc; b=ldM2sJN2UHk/DSDzaLlccWq3jHrjWvceQhN+8kkUxICi5yUDlLPHdB8qcUhHYNJ1SRPo9IHaznQNAxzC6moFQV8XEzP9+fXdO3OW4CDMj6sGEZ7ZbRMQMzRtsS++lfGIEXFcBsyyYaDoIllnHze2JPyrpz/fT8WoiGjvIIycUoM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794935948; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ce6aUHCZ7Rx31iKQJVNhPpVlzSao3T5q4N453t3rLrE=; b=I/f5Lgo9grBC6pnvMm5OTxPYVjRKXTWi1vDuoByvF5KfB7yqfQkGfMP4aLmOMaEQ69W2llo77XN2Nq3WxlM/swRD1cKZhz9PRjyh439rj45YYev2bj7V2dfUc8UcvNySWgNuewJ7UM2cxrVgQW9BbLzlTs4SRXzutMDIkdGOc7w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794935948971877.7751944539198; Tue, 17 Nov 2026 09:19:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTMp8-0006a6-9h; Tue, 17 Nov 2026 12:18:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTMp4-0006Y5-PS for qemu-devel@nongnu.org; Tue, 17 Nov 2026 12:18:23 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTMp3-0006aL-8U for qemu-devel@nongnu.org; Tue, 17 Nov 2026 12:18:22 -0500 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-112-hA3dP4gcOrKxixHnyxqsGA-1; Tue, 17 Nov 2026 12:18:17 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 05D3C1800599; Tue, 17 Nov 2026 17:18:16 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.44.32.7]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6B507195B3C7; Tue, 17 Nov 2026 17:18:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794935901; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ce6aUHCZ7Rx31iKQJVNhPpVlzSao3T5q4N453t3rLrE=; b=FRYYy54MwHZfNuqVXZdekCLu8ZfRYbnmf9FTKOJDlAAhJS5r2e70rPYmyW7M0BL99QRc9z FZ4iegjvPO8WKcJLX+V0QL5C3ZjtcnsnM+nAjGgummObPxvc/S4GxM9aXOdheYzfmzLrgv 6oXnZIhrRkz8d3JqquTwSfe9k7bgwlI= X-MC-Unique: hA3dP4gcOrKxixHnyxqsGA-1 X-Mimecast-MFC-AGG-ID: hA3dP4gcOrKxixHnyxqsGA_1794935896 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 6/8] block: read the old child length after draining in bdrv_replace_child_bs() Date: Tue, 17 Nov 2026 18:17:56 +0100 Message-ID: <20261117171758.237462-7-kwolf@redhat.com> In-Reply-To: <20261117171758.237462-1-kwolf@redhat.com> References: <20261117171758.237462-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1794935952000158500 From: "Denis V. Lunev" bdrv_drained_begin() runs nested event loops, and old_bs can be resized from there by something other than the BlockBackend being switched: an export truncating it, or a block job completing. old_len read before the drain is then stale, and comparing it with new_len sends a notification the parent does not need or skips one it does. Read it once both nodes are drained, so that the read, the comparison and the notification see the same sizes. A resize which completes in the drain notifies the parents of old_bs, @child included, on its own. Fixes: 8b267376df87 ("block: notify the parent when a replaced child has a = different size") Suggested-by: Kevin Wolf Signed-off-by: Denis V. Lunev Cc: Kevin Wolf Cc: Hanna Reitz Cc: Eric Blake Cc: Philippe Mathieu-Daud=C3=A9 Message-ID: <20261105203752.3169635-2-den@openvz.org> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/block.c b/block.c index 006c3413406..9df1a48c06b 100644 --- a/block.c +++ b/block.c @@ -5566,11 +5566,12 @@ int bdrv_replace_child_bs(BdrvChild *child, BlockDr= iverState *new_bs, =20 GLOBAL_STATE_CODE(); =20 - old_len =3D bdrv_getlength(old_bs); - bdrv_ref(old_bs); bdrv_drained_begin(old_bs); bdrv_drained_begin(new_bs); + + old_len =3D bdrv_getlength(old_bs); + bdrv_graph_wrlock(); =20 bdrv_replace_child_tran(child, new_bs, tran); --=20 2.56.1 From nobody Mon Nov 23 04:26:29 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794935948; cv=none; d=zohomail.com; s=zohoarc; b=hdRrShc0J1aEw45O+CWGXMPV5xhenEbRukE1Fg7vq9fjnUOuU67kzbH6YDON7w6MJzMgL9rxu/XgUzV5bn3hA05FLeDkEA4LcvxXyarnUjrx4NA2/KnjMK6ROAUWEzpHAugmazhPNTsKXlCaNBBcgFQqzzGWj+7wDEhE5gYHjN0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794935948; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WcaOoBTpm7xnV3dARlnzMyGV1Kqy5XZGkQnGPk6b4qs=; b=Vv8lFFxaudM/r0HRefXR9HQ5VnoNBWL1IMsAG43Ca06JwGW+OouJDow/c9hsOhyo0GKWM5q9BhavQQdATNJ4PShNjl5pEXGtBciQJFK18l5Oim6CpoEGRDVS84U/Xw3xx7D9ZWFv0NOAUMhHoXxi5U0+d1XVu2EAUK0l2ASE/bk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794935948659681.4942722708045; Tue, 17 Nov 2026 09:19:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTMp9-0006ap-0x; Tue, 17 Nov 2026 12:18:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTMp7-0006Z0-1a for qemu-devel@nongnu.org; Tue, 17 Nov 2026 12:18:25 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTMp4-0006aZ-LV for qemu-devel@nongnu.org; Tue, 17 Nov 2026 12:18:23 -0500 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-153-kq2837fjNcmKQS_ea9_dYw-1; Tue, 17 Nov 2026 12:18:19 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BAA511955F14; Tue, 17 Nov 2026 17:18:17 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.44.32.7]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 699E8195B3C5; Tue, 17 Nov 2026 17:18:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794935902; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WcaOoBTpm7xnV3dARlnzMyGV1Kqy5XZGkQnGPk6b4qs=; b=H40U7L9Ak51x9DRqgUPjiqQDDpjXgbxAwLMd3SmCFF/E9V9wcERLqAfOttve2uGaBnbPKo 07dEFvHw14jNCd5MjcWtM1GvJI1CP/29cEa2YudCA2023f/PUbP5BabCKt2tqYKi3M1R7B UNJChkc5m8GFi1djmGv+VoNnpmbJRyI= X-MC-Unique: kq2837fjNcmKQS_ea9_dYw-1 X-Mimecast-MFC-AGG-ID: kq2837fjNcmKQS_ea9_dYw_1794935897 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 7/8] block: add bdrv_child_notify_resize() to notify a single parent Date: Tue, 17 Nov 2026 18:17:57 +0100 Message-ID: <20261117171758.237462-8-kwolf@redhat.com> In-Reply-To: <20261117171758.237462-1-kwolf@redhat.com> References: <20261117171758.237462-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: 5 X-Spam_score: 0.5 X-Spam_bar: / X-Spam_report: (0.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_SBL_CSS=3.335, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1794935951885158500 From: "Denis V. Lunev" bdrv_co_parent_cb_resize() calls the resize hook of every parent of a node. bdrv_replace_child_bs() needs to call it for one BdrvChild, and from outside a coroutine. Move the call into bdrv_co_child_notify_resize(), make the loop use it, and add a co_wrapper for callers outside a coroutine. No functional change. Suggested-by: Kevin Wolf Signed-off-by: Denis V. Lunev Cc: Kevin Wolf Cc: Hanna Reitz Cc: Eric Blake Cc: Philippe Mathieu-Daud=C3=A9 Message-ID: <20261105203752.3169635-3-den@openvz.org> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- include/block/block_int-io.h | 9 +++++++++ block/io.c | 14 +++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/include/block/block_int-io.h b/include/block/block_int-io.h index 95d0dd7a05f..3cb72fecd4f 100644 --- a/include/block/block_int-io.h +++ b/include/block/block_int-io.h @@ -197,6 +197,15 @@ void bdrv_bsc_fill(BlockDriverState *bs, int64_t offse= t, int64_t bytes); void coroutine_fn GRAPH_RDLOCK bdrv_co_parent_cb_resize(BlockDriverState *bs); =20 +/* + * Notify the parent behind @c that the size of its child changed. + */ +void coroutine_fn GRAPH_RDLOCK +bdrv_co_child_notify_resize(BdrvChild *c); + +void co_wrapper_bdrv_rdlock +bdrv_child_notify_resize(BdrvChild *c); + void co_wrapper_bdrv_rdlock bdrv_parent_cb_resize(BlockDriverState *bs); =20 diff --git a/block/io.c b/block/io.c index 0f81b7e6bb9..e4568d4d244 100644 --- a/block/io.c +++ b/block/io.c @@ -3636,6 +3636,16 @@ int coroutine_fn bdrv_co_copy_range(BdrvChild *src, = int64_t src_offset, bytes, read_flags, write_flags); } =20 +void coroutine_fn bdrv_co_child_notify_resize(BdrvChild *c) +{ + IO_CODE(); + assert_bdrv_graph_readable(); + + if (c->klass->resize) { + c->klass->resize(c); + } +} + void coroutine_fn bdrv_co_parent_cb_resize(BlockDriverState *bs) { BdrvChild *c; @@ -3644,9 +3654,7 @@ void coroutine_fn bdrv_co_parent_cb_resize(BlockDrive= rState *bs) assert_bdrv_graph_readable(); =20 QLIST_FOREACH(c, &bs->parents, next_parent) { - if (c->klass->resize) { - c->klass->resize(c); - } + bdrv_co_child_notify_resize(c); } } =20 --=20 2.56.1 From nobody Mon Nov 23 04:26:29 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1794935960; cv=none; d=zohomail.com; s=zohoarc; b=UNbXsybbIUyplOir672cj4f/5AH3ndsKsF/Oy7rBb8GeJY7nUIk3vLGAKi4l6oNvb28a6iLrRdfElPdee6sEgGnq/5H4JC1Hoj8R6wZ2L2ClWMndNQYUM6iclVBbQ3F8uz42o9yYkCV1g0HeNVQdryWpTcm68cMAUimNxJbsho4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1794935960; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=goYzro8Ll5RWFNp/oJjIQrPkpGv0L0RDI/7uWC2pE2k=; b=d47zyxRES5+HgvThI9lqB5fpJoY1S3VsFDlu2NIanZYKgqVILC9fUZTkNWu0Cbce3Yv4nvxNBtaarGeCVy3cBGD6gChFt459plL49noX2YTBphZUFQiq1+daigiE8e1hNp56lShfnJf5YAyD0a3o+47F7Z13S6j078G7RbAm1M0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1794935960045407.3452904076121; Tue, 17 Nov 2026 09:19:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xTMpB-0006bs-9q; Tue, 17 Nov 2026 12:18:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTMp9-0006at-0n for qemu-devel@nongnu.org; Tue, 17 Nov 2026 12:18:27 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xTMp7-0006bM-JB for qemu-devel@nongnu.org; Tue, 17 Nov 2026 12:18:26 -0500 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-355-ydAhOLvRNfqJZ3i6xNtUaQ-1; Tue, 17 Nov 2026 12:18:20 -0500 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7ECFA18002C5; Tue, 17 Nov 2026 17:18:19 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.44.32.7]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2C06B195B3C5; Tue, 17 Nov 2026 17:18:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1794935904; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=goYzro8Ll5RWFNp/oJjIQrPkpGv0L0RDI/7uWC2pE2k=; b=JvXToVuxVQTH1RprmjAtJ/sRjN2MDC5ST8wjq8jz8A0kdDbjjzQqovS3Gww52BBpGXYJP3 XD6r9chnB6wPvs2n0rlqyfsNIyojoEv3UTGEAxZOpbikYStXTLZ/FWKXKUb3207B6dGq4K i94zLDVi9koQ53/QB1hJ1ijiZAri37U= X-MC-Unique: ydAhOLvRNfqJZ3i6xNtUaQ-1 X-Mimecast-MFC-AGG-ID: ydAhOLvRNfqJZ3i6xNtUaQ_1794935899 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 8/8] block: notify only the replaced child in bdrv_replace_child_bs() Date: Tue, 17 Nov 2026 18:17:58 +0100 Message-ID: <20261117171758.237462-9-kwolf@redhat.com> In-Reply-To: <20261117171758.237462-1-kwolf@redhat.com> References: <20261117171758.237462-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1794935962178158500 From: "Denis V. Lunev" bdrv_replace_child_bs() compares the sizes of the old and the new node to decide whether @child has to be told, and then notifies every parent of new_bs. The other parents already had that node and its size, so they get a resize event for nothing: a scsi-hd sharing the new node reports CAPACITY DATA HAS CHANGED to its guest although the capacity is the same. Notify @child alone. bdrv_parent_cb_resize() has no user left, so drop it. Fixes: 8b267376df87 ("block: notify the parent when a replaced child has a = different size") Suggested-by: Kevin Wolf Signed-off-by: Denis V. Lunev Cc: Kevin Wolf Cc: Hanna Reitz Cc: Eric Blake Cc: Philippe Mathieu-Daud=C3=A9 Message-ID: <20261105203752.3169635-4-den@openvz.org> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- include/block/block_int-io.h | 3 --- block.c | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/include/block/block_int-io.h b/include/block/block_int-io.h index 3cb72fecd4f..6aa7b2184e9 100644 --- a/include/block/block_int-io.h +++ b/include/block/block_int-io.h @@ -206,7 +206,4 @@ bdrv_co_child_notify_resize(BdrvChild *c); void co_wrapper_bdrv_rdlock bdrv_child_notify_resize(BdrvChild *c); =20 -void co_wrapper_bdrv_rdlock -bdrv_parent_cb_resize(BlockDriverState *bs); - #endif /* BLOCK_INT_IO_H */ diff --git a/block.c b/block.c index 9df1a48c06b..c3e7059556a 100644 --- a/block.c +++ b/block.c @@ -5590,7 +5590,7 @@ int bdrv_replace_child_bs(BdrvChild *child, BlockDriv= erState *new_bs, int64_t new_len =3D bdrv_getlength(new_bs); =20 if (new_len >=3D 0 && new_len !=3D old_len) { - bdrv_parent_cb_resize(new_bs); + bdrv_child_notify_resize(child); } } =20 --=20 2.56.1