qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Alex Bligh <alex@alex.org.uk>,
	"Daniel P. Berrange" <berrange@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Kevin Wolf <kwolf@redhat.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: Wouter Verhelst <w@uter.be>, qemu-stable <qemu-stable@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH for-2.6] Fix NBD unsupported options
Date: Tue, 5 Apr 2016 14:09:29 -0600	[thread overview]
Message-ID: <57041B79.9080707@redhat.com> (raw)
In-Reply-To: <1459882500-24316-1-git-send-email-alex@alex.org.uk>

[-- Attachment #1: Type: text/plain, Size: 2333 bytes --]

On 04/05/2016 12:55 PM, Alex Bligh wrote:
> nbd-client.c currently fails to handle unsupported options properly.
> If during option haggling the server finds an option that is
> unsupported, it returns an NBD_REP_ERR_UNSUP reply.
> 
> According to nbd's proto.md, the format for such a reply
> should be:
> 
>   S: 64 bits, 0x3e889045565a9 (magic number for replies)
>   S: 32 bits, the option as sent by the client to which this is a reply
>   S: 32 bits, reply type (e.g., NBD_REP_ACK for successful completion,
>      or NBD_REP_ERR_UNSUP to mark use of an option not known by this server
>   S: 32 bits, length of the reply. This may be zero for some replies,
>      in which case the next field is not sent
>   S: any data as required by the reply (e.g., an export name in the case
>      of NBD_REP_SERVER)
> 
> However, in nbd-client.c, the reply type was being read, and if it
> contained an error, it was bailing out and issuing the next option
> request without first reading the length. This meant that the
> next option / handshake read had an extra 4 bytes of data in it.
> In practice, this makes Qemu incompatible with servers that do not
> support NBD_OPT_LIST.

Or any other option that we are adding; I probably would have hit the
same bug in my work on NBD_OPT_STRUCTURED_REPLY. :)

> 
> To verify this isn't an error in the specification or my reading of
> it, replies are sent by the reference implementation here:
>  https://github.com/yoe/nbd/blob/master/nbd-server.c#L1232

Not a stable link (master moves), but accurate for today.  A stable link
would also peg a particular commit id (7 or so hex digits would be fine:
https://github.com/yoe/nbd/blob/66dfb35/doc/proto.md#L1232


> and as is evident it always sends a 'datasize' (aka length) 32 bit
> word. Unsupported elements are replied to here:
>  https://github.com/yoe/nbd/blob/master/nbd-server.c#L1371
> 
> Signed-off-by: Alex Bligh <alex@alex.org.uk>
> ---
>  nbd/client.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)

Reviewed-by: Eric Blake <eblake@redhat.com>

Counts as a bug fix, so it should be safe even during qemu hard freeze.
 Adding qemu-stable in cc.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


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

  reply	other threads:[~2016-04-05 20:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-05 18:55 [Qemu-devel] [PATCH] Fix NBD unsupported options Alex Bligh
2016-04-05 20:09 ` Eric Blake [this message]
2016-04-06  8:06 ` Paolo Bonzini
2016-04-06 16:14 ` Eric Blake
2016-04-06 16:29   ` Alex Bligh

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=57041B79.9080707@redhat.com \
    --to=eblake@redhat.com \
    --cc=alex@alex.org.uk \
    --cc=berrange@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --cc=w@uter.be \
    /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).