From: Eric Blake <eblake@redhat.com>
To: Thomas Huth <thuth@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
qemu-devel@nongnu.org, Peter Maydell <peter.maydell@linaro.org>,
Hanna Reitz <hreitz@redhat.com>,
qemu-block@nongnu.org
Subject: Re: [PATCH] block/vhdx: Add alignment checks for region tables
Date: Wed, 11 Nov 2026 14:32:46 -0600 [thread overview]
Message-ID: <avTQnxm1bMJ6WbDQ@redhat.com> (raw)
In-Reply-To: <20261111161442.329763-1-thuth@redhat.com>
On Wed, Nov 11, 2026 at 05:14:42PM +0100, Thomas Huth wrote:
> 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>
> ---
> block/vhdx.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/block/vhdx.c b/block/vhdx.c
> index 8013a90a1a4..f5beace56f5 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 length must be at least 1 MiB.
> + */
> + if ((rt_entry.file_offset & (MiB - 1)) ||
> + (rt_entry.length & (MiB - 1)) || rt_entry.length < MiB) {
Would QEMU_IS_ALIGNED() be better than open-coding the math here?
Also, the 'rt_entry.length < MiB' clause could be simplified to
'rt_entry.length == 0', since all other values less than MiB fail the
earlier alignment clause.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc.
Virtualization: qemu.org | libguestfs.org
next prev parent reply other threads:[~2026-11-11 20:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 16:14 [PATCH] block/vhdx: Add alignment checks for region tables Thomas Huth
2026-11-11 20:32 ` Eric Blake [this message]
2026-11-12 9:11 ` Thomas Huth
-- strict thread matches above, loose matches on Subject: below --
2026-11-12 9:22 Thomas Huth
2026-11-12 12:49 ` Kevin Wolf
2026-11-12 14:48 ` Thomas Huth
2026-11-12 16:19 ` Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=avTQnxm1bMJ6WbDQ@redhat.com \
--to=eblake@redhat.com \
--cc=hreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.