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

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