qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PULL for-9.0 0/1] Block patches
@ 2024-04-04 13:58 Stefan Hajnoczi
  2024-04-04 13:58 ` [PULL for-9.0 1/1] block/virtio-blk: Fix memory leak from virtio_blk_zone_report Stefan Hajnoczi
  2024-04-04 17:26 ` [PULL for-9.0 0/1] Block patches Peter Maydell
  0 siblings, 2 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2024-04-04 13:58 UTC (permalink / raw)
  To: qemu-devel
  Cc: Michael S. Tsirkin, Peter Maydell, qemu-block, Stefan Hajnoczi,
	Hanna Reitz, Kevin Wolf

The following changes since commit 786fd793b81410fb2a28914315e2f05d2ff6733b:

  Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2024-04-03 12:52:03 +0100)

are available in the Git repository at:

  https://gitlab.com/stefanha/qemu.git tags/block-pull-request

for you to fetch changes up to bbdf9023665f409113cb07b463732861af63fb47:

  block/virtio-blk: Fix memory leak from virtio_blk_zone_report (2024-04-04 09:29:42 -0400)

----------------------------------------------------------------
Pull request

Fix a memory leak in virtio-blk zone report emulation code when the request is
invalid.

----------------------------------------------------------------

Zheyu Ma (1):
  block/virtio-blk: Fix memory leak from virtio_blk_zone_report

 hw/block/virtio-blk.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

-- 
2.44.0



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PULL for-9.0 1/1] block/virtio-blk: Fix memory leak from virtio_blk_zone_report
  2024-04-04 13:58 [PULL for-9.0 0/1] Block patches Stefan Hajnoczi
@ 2024-04-04 13:58 ` Stefan Hajnoczi
  2024-04-04 17:26 ` [PULL for-9.0 0/1] Block patches Peter Maydell
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2024-04-04 13:58 UTC (permalink / raw)
  To: qemu-devel
  Cc: Michael S. Tsirkin, Peter Maydell, qemu-block, Stefan Hajnoczi,
	Hanna Reitz, Kevin Wolf, Zheyu Ma

From: Zheyu Ma <zheyuma97@gmail.com>

This modification ensures that in scenarios where the buffer size is
insufficient for a zone report, the function will now properly set an
error status and proceed to a cleanup label, instead of merely
returning.

The following ASAN log reveals it:

==1767400==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 312 byte(s) in 1 object(s) allocated from:
    #0 0x64ac7b3280cd in malloc llvm/compiler-rt/lib/asan/asan_malloc_linux.cpp:129:3
    #1 0x735b02fb9738 in g_malloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x5e738)
    #2 0x64ac7d23be96 in virtqueue_split_pop hw/virtio/virtio.c:1612:12
    #3 0x64ac7d23728a in virtqueue_pop hw/virtio/virtio.c:1783:16
    #4 0x64ac7cfcaacd in virtio_blk_get_request hw/block/virtio-blk.c:228:27
    #5 0x64ac7cfca7c7 in virtio_blk_handle_vq hw/block/virtio-blk.c:1123:23
    #6 0x64ac7cfecb95 in virtio_blk_handle_output hw/block/virtio-blk.c:1157:5

Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
Message-id: 20240404120040.1951466-1-zheyuma97@gmail.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 hw/block/virtio-blk.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 92de315f17..bb86e65f65 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -768,7 +768,8 @@ static void virtio_blk_handle_zone_report(VirtIOBlockReq *req,
             sizeof(struct virtio_blk_zone_report) +
             sizeof(struct virtio_blk_zone_descriptor)) {
         virtio_error(vdev, "in buffer too small for zone report");
-        return;
+        err_status = VIRTIO_BLK_S_ZONE_INVALID_CMD;
+        goto out;
     }
 
     /* start byte offset of the zone report */
-- 
2.44.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PULL for-9.0 0/1] Block patches
  2024-04-04 13:58 [PULL for-9.0 0/1] Block patches Stefan Hajnoczi
  2024-04-04 13:58 ` [PULL for-9.0 1/1] block/virtio-blk: Fix memory leak from virtio_blk_zone_report Stefan Hajnoczi
@ 2024-04-04 17:26 ` Peter Maydell
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2024-04-04 17:26 UTC (permalink / raw)
  To: Stefan Hajnoczi
  Cc: qemu-devel, Michael S. Tsirkin, qemu-block, Hanna Reitz,
	Kevin Wolf

On Thu, 4 Apr 2024 at 14:58, Stefan Hajnoczi <stefanha@redhat.com> wrote:
>
> The following changes since commit 786fd793b81410fb2a28914315e2f05d2ff6733b:
>
>   Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging (2024-04-03 12:52:03 +0100)
>
> are available in the Git repository at:
>
>   https://gitlab.com/stefanha/qemu.git tags/block-pull-request
>
> for you to fetch changes up to bbdf9023665f409113cb07b463732861af63fb47:
>
>   block/virtio-blk: Fix memory leak from virtio_blk_zone_report (2024-04-04 09:29:42 -0400)
>
> ----------------------------------------------------------------
> Pull request
>
> Fix a memory leak in virtio-blk zone report emulation code when the request is
> invalid.
>
> ----------------------------------------------------------------
>


Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/9.0
for any user-visible changes.

-- PMM


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-04-04 17:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-04 13:58 [PULL for-9.0 0/1] Block patches Stefan Hajnoczi
2024-04-04 13:58 ` [PULL for-9.0 1/1] block/virtio-blk: Fix memory leak from virtio_blk_zone_report Stefan Hajnoczi
2024-04-04 17:26 ` [PULL for-9.0 0/1] Block patches Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).