|
|
a83cc2 |
From bb551b71851c8d5a37b29aae373a99e97885a4df Mon Sep 17 00:00:00 2001
|
|
|
a83cc2 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
a83cc2 |
Date: Mon, 12 Jul 2021 10:22:25 -0400
|
|
|
a83cc2 |
Subject: [PATCH 05/43] vhost-user-blk: Fail gracefully on too large queue size
|
|
|
a83cc2 |
MIME-Version: 1.0
|
|
|
a83cc2 |
Content-Type: text/plain; charset=UTF-8
|
|
|
a83cc2 |
Content-Transfer-Encoding: 8bit
|
|
|
a83cc2 |
|
|
|
a83cc2 |
RH-Author: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
a83cc2 |
RH-Bugzilla: 1957194
|
|
|
a83cc2 |
|
|
|
a83cc2 |
virtio_add_queue() aborts when queue_size > VIRTQUEUE_MAX_SIZE, so
|
|
|
a83cc2 |
vhost_user_blk_device_realize() should check this before calling it.
|
|
|
a83cc2 |
|
|
|
a83cc2 |
Simple reproducer:
|
|
|
a83cc2 |
|
|
|
a83cc2 |
qemu-system-x86_64 \
|
|
|
a83cc2 |
-chardev null,id=foo \
|
|
|
a83cc2 |
-device vhost-user-blk-pci,queue-size=4096,chardev=foo
|
|
|
a83cc2 |
|
|
|
a83cc2 |
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1935014
|
|
|
a83cc2 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
a83cc2 |
Message-Id: <20210413165654.50810-1-kwolf@redhat.com>
|
|
|
a83cc2 |
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
a83cc2 |
Reviewed-by: Raphael Norwitz <raphael.norwitz@nutanix.com>
|
|
|
a83cc2 |
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
a83cc2 |
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
|
|
|
a83cc2 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
a83cc2 |
(cherry picked from commit 68bf7336533faa6aa90fdd4558edddbf5d8ef814)
|
|
|
a83cc2 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
a83cc2 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
a83cc2 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
a83cc2 |
---
|
|
|
a83cc2 |
hw/block/vhost-user-blk.c | 5 +++++
|
|
|
a83cc2 |
1 file changed, 5 insertions(+)
|
|
|
a83cc2 |
|
|
|
a83cc2 |
diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c
|
|
|
a83cc2 |
index 0b5b9d44cd..f5e9682703 100644
|
|
|
a83cc2 |
--- a/hw/block/vhost-user-blk.c
|
|
|
a83cc2 |
+++ b/hw/block/vhost-user-blk.c
|
|
|
a83cc2 |
@@ -467,6 +467,11 @@ static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp)
|
|
|
a83cc2 |
error_setg(errp, "vhost-user-blk: queue size must be non-zero");
|
|
|
a83cc2 |
return;
|
|
|
a83cc2 |
}
|
|
|
a83cc2 |
+ if (s->queue_size > VIRTQUEUE_MAX_SIZE) {
|
|
|
a83cc2 |
+ error_setg(errp, "vhost-user-blk: queue size must not exceed %d",
|
|
|
a83cc2 |
+ VIRTQUEUE_MAX_SIZE);
|
|
|
a83cc2 |
+ return;
|
|
|
a83cc2 |
+ }
|
|
|
a83cc2 |
|
|
|
a83cc2 |
if (!vhost_user_init(&s->vhost_user, &s->chardev, errp)) {
|
|
|
a83cc2 |
return;
|
|
|
a83cc2 |
--
|
|
|
a83cc2 |
2.27.0
|
|
|
a83cc2 |
|