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