* [PATCH v3] block/vhdx: Add alignment checks for region tables
@ 2026-11-13 7:23 Thomas Huth
2026-11-16 17:07 ` Kevin Wolf
0 siblings, 1 reply; 2+ messages in thread
From: Thomas Huth @ 2026-11-13 7:23 UTC (permalink / raw)
To: Kevin Wolf, qemu-devel
Cc: Peter Maydell, Hanna Reitz, qemu-block, Eric Blake, qemu-stable
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.
Buglink: https://gitlab.com/qemu-project/qemu/-/work_items/3762
Reported-by: Daniel Wade <danjwade95@gmail.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
v3: Fixed the check: Offset (not the length) must be at least 1 MB
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, BDRVVHDXState *s)
vhdx_region_entry_le_import(&rt_entry);
+ /*
+ * 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_offset) {
+ ret = -EINVAL;
+ goto fail;
+ }
+
/* check for region overlap between these entries, and any
* other memory regions in the file */
ret = vhdx_region_check(s, rt_entry.file_offset, rt_entry.length);
--
2.56.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v3] block/vhdx: Add alignment checks for region tables
2026-11-13 7:23 [PATCH v3] block/vhdx: Add alignment checks for region tables Thomas Huth
@ 2026-11-16 17:07 ` Kevin Wolf
0 siblings, 0 replies; 2+ messages in thread
From: Kevin Wolf @ 2026-11-16 17:07 UTC (permalink / raw)
To: Thomas Huth
Cc: qemu-devel, Peter Maydell, Hanna Reitz, qemu-block, Eric Blake,
qemu-stable
Am 13.11.2026 um 08:23 hat Thomas Huth geschrieben:
> 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.
>
> Buglink: https://gitlab.com/qemu-project/qemu/-/work_items/3762
> Reported-by: Daniel Wade <danjwade95@gmail.com>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
Thanks, applied to the block branch.
Kevin
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-16 17:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-13 7:23 [PATCH v3] block/vhdx: Add alignment checks for region tables Thomas Huth
2026-11-16 17:07 ` Kevin Wolf
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.