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