All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: qemu-devel@nongnu.org, Kevin Wolf <kwolf@redhat.com>,
	 qemu-block@nongnu.org, Hanna Reitz <hreitz@redhat.com>
Subject: Re: [PATCH] dmg: avoid out-of-bounds memory load in dmg_read_mish_block()
Date: Tue, 13 Oct 2026 15:22:41 -0500	[thread overview]
Message-ID: <as6SWQZE8hTiY81a@redhat.com> (raw)
In-Reply-To: <20261013193710.1311621-1-stefanha@redhat.com>

On Tue, Oct 13, 2026 at 03:37:08PM -0400, Stefan Hajnoczi wrote:
> dmg_read_mish_block() loads from memory beyond the end of the buffer
> when count is less than 4.
> 
> There is no known security impact here because dmg_read_mish_block()
> returns almost immediately without any opportunity to gain control of
> execution or cause other damage. A crash will not happen because it's a
> 32-bit load from a memory address that was just heap allocated. The
> address will be properly aligned and will not span a page of memory.
> 
> Reported-by: router0mail <https://gitlab.com/router0mail>
> Fixes: 7aee37b93a4f ("block/dmg: process a buffer instead of reading ints")
> Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4569
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  block/dmg.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/block/dmg.c b/block/dmg.c
> index 5d7d3b8901f..412d4bfc354 100644
> --- a/block/dmg.c
> +++ b/block/dmg.c
> @@ -226,9 +226,13 @@ static int dmg_read_mish_block(BDRVDMGState *s, DmgHeaderState *ds,
>      uint64_t in_offset = ds->data_fork_offset;
>      uint64_t out_offset;
>  
> +    if (count < 244) {
> +        return 0; /* too small, skip silently */
> +    }
> +
>      type = buff_read_uint32(buffer, offset);
> -    /* skip data that is not a valid MISH block (invalid magic or too small) */
> -    if (type != 0x6d697368 || count < 244) {
> +    /* skip data that is not a valid MISH block (invalid magic) */
> +    if (type != 0x6d697368) {
>          /* assume success for now */
>          return 0;
>      }

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.
Virtualization:  qemu.org | libguestfs.org



      reply	other threads:[~2026-10-13 20:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13 19:37 [PATCH] dmg: avoid out-of-bounds memory load in dmg_read_mish_block() Stefan Hajnoczi
2026-10-13 20:22 ` Eric Blake [this message]

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=as6SWQZE8hTiY81a@redhat.com \
    --to=eblake@redhat.com \
    --cc=hreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@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.