From: Fam Zheng <famz@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org,
Stefan Hajnoczi <stefanha@redhat.com>,
qemu-stable@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 2/2] block: Fix NULL deference for unaligned write if qiov is NULL
Date: Mon, 27 Apr 2015 13:17:28 +0800 [thread overview]
Message-ID: <20150427051728.GE384@ad.nay.redhat.com> (raw)
In-Reply-To: <553A2E45.508@redhat.com>
On Fri, 04/24 13:51, Paolo Bonzini wrote:
>
>
> On 24/04/2015 13:00, Paolo Bonzini wrote:
> >> - qemu_iovec_add(&local_qiov, head_buf, offset & (align - 1));
> >> - qemu_iovec_concat(&local_qiov, qiov, 0, qiov->size);
> >> - use_local_qiov = true;
> >> + if (qiov) {
> >> + qemu_iovec_init(&local_qiov, qiov ? qiov->niov + 2 : 1);
> >> + qemu_iovec_add(&local_qiov, head_buf, offset & (align - 1));
> >> + qemu_iovec_concat(&local_qiov, qiov, 0, qiov->size);
> >> + use_local_qiov = true;
> >> + bytes += offset & (align - 1);
> >> + offset = offset & ~(align - 1);
> >> + } else {
> >> + memset(head_buf + (offset & (align - 1)), 0,
> >> + align - (offset & (align - 1)));
>
> Actually, is the byte count correct if bytes < align? In the case of
> your testcase, you'd destroy bytes 1536..4095.
Yes, good catch!
Fam
>
> Same for the computation of bytes, below. It could underflow.
>
> Perhaps a qemu-iotests testcase, using qemu-io, is also necessary.
>
> Paolo
>
> >> + ret = bdrv_aligned_pwritev(bs, &req, offset & ~(align - 1), align,
> >> + &head_qiov, 0);
> >> + if (ret < 0) {
> >> + goto fail;
> >> + }
> >> + bytes -= align - (offset & (align - 1));
> >> + offset = ROUND_UP(offset, align);
> >> + }
> >> + }
prev parent reply other threads:[~2015-04-27 5:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-24 10:33 [Qemu-devel] [PATCH v2 0/2] block: Fix unaligned bdrv_aio_write_zeroes Fam Zheng
2015-04-24 10:33 ` [Qemu-devel] [PATCH v2 1/2] Revert "block: Fix unaligned zero write" Fam Zheng
2015-04-24 11:12 ` Fam Zheng
2015-04-24 10:33 ` [Qemu-devel] [PATCH v2 2/2] block: Fix NULL deference for unaligned write if qiov is NULL Fam Zheng
2015-04-24 11:00 ` Paolo Bonzini
2015-04-24 11:51 ` Paolo Bonzini
2015-04-27 5:17 ` Fam Zheng [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=20150427051728.GE384@ad.nay.redhat.com \
--to=famz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=stefanha@redhat.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 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).