All of lore.kernel.org
 help / color / mirror / Atom feed
From: gerben@altlinux.org
To: qemu-devel@nongnu.org, kwolf@redhat.com, hreitz@redhat.com
Cc: sdl.qemu@linuxtesting.org
Subject: [PATCH] block/vmdk: prevent double-free in extent memory management
Date: Tue,  4 Mar 2025 12:04:02 +0300	[thread overview]
Message-ID: <20250304090415.39393-1-gerben@altlinux.org> (raw)

From: Denis Rastyogin <gerben@altlinux.org>

This error was discovered by fuzzing qemu-img.

A double-free issue in the VMDK driver occurs when handling snapshots.
The memory allocated for extent structures is freed twice: first in
vmdk_close (block/vmdk.c) and then in vmdk_add_extent (block/vmdk.c).

The fix ensures the s->extents pointer is set to NULL after freeing,
preventing double-free.

Closes: https://gitlab.com/qemu-project/qemu/-/issues/2853
Signed-off-by: Denis Rastyogin <gerben@altlinux.org>
---
 block/vmdk.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/block/vmdk.c b/block/vmdk.c
index 2adec49912..d6baa54602 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -285,6 +285,7 @@ static void vmdk_free_extents(BlockDriverState *bs)
     bdrv_graph_wrunlock();
 
     g_free(s->extents);
+    s->extents = NULL;
 }
 
 static void vmdk_free_last_extent(BlockDriverState *bs)
-- 
2.42.2



             reply	other threads:[~2025-03-04  9:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-04  9:04 gerben [this message]
2025-03-10 10:35 ` [PATCH] block/vmdk: prevent double-free in extent memory management 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=20250304090415.39393-1-gerben@altlinux.org \
    --to=gerben@altlinux.org \
    --cc=hreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=sdl.qemu@linuxtesting.org \
    /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.