* [Devel] [PATCH hci-8.1] dm-qcow2: reject v3 images with header_length below 104
@ 2026-11-16 10:37 Alexander Ivanov
2026-11-16 10:40 ` no-reply
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Alexander Ivanov @ 2026-11-16 10:37 UTC (permalink / raw)
To: andrey.zhadchenko; +Cc: devel
qcow2_check_convert_hdr() checks header_length only when the
compression bit is set, and only against sizeof(struct QCowHeader). A
v3 image with header_length below the fixed v3 header size is
accepted, and the header extension parser then starts at
header_length and reads the fixed header fields as extensions.
The driver used to refuse such images, but the check went under the
compression bit when zstd support was added.
Fail with -EINVAL when a v3 image has header_length below 104,
regardless of its incompatible features, as qemu does ("qcow2 header
too short").
Fixes: 66195f78dd3c ("dm-qcow2: add zstd decompression")
https://virtuozzo.atlassian.net/browse/VSTOR-152393
Feature: dm-qcow2: block device over QCOW2 files driver
Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
---
drivers/md/dm-qcow2-target.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/md/dm-qcow2-target.c b/drivers/md/dm-qcow2-target.c
index f4004f6095a7..89c3a91f0fec 100644
--- a/drivers/md/dm-qcow2-target.c
+++ b/drivers/md/dm-qcow2-target.c
@@ -612,6 +612,9 @@ static int qcow2_check_convert_hdr(struct dm_target *ti,
hdr->refcount_order = be32_to_cpu(raw_hdr->refcount_order);
hdr->header_length = be32_to_cpu(raw_hdr->header_length);
+ if (hdr->header_length < offsetof(struct QCowHeader, compression_type))
+ return -EINVAL;
+
is_ro = !(dm_table_get_mode(ti->table) & FMODE_WRITE);
// if (!is_ro && kernel_sets_dirty_bit !=
--
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] dm-qcow2: reject v3 images with header_length below 104
2026-11-16 10:37 [Devel] [PATCH hci-8.1] dm-qcow2: reject v3 images with header_length below 104 Alexander Ivanov
@ 2026-11-16 10:40 ` no-reply
2026-11-16 17:21 ` Konstantin Khorenko
2026-11-16 17:21 ` Konstantin Khorenko
2 siblings, 0 replies; 4+ messages in thread
From: no-reply @ 2026-11-16 10:40 UTC (permalink / raw)
To: Alexander Ivanov, andrey.zhadchenko; +Cc: devel
> qcow2_check_convert_hdr() checks header_length only when the
> compression bit is set, and only against sizeof(struct QCowHeader). A
> v3 image with header_length below the fixed v3 header size is
> accepted, and the header extension parser then starts at
> header_length and reads the fixed header fields as extensions.
>
> The driver used to refuse such images, but the check went under the
> compression bit when zstd support was added.
>
> Fail with -EINVAL when a v3 image has header_length below 104,
> regardless of its incompatible features, as qemu does ("qcow2 header
> too short").
>
> Fixes: 66195f78dd3c ("dm-qcow2: add zstd decompression")
> https://virtuozzo.atlassian.net/browse/VSTOR-152393
> Feature: dm-qcow2: block device over QCOW2 files driver
>
> Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261116103752.2878746-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] dm-qcow2: reject v3 images with header_length below 104
2026-11-16 10:37 [Devel] [PATCH hci-8.1] dm-qcow2: reject v3 images with header_length below 104 Alexander Ivanov
2026-11-16 10:40 ` no-reply
@ 2026-11-16 17:21 ` Konstantin Khorenko
2026-11-16 17:21 ` Konstantin Khorenko
2 siblings, 0 replies; 4+ messages in thread
From: Konstantin Khorenko @ 2026-11-16 17:21 UTC (permalink / raw)
To: Alexander Ivanov; +Cc: devel
Applying as is.
On Mon, 16 Nov 2026 11:37:52 +0100, Alexander Ivanov wrote:
> + if (hdr->header_length < offsetof(struct QCowHeader, compression_type))
> + return -EINVAL;
This is the check 66195f78dd3c dropped, back with qemu's threshold and
error code. No tool writes a v3 header below 104, so only a broken
image is refused.
--
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] dm-qcow2: reject v3 images with header_length below 104
2026-11-16 10:37 [Devel] [PATCH hci-8.1] dm-qcow2: reject v3 images with header_length below 104 Alexander Ivanov
2026-11-16 10:40 ` no-reply
2026-11-16 17:21 ` Konstantin Khorenko
@ 2026-11-16 17:21 ` Konstantin Khorenko
2 siblings, 0 replies; 4+ messages in thread
From: Konstantin Khorenko @ 2026-11-16 17:21 UTC (permalink / raw)
To: andrey.zhadchenko, Alexander Ivanov; +Cc: devel
On Mon, 16 Nov 2026 11:37:52 +0100, Alexander Ivanov wrote:
> dm-qcow2: reject v3 images with header_length below 104
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] dm-qcow2: reject v3 images with header_length below 104
https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/a656d0a24ddd
--
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:22 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:37 [Devel] [PATCH hci-8.1] dm-qcow2: reject v3 images with header_length below 104 Alexander Ivanov
2026-11-16 10:40 ` no-reply
2026-11-16 17:21 ` Konstantin Khorenko
2026-11-16 17:21 ` Konstantin Khorenko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.