From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51471) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ap1Zd-0007Na-52 for qemu-devel@nongnu.org; Sat, 09 Apr 2016 18:41:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ap1ZZ-0008G8-V6 for qemu-devel@nongnu.org; Sat, 09 Apr 2016 18:41:49 -0400 References: <1459961962-18771-1-git-send-email-eblake@redhat.com> <1459982918-32229-1-git-send-email-eblake@redhat.com> From: Eric Blake Message-ID: <57098528.7040008@redhat.com> Date: Sat, 9 Apr 2016 16:41:44 -0600 MIME-Version: 1.0 In-Reply-To: <1459982918-32229-1-git-send-email-eblake@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="7RmFWUW6XWwRldQk3MV847It1gbd2cw1n" Subject: Re: [Qemu-devel] [PATCH v2 2/1 for-2.6] nbd: Don't kill server when client requests unknown option List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, alex@alex.org.uk, qemu-stable This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --7RmFWUW6XWwRldQk3MV847It1gbd2cw1n Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Adding qemu-stable; this fix needs to be backported to 2.5.x stable series (in the file ./nbd.c at the time), if we want to be able to allow a 2.7 client to connect to a 2.5 server. On 04/06/2016 04:48 PM, Eric Blake wrote: > nbd-server.c currently fails to handle unsupported options properly. > If during option haggling the client sends an unknown request, the > server kills the connection instead of letting the client try to > fall back to something older. This is precisely what advertising > NBD_FLAG_FIXED_NEWSTYLE was supposed to fix. >=20 > Signed-off-by: Eric Blake > --- >=20 > Turns out our server has a very similar bug to the client. > If desired, I can spin a v3 that moves the hunk in nbd/client.c > to the previous patch. >=20 > nbd/client.c | 2 ++ > nbd/server.c | 5 ++++- > 2 files changed, 6 insertions(+), 1 deletion(-) >=20 > diff --git a/nbd/client.c b/nbd/client.c > index 67116b9..fc382c5 100644 > --- a/nbd/client.c > +++ b/nbd/client.c > @@ -109,6 +109,8 @@ static int nbd_handle_reply_err(QIOChannel *ioc, ui= nt32_t opt, uint32_t type, >=20 > switch (type) { > case NBD_REP_ERR_UNSUP: > + TRACE("server doesn't understand request %d, attempting fallba= ck", > + opt); > result =3D 0; > goto cleanup; >=20 > diff --git a/nbd/server.c b/nbd/server.c > index b95571b..7843584 100644 > --- a/nbd/server.c > +++ b/nbd/server.c > @@ -482,9 +482,12 @@ static int nbd_negotiate_options(NBDClient *client= ) > return -EINVAL; > default: > TRACE("Unsupported option 0x%x", clientflags); > + if (nbd_negotiate_drop_sync(client->ioc, length) !=3D = length) { > + return -EIO; > + } > nbd_negotiate_send_rep(client->ioc, NBD_REP_ERR_UNSUP,= > clientflags); > - return -EINVAL; > + break; > } > } else { > /* >=20 --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --7RmFWUW6XWwRldQk3MV847It1gbd2cw1n Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJXCYUoAAoJEKeha0olJ0NqZIgH/1Knar80LrIaCwFT6sgtXHSq ZjmOsx5jKQBxcW2JtJRFR7rlwwoMdfDfGzeRzaR2sVe4iCpcP0w6N/puGa9lfyFM 8NiHbWk/n8s3GaU2kYQM3DkwCPhJ3Ng5Qt/ogVP8qFljrAr7TXkGncw1sLS8jYFU dRnraohusy56WC4eiZLso8RJ9JdyDiCf0FlS6zYDSvFj+65BLk6PWSWNd9t3j6Ii Y0M3cENLp1xiSG/iG8yxwa1crzVJ5zmMWt2Eheftkn2d+sFw+95gnwT9JZHFHoM6 F8G4mxug4MZpzoepOVtySyk4gweNEJHAnaMiA37UR8m/CQRtCR/h9GBUSfaDR/8= =ExiN -----END PGP SIGNATURE----- --7RmFWUW6XWwRldQk3MV847It1gbd2cw1n--