qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: gerben@altlinux.org
Cc: qemu-block@nongnu.org, hreitz@redhat.com, qemu-devel@nongnu.org,
	sdl.qemu@linuxtesting.org, Vasiliy Kovalev <kovalev@altlinux.org>
Subject: Re: [PATCH 3/4] qemu-img: prevent stack overflow in bench by using bottom half
Date: Fri, 25 Apr 2025 18:08:46 +0200	[thread overview]
Message-ID: <aAuzjsNLQRUv3orx@redhat.com> (raw)
In-Reply-To: <20250327162423.25154-4-gerben@altlinux.org>

Am 27.03.2025 um 17:24 hat gerben@altlinux.org geschrieben:
> From: Denis Rastyogin <gerben@altlinux.org>
> 
> This error was discovered by fuzzing qemu-img.
> 
> Previously, new I/O requests were launched synchronously inside the
> completion callback `bench_cb`, leading to deep recursion and stack
> overflow. This patch moves the launching of new requests to a separate
> function `bench_bh`, scheduled via `qemu_bh_schedule` to run in the event
> loop context, thus unwinding the stack and preventing overflow.
> 
> Signed-off-by: Vasiliy Kovalev <kovalev@altlinux.org>
> Signed-off-by: Denis Rastyogin <gerben@altlinux.org>

Normally, the callback shouldn't immediately be called, except for
errors, which take a different code path anyway.

Was this tested with the null block driver or with a backend that is
actually relevant in practice?

I wonder if switching qemu-img bench to coroutines would make sense. But
since this is a benchmarking tool, we need to measure the performance
difference from both an additional BH and from switching to coroutines
compared to the current state. In case of doubt, I'd leave this unfixed,
this isn't something that is run in production.

Kevin



  reply	other threads:[~2025-04-25 16:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-27 16:24 [PATCH 0/4] Fix qemu-img bench issues and improve checks gerben
2025-03-27 16:24 ` [PATCH 1/4] qemu-img: fix division by zero in bench_cb() for zero-sized gerben
2025-03-27 16:24 ` [PATCH 2/4] qemu-img: fix offset calculation in bench gerben
2025-04-25 16:04   ` Kevin Wolf
2025-03-27 16:24 ` [PATCH 3/4] qemu-img: prevent stack overflow in bench by using bottom half gerben
2025-04-25 16:08   ` Kevin Wolf [this message]
2025-03-27 16:24 ` [PATCH 4/4] qemu-img: improve queue depth validation in img_bench gerben
2025-04-25 16:10   ` 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=aAuzjsNLQRUv3orx@redhat.com \
    --to=kwolf@redhat.com \
    --cc=gerben@altlinux.org \
    --cc=hreitz@redhat.com \
    --cc=kovalev@altlinux.org \
    --cc=qemu-block@nongnu.org \
    --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 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).