All of
 help / color / mirror / Atom feed
To: "" <>
Subject: Fix a potential Use-after-free in test_blockjob_common_drain_node() (v6.2.0).
Date: Wed, 23 Feb 2022 22:37:24 +0800 (GMT+08:00)	[thread overview]
Message-ID: <> (raw)

[-- Attachment #1.1: Type: text/plain, Size: 754 bytes --]

Hi all,

I find a potential Use-after-free in QEMU 6.2.0, which is in test_blockjob_common_drain_node() (./tests/unit/test-bdrv-drain.c).

Specifically, at line 880, the variable 'scr' is released by the bdrv_unref(). However, at line 881, it is subsequently used as the 1st parameter of the function bdrv_set_backing_hd(). As a result, an UAF bug may be triggered.

880    bdrv_unref(src);

881    bdrv_set_backing_hd(src, src_backing, &error_abort);

I believe that the problem can be fixed by invoking bdrv_unref() after the call of bdrv_set_backing_hd() rather than before it.

---    bdrv_unref(src);
881    bdrv_set_backing_hd(src, src_backing, &error_abort);

I'm looking forward to your confirmation.


[-- Attachment #1.2: Type: text/html, Size: 3074 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: test-bdrv-drain.patch --]
[-- Type: text/x-patch; name=test-bdrv-drain.patch, Size: 506 bytes --]

--- ./tests/unit/test-bdrv-drain.c	2022-02-23 15:06:32.384786070 +0800
+++ ./tests/unit/test-bdrv-drain-PATCH.c	2022-02-23 21:16:43.444928992 +0800
@@ -877,8 +877,8 @@
                                        BDRV_O_RDWR, &error_abort);
     bdrv_set_backing_hd(src_overlay, src, &error_abort);
-    bdrv_unref(src);
     bdrv_set_backing_hd(src, src_backing, &error_abort);
+    bdrv_unref(src);
     blk_src = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL);

             reply	other threads:[~2022-02-23 15:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-23 14:37 wliang [this message]
2022-02-25  4:21 ` Fix a potential Use-after-free in test_blockjob_common_drain_node() (v6.2.0) wliang

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* 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.