All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org,
	Hanna Reitz <hreitz@redhat.com>,
	boy juju <agx1657748706@gmail.com>,
	Tristan Madani <tristan@talencesecurity.com>
Subject: Re: [PATCH for-11.1 1/3] dmg: fix out-of-bounds load in search_chunk() (CVE-2026-65929)
Date: Fri, 24 Jul 2026 16:27:45 +0200	[thread overview]
Message-ID: <amN2YcIgQuUsrFOa@redhat.com> (raw)
In-Reply-To: <20260723144519.364701-2-stefanha@redhat.com>

Am 23.07.2026 um 16:45 hat Stefan Hajnoczi geschrieben:
> The binary search in search_chunk() uses s->n_chunks as the (inclusive)
> upper bound. Chunk indices are in the right-open interval [0,
> s->n_chunks) so it is wrong to search all the way up to s->n_chunks
> rather than s->n_chunks - 1.
> 
> The worst case security scenario I can see is convincing a victim to
> hotplug a malicious DMG file to a running guest, potentially causing
> QEMU to crash when loading from memory beyond the end of s->sectors[] or
> s->sectorscounts[]. This could be a denial of service.
> 
> Fixes: CVE-2026-65929
> Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3844
> Reported-by: boy juju <agx1657748706@gmail.com>
> Reported-by: Tristan Madani <tristan@talencesecurity.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  block/dmg.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/block/dmg.c b/block/dmg.c
> index 33dcb3a3498..e325127d144 100644
> --- a/block/dmg.c
> +++ b/block/dmg.c
> @@ -609,7 +609,10 @@ static inline int is_sector_in_chunk(BDRVDMGState *s,
>  static inline uint32_t search_chunk(BDRVDMGState *s, uint64_t sector_num)
>  {
>      /* binary search */
> -    uint32_t chunk1 = 0, chunk2 = s->n_chunks, chunk3;
> +    uint32_t chunk1 = 0, chunk2 = s->n_chunks - 1, chunk3;
> +    if (s->n_chunks == 0) {
> +        goto err; /* should never happen */
> +    }
>      while (chunk1 <= chunk2) {
>          chunk3 = (chunk1 + chunk2) / 2;
>          if (s->sectors[chunk3] > sector_num) {

Fair enough to keep the fix minimal here, but is there any justification
for manually implementing binary search instead of using bsearch()? If
not, this could be a follow-up cleanup.

Kevin



  parent reply	other threads:[~2026-07-24 14:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-23 14:45 [PATCH for-11.1 0/3] dmg: add missing input validation (CVE-2026-65929 & CVE-2026-65928) Stefan Hajnoczi
2026-07-23 14:45 ` [PATCH for-11.1 1/3] dmg: fix out-of-bounds load in search_chunk() (CVE-2026-65929) Stefan Hajnoczi
2026-07-24  6:41   ` Philippe Mathieu-Daudé
2026-07-24 14:27   ` Kevin Wolf [this message]
2026-07-23 14:45 ` [PATCH for-11.1 2/3] dmg: refuse to open files with no chunks Stefan Hajnoczi
2026-07-24  6:37   ` Philippe Mathieu-Daudé
2026-07-23 14:45 ` [PATCH for-11.1 3/3] dmg: reject inconsistent UDRW chunk sector count and length (CVE-2026-65928) Stefan Hajnoczi
2026-07-24 15:15 ` [PATCH for-11.1 0/3] dmg: add missing input validation (CVE-2026-65929 & CVE-2026-65928) 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=amN2YcIgQuUsrFOa@redhat.com \
    --to=kwolf@redhat.com \
    --cc=agx1657748706@gmail.com \
    --cc=hreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=tristan@talencesecurity.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.