From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45553) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoD95-0003p8-FO for qemu-devel@nongnu.org; Thu, 07 Apr 2016 12:51:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aoD94-0001br-KO for qemu-devel@nongnu.org; Thu, 07 Apr 2016 12:51:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54262) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aoD94-0001bk-Em for qemu-devel@nongnu.org; Thu, 07 Apr 2016 12:51:02 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 114E13B753 for ; Thu, 7 Apr 2016 16:51:02 +0000 (UTC) From: Paolo Bonzini Date: Thu, 7 Apr 2016 18:50:39 +0200 Message-Id: <1460047845-14488-10-git-send-email-pbonzini@redhat.com> In-Reply-To: <1460047845-14488-1-git-send-email-pbonzini@redhat.com> References: <1460047845-14488-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 09/15] 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 From: Eric Blake 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. Signed-off-by: Eric Blake Message-Id: <1459982918-32229-1-git-send-email-eblake@redhat.com> Signed-off-by: Paolo Bonzini --- nbd/server.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nbd/server.c b/nbd/server.c index 6d9c15a..2a4dd10 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -483,9 +483,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) != length) { + return -EIO; + } nbd_negotiate_send_rep(client->ioc, NBD_REP_ERR_UNSUP, clientflags); - return -EINVAL; + break; } } else { /* -- 2.5.5