From: John Snow <jsnow@redhat.com>
To: Eric Blake <eblake@redhat.com>, qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
vsementsov@virtuozzo.com, qemu-stable@nongnu.org,
qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] nbd/server: Reject 0-length block status request
Date: Thu, 21 Jun 2018 17:35:04 -0400 [thread overview]
Message-ID: <3f0ee8b0-3159-df19-8a74-c10f8e87ec62@redhat.com> (raw)
In-Reply-To: <20180621124937.166549-1-eblake@redhat.com>
On 06/21/2018 08:49 AM, Eric Blake wrote:
> The NBD spec says that behavior is unspecified if the client
> requests 0 length for block status; but since the structured
> reply is documenting as returning a non-zero length, it's
> easier to just diagnose this with an EINVAL error than to
> figure out what to return.
>
Relevant section:
REQUEST TYPES / NBD_CMD_BLOCK_STATUS (7)
"A block status query request. Length and offset define the range of
interest. The client SHOULD NOT request a status length of 0; the
behavior of a server on such a request is unspecified although the
server SHOULD NOT disconnect."
Leave a little breadcrumb in the commit message because it's headed to
-stable.
> CC: qemu-stable@nongnu.org
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
> nbd/server.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/nbd/server.c b/nbd/server.c
> index 9e1f2271784..493a926e063 100644
> --- a/nbd/server.c
> +++ b/nbd/server.c
> @@ -2007,6 +2007,10 @@ static coroutine_fn int nbd_handle_request(NBDClient *client,
> "discard failed", errp);
>
> case NBD_CMD_BLOCK_STATUS:
> + if (!request->len) {
> + return nbd_send_generic_reply(client, request->handle, -EINVAL,
> + "need non-zero length", errp);
> + }
> if (client->export_meta.valid && client->export_meta.base_allocation) {
> return nbd_co_send_block_status(client, request->handle,
> blk_bs(exp->blk), request->from,
>
Looks correct assuming spec agrees.
Reviewed-by: John Snow <jsnow@redhat.com>
prev parent reply other threads:[~2018-06-21 21:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-21 12:49 [Qemu-devel] [PATCH] nbd/server: Reject 0-length block status request Eric Blake
2018-06-21 12:52 ` Vladimir Sementsov-Ogievskiy
2018-06-21 14:27 ` Eric Blake
2018-06-21 21:35 ` John Snow [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=3f0ee8b0-3159-df19-8a74-c10f8e87ec62@redhat.com \
--to=jsnow@redhat.com \
--cc=eblake@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@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).