cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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