From: Eric Blake <eblake@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, pbonzini@redhat.com, kwolf@redhat.com,
Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 6/7] nbd-client: Stricter enforcing of structured reply spec
Date: Thu, 9 Nov 2017 08:45:49 -0600 [thread overview]
Message-ID: <a87d9893-53fa-0dec-79b9-7f1f6a4c3db5@redhat.com> (raw)
In-Reply-To: <22a7af7d-6ce4-c73d-1559-58a30ba2115d@virtuozzo.com>
[-- Attachment #1: Type: text/plain, Size: 2221 bytes --]
On 11/09/2017 03:37 AM, Vladimir Sementsov-Ogievskiy wrote:
> 09.11.2017 00:57, Eric Blake wrote:
>> Ensure that the server is not sending unexpected chunk lengths
>> for either the NONE or the OFFSET_DATA chunk, nor unexpected
>> hole length for OFFSET_HOLE. This will flag any server that
>> responds to a zero-length read with an OFFSET_DATA as broken,
>
> or OFFSET_HOLE
True, even though our implementation was not doing that. I can tweak
the commit message.
>
>> even though we previously fixed our client to never be able to
>> send such a request over the wire.
>>
>> Signed-off-by: Eric Blake <eblake@redhat.com>
>> ---
>> block/nbd-client.c | 12 +++++++++---
>> 1 file changed, 9 insertions(+), 3 deletions(-)
>>
>> @@ -281,7 +281,8 @@ static int
>> nbd_co_receive_offset_data_payload(NBDClientSession *s,
>>
>> assert(nbd_reply_is_structured(&s->reply));
>>
>> - if (chunk->length < sizeof(offset)) {
>> + /* The NBD spec requires at least one byte of payload */
>> + if (chunk->length <= sizeof(offset)) {
>> error_setg(errp, "Protocol error: invalid payload for "
>> "NBD_REPLY_TYPE_OFFSET_DATA");
>> return -EINVAL;
>> @@ -293,7 +294,7 @@ static int
>> nbd_co_receive_offset_data_payload(NBDClientSession *s,
>> be64_to_cpus(&offset);
>>
>> data_size = chunk->length - sizeof(offset);
>> - if (offset < orig_offset || data_size > qiov->size ||
>> + if (!data_size || offset < orig_offset || data_size > qiov->size ||
>
> !data_size - always false here (because of previous check), and even if
> it could be zero it
> isn't correspond to error message.
>
> without this, or with an assert instead:
I like the assert instead.
>
> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>
>
Thanks for the reviews; I'll queue this series onto my NBD tree with
your suggestions incorporated, and send a pull request for 2.11 shortly.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]
next prev parent reply other threads:[~2017-11-09 14:46 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-08 21:56 [Qemu-devel] [PATCH v2 0/7] various NBD fixes for 2.11 Eric Blake
2017-11-08 21:56 ` [Qemu-devel] [PATCH v2 1/7] nbd-client: Fix error message typos Eric Blake
2017-11-09 8:58 ` Vladimir Sementsov-Ogievskiy
2017-11-09 14:43 ` Eric Blake
2017-11-08 21:56 ` [Qemu-devel] [PATCH v2 2/7] nbd-client: Refuse read-only client with BDRV_O_RDWR Eric Blake
2017-11-08 22:07 ` Eric Blake
2017-11-08 22:23 ` [Qemu-devel] [PATCH v2 2.5/7] fixup! " Eric Blake
2017-11-09 9:05 ` Vladimir Sementsov-Ogievskiy
2017-11-09 9:04 ` [Qemu-devel] [PATCH v2 2/7] " Vladimir Sementsov-Ogievskiy
2017-11-08 21:56 ` [Qemu-devel] [PATCH v2 3/7] nbd/client: Nicer trace of structured reply Eric Blake
2017-11-09 9:10 ` Vladimir Sementsov-Ogievskiy
2017-11-08 21:57 ` [Qemu-devel] [PATCH v2 4/7] nbd: Fix struct name for structured reads Eric Blake
2017-11-09 9:13 ` Vladimir Sementsov-Ogievskiy
2017-11-08 21:57 ` [Qemu-devel] [PATCH v2 5/7] nbd-client: Short-circuit 0-length operations Eric Blake
2017-11-09 9:20 ` Vladimir Sementsov-Ogievskiy
2017-11-09 14:44 ` Eric Blake
2017-11-08 21:57 ` [Qemu-devel] [PATCH v2 6/7] nbd-client: Stricter enforcing of structured reply spec Eric Blake
2017-11-09 9:37 ` Vladimir Sementsov-Ogievskiy
2017-11-09 14:45 ` Eric Blake [this message]
2017-11-08 21:57 ` [Qemu-devel] [PATCH v2 7/7] nbd/server: Fix structured read of length 0 Eric Blake
2017-11-09 9:43 ` Vladimir Sementsov-Ogievskiy
2017-11-08 22:24 ` [Qemu-devel] [PATCH v2 0/7] various NBD fixes for 2.11 no-reply
2017-11-08 23:05 ` Eric Blake
2017-11-09 5:34 ` 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=a87d9893-53fa-0dec-79b9-7f1f6a4c3db5@redhat.com \
--to=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--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 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).