Blame SOURCES/kvm-nbd-server-Reject-0-length-block-status-request.patch

383d26
From 32058dd38df873a275bc004c53b5ae7e74af6871 Mon Sep 17 00:00:00 2001
383d26
From: John Snow <jsnow@redhat.com>
383d26
Date: Wed, 18 Jul 2018 22:54:59 +0200
383d26
Subject: [PATCH 74/89] nbd/server: Reject 0-length block status request
383d26
383d26
RH-Author: John Snow <jsnow@redhat.com>
383d26
Message-id: <20180718225511.14878-24-jsnow@redhat.com>
383d26
Patchwork-id: 81423
383d26
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 23/35] nbd/server: Reject 0-length block status request
383d26
Bugzilla: 1207657
383d26
RH-Acked-by: Eric Blake <eblake@redhat.com>
383d26
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
383d26
RH-Acked-by: Fam Zheng <famz@redhat.com>
383d26
383d26
From: Eric Blake <eblake@redhat.com>
383d26
383d26
The NBD spec says that behavior is unspecified if the client
383d26
requests 0 length for block status; but since the structured
383d26
reply is documenting as returning a non-zero length, it's
383d26
easier to just diagnose this with an EINVAL error than to
383d26
figure out what to return.
383d26
383d26
CC: qemu-stable@nongnu.org
383d26
Signed-off-by: Eric Blake <eblake@redhat.com>
383d26
Message-Id: <20180621124937.166549-1-eblake@redhat.com>
383d26
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
383d26
(cherry picked from commit d8b20291cba6aa9bb295885a34f2b5f05d59d1b2)
383d26
Signed-off-by: John Snow <jsnow@redhat.com>
383d26
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
383d26
---
383d26
 nbd/server.c | 4 ++++
383d26
 1 file changed, 4 insertions(+)
383d26
383d26
diff --git a/nbd/server.c b/nbd/server.c
383d26
index 9e1f227..493a926 100644
383d26
--- a/nbd/server.c
383d26
+++ b/nbd/server.c
383d26
@@ -2007,6 +2007,10 @@ static coroutine_fn int nbd_handle_request(NBDClient *client,
383d26
                                       "discard failed", errp);
383d26
 
383d26
     case NBD_CMD_BLOCK_STATUS:
383d26
+        if (!request->len) {
383d26
+            return nbd_send_generic_reply(client, request->handle, -EINVAL,
383d26
+                                          "need non-zero length", errp);
383d26
+        }
383d26
         if (client->export_meta.valid && client->export_meta.base_allocation) {
383d26
             return nbd_co_send_block_status(client, request->handle,
383d26
                                             blk_bs(exp->blk), request->from,
383d26
-- 
383d26
1.8.3.1
383d26