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
Subject: Re: [PATCH v2] qemu-img: fix offset calculation in bench
Date: Tue, 20 May 2025 12:04:05 +0200 [thread overview]
Message-ID: <aCxTlds6UuiTR6w3@redhat.com> (raw)
In-Reply-To: <20250506141410.100119-1-gerben@altlinux.org>
Am 06.05.2025 um 16:13 hat gerben@altlinux.org geschrieben:
> From: Denis Rastyogin <gerben@altlinux.org>
>
> This error was discovered by fuzzing qemu-img.
>
> The current offset calculation leads to an EIO error
> in block/block-backend.c: blk_check_byte_request():
>
> if (offset > len || len - offset < bytes) {
> return -EIO;
> }
>
> This triggers the error message:
> "qemu-img: Failed request: Input/output error".
>
> Example of the issue:
> offset: 260076
> len: 260096
> bytes: 4096
>
> This fix ensures that offset remains within a valid range.
>
> Signed-off-by: Denis Rastyogin <gerben@altlinux.org>
> ---
> qemu-img.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/qemu-img.c b/qemu-img.c
> index 76ac5d3028..e64acfafb3 100644
> --- a/qemu-img.c
> +++ b/qemu-img.c
> @@ -4488,10 +4488,10 @@ static void bench_cb(void *opaque, int ret)
> */
> b->in_flight++;
> b->offset += b->step;
> - if (b->image_size == 0) {
> + if (b->image_size - b->bufsize <= 0) {
The result of b->image_size - b->bufsize is unsigned, so this doesn't do
what it looks like. I'm replacing it with b->image_size <= b->bufsize.
> b->offset = 0;
> } else {
> - b->offset %= b->image_size;
> + b->offset %= b->image_size - b->bufsize;
> }
> if (b->write) {
> acb = blk_aio_pwritev(b->blk, offset, b->qiov, 0, bench_cb, b);
Thanks, applied to the block branch.
Kevin
prev parent reply other threads:[~2025-05-20 10:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-06 14:13 [PATCH v2] qemu-img: fix offset calculation in bench gerben
2025-05-20 10:04 ` Kevin Wolf [this message]
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=aCxTlds6UuiTR6w3@redhat.com \
--to=kwolf@redhat.com \
--cc=gerben@altlinux.org \
--cc=hreitz@redhat.com \
--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 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.