All of lore.kernel.org
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
	qemu-block@nongnu.org
Cc: kwolf@redhat.com, fam@euphon.net, qemu-devel@nongnu.org,
	stefanha@redhat.com, qemu-stable@nongnu.org
Subject: Re: [PATCH] block: fix crash on zero-length unaligned write and read
Date: Thu, 6 Feb 2020 18:36:36 +0100	[thread overview]
Message-ID: <ac4dc8b4-1057-673b-b7cd-70efbc81daab@redhat.com> (raw)
In-Reply-To: <20200206164245.17781-1-vsementsov@virtuozzo.com>


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

On 06.02.20 17:42, Vladimir Sementsov-Ogievskiy wrote:
> Commit 7a3f542fbd "block/io: refactor padding" occasionally dropped
> aligning for zero-length request: bdrv_init_padding() blindly return
> false if bytes == 0, like there is nothing to align.
> 
> This leads the following command to crash:
> 
> ./qemu-io --image-opts -c 'write 1 0' \
>   driver=blkdebug,align=512,image.driver=null-co,image.size=512
> 
>>> qemu-io: block/io.c:1955: bdrv_aligned_pwritev: Assertion
>     `(offset & (align - 1)) == 0' failed.
>>> Aborted (core dumped)
> 
> Prior to 7a3f542fbd we does aligning of such zero requests. Instead of
> recovering this behavior let's just do nothing on such requests as it
> is useless.
> 
> Note that driver may have special meaning of zero-length reqeusts, like
> qcow2_co_pwritev_compressed_part, so we can't skip any zero-length
> operation. But for unaligned ones, we can't pass it to driver anyway.
> 
> This commit also fixes crash in iotest 80 running with -nocache:
> 
> ./check -nocache -qcow2 80
> 
> which crashes on same assertion due to trying to read empty extra data
> in qcow2_do_read_snapshots().
> 
> Cc: qemu-stable@nongnu.org # v4.2
> Fixes: 7a3f542fbd
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  block/io.c | 28 +++++++++++++++++++++++++++-
>  1 file changed, 27 insertions(+), 1 deletion(-)

Zero-length reads would still trigger CORs when padded.  But there is no
reason to assume or rely on this, so:

Reviewed-by: Max Reitz <mreitz@redhat.com>

(block/io.c is Stefan’s department. :-))

Max


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2020-02-06 17:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-06 16:42 [PATCH] block: fix crash on zero-length unaligned write and read Vladimir Sementsov-Ogievskiy
2020-02-06 17:36 ` Max Reitz [this message]
2020-02-07 16:47 ` Stefan Hajnoczi
2020-02-07 16:51   ` Vladimir Sementsov-Ogievskiy

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=ac4dc8b4-1057-673b-b7cd-70efbc81daab@redhat.com \
    --to=mreitz@redhat.com \
    --cc=fam@euphon.net \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=vsementsov@virtuozzo.com \
    /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.