From: Paolo Bonzini <pbonzini@redhat.com>
To: Fam Zheng <famz@redhat.com>, qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, qemu-stable@nongnu.org,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 2/2] block: Fix NULL deference for unaligned write if qiov is NULL
Date: Fri, 24 Apr 2015 13:51:33 +0200 [thread overview]
Message-ID: <553A2E45.508@redhat.com> (raw)
In-Reply-To: <553A2245.9060304@redhat.com>
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.
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);
>> + }
>> + }
next prev parent reply other threads:[~2015-04-24 11:51 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 [this message]
2015-04-27 5:17 ` Fam Zheng
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=553A2E45.508@redhat.com \
--to=pbonzini@redhat.com \
--cc=famz@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 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.