* [Devel] [PATCH hci-8.1] drivers/md/dm-qcow2: set header_length to 72 for v2 images
@ 2026-11-16 10:05 Alexander Ivanov
2026-11-16 10:08 ` no-reply
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Alexander Ivanov @ 2026-11-16 10:05 UTC (permalink / raw)
To: andrey.zhadchenko; +Cc: devel
qcow2_check_convert_hdr() returns for a v2 image before it fills in
hdr->header_length, so the field stays 0 from kzalloc().
qcow2_parse_header() uses header_length as the start of header
extensions and so parses them from offset 0 of the image, i.e. from
the header itself, instead of from offset 72 right after the v2 header.
Set header_length to the size of the v2 header before the version
check, as qemu does. v3 images overwrite it from the raw header.
https://virtuozzo.atlassian.net/browse/VSTOR-152394
Feature: dm-qcow2: block device over QCOW2 files driver
Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
---
drivers/md/dm-qcow2-target.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/md/dm-qcow2-target.c b/drivers/md/dm-qcow2-target.c
index f4004f6095a7..3a3964e229e3 100644
--- a/drivers/md/dm-qcow2-target.c
+++ b/drivers/md/dm-qcow2-target.c
@@ -603,6 +603,7 @@ static int qcow2_check_convert_hdr(struct dm_target *ti,
return -EOPNOTSUPP;
hdr->refcount_order = 4;
+ hdr->header_length = offsetof(struct QCowHeader, incompatible_features);
if (hdr->version == 2)
return 0;
--
2.53.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Devel] [PATCH hci-8.1] drivers/md/dm-qcow2: set header_length to 72 for v2 images
2026-11-16 10:05 [Devel] [PATCH hci-8.1] drivers/md/dm-qcow2: set header_length to 72 for v2 images Alexander Ivanov
@ 2026-11-16 10:08 ` no-reply
2026-11-16 17:19 ` Konstantin Khorenko
2026-11-16 17:20 ` Konstantin Khorenko
2 siblings, 0 replies; 4+ messages in thread
From: no-reply @ 2026-11-16 10:08 UTC (permalink / raw)
To: Alexander Ivanov, andrey.zhadchenko; +Cc: devel
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] dm-qcow2: bug-fix commit lacks a Fixes: trailer
--
commit 50d27ce56be53596fa9d5de781a9cec9b705d815
Author: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
> drivers/md/dm-qcow2: set header_length to 72 for v2 images
>
> qcow2_check_convert_hdr() returns for a v2 image before it fills in
> hdr->header_length, so the field stays 0 from kzalloc().
> qcow2_parse_header() uses header_length as the start of header
> extensions and so parses them from offset 0 of the image, i.e. from
> the header itself, instead of from offset 72 right after the v2 header.
>
> Set header_length to the size of the v2 header before the version
> check, as qemu does. v3 images overwrite it from the raw header.
>
> https://virtuozzo.atlassian.net/browse/VSTOR-152394
> Feature: dm-qcow2: block device over QCOW2 files driver
>
> Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
[Severity: Low]
This fixes a bug that has been there since the driver was introduced: the
early return for v2 images has always left header_length at 0. Should this
include:
Fixes: 2a728299abdb ("dm-qcow2: Introduce driver to create block devices over QCOW2 files")
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261116100522.2867539-1-alexander.ivanov@virtuozzo.com?part=1
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Devel] [PATCH hci-8.1] drivers/md/dm-qcow2: set header_length to 72 for v2 images
2026-11-16 10:05 [Devel] [PATCH hci-8.1] drivers/md/dm-qcow2: set header_length to 72 for v2 images Alexander Ivanov
2026-11-16 10:08 ` no-reply
@ 2026-11-16 17:19 ` Konstantin Khorenko
2026-11-16 17:20 ` Konstantin Khorenko
2 siblings, 0 replies; 4+ messages in thread
From: Konstantin Khorenko @ 2026-11-16 17:19 UTC (permalink / raw)
To: Alexander Ivanov; +Cc: devel
Applying with these fixes on my side:
- subject prefix "drivers/md/dm-qcow2:" -> "dm-qcow2:", as in your
sibling patch and most of the driver history
- added what the bug did: the walk ends on a zero word of the header,
so v2 extensions were never seen
- added the new behaviour: a bitmaps extension in a v2 image is now
checked as on v3, and a malformed one fails the table load, while
qemu warns and ignores it
- added Fixes: f625cc9e0c22 ("dm-qcow2: parse bitmap extension"),
which brought ext_start = hdr->header_length; 2a728299abdb, which
Sashiko named, never read header_length for v2
On Mon, 16 Nov 2026 11:05:22 +0100, Alexander Ivanov wrote:
> Set header_length to the size of the v2 header before the version
> check, as qemu does. v3 images overwrite it from the raw header.
Bitmaps need the autoclear bit, which only v3 has, so a v2 image with
a bitmaps extension is not valid anyway. The stricter check is fine
with me, no code change needed.
--
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Devel] [PATCH hci-8.1] drivers/md/dm-qcow2: set header_length to 72 for v2 images
2026-11-16 10:05 [Devel] [PATCH hci-8.1] drivers/md/dm-qcow2: set header_length to 72 for v2 images Alexander Ivanov
2026-11-16 10:08 ` no-reply
2026-11-16 17:19 ` Konstantin Khorenko
@ 2026-11-16 17:20 ` Konstantin Khorenko
2 siblings, 0 replies; 4+ messages in thread
From: Konstantin Khorenko @ 2026-11-16 17:20 UTC (permalink / raw)
To: andrey.zhadchenko, Alexander Ivanov; +Cc: devel
On Mon, 16 Nov 2026 11:05:22 +0100, Alexander Ivanov wrote:
> drivers/md/dm-qcow2: set header_length to 72 for v2 images
Applied to branch-rh10-6.12.0-211.75.1.26.x.vz10-ovz, will be released in rh10-6.12.0-211.75.1.24.3.vz10, thanks!
[1/1] drivers/md/dm-qcow2: set header_length to 72 for v2 images
https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/affd6dc989b5
--
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-16 17:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-16 10:05 [Devel] [PATCH hci-8.1] drivers/md/dm-qcow2: set header_length to 72 for v2 images Alexander Ivanov
2026-11-16 10:08 ` no-reply
2026-11-16 17:19 ` Konstantin Khorenko
2026-11-16 17:20 ` Konstantin Khorenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox