Skip to contentSkip to conversation

vhost-user-blk: Fail gracefully on too large queue size

PATCH In review Kevin Wolf 4 participants 5 messages Apr 13, 2021 – Apr 30, 2021

lore
Share & tools
lore

Kevin Wolf

author
#0 lore raw

PATCH v2 1/1 vhost-user-blk: Fail gracefully on too large queue size

virtio_add_queue() aborts when queue_size > VIRTQUEUE_MAX_SIZE, so vhost_user_blk_device_realize() should check this before calling it.

Simple reproducer:

qemu-system-x86_64 \
    -chardev null,id=foo \
    -device vhost-user-blk-pci,queue-size=4096,chardev=foo
---
 hw/block/vhost-user-blk.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/block/vhost-user-blk.c +5 -0
index 0b5b9d44cd..f5e9682703 100644
@@ -467,6 +467,11 @@ static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp)
         error_setg(errp, "vhost-user-blk: queue size must be non-zero");
         return;
     }
+    if (s->queue_size > VIRTQUEUE_MAX_SIZE) {
+        error_setg(errp, "vhost-user-blk: queue size must not exceed %d",
+                   VIRTQUEUE_MAX_SIZE);
+        return;
+    }
 
     if (!vhost_user_init(&s->vhost_user, &s->chardev, errp)) {
         return;
Signature · 1 line
2.30.2
Reviewed-by Tested-by on v2 1/1
#1 lore raw
Quoted 9 lines · Kevin Wolf

virtio_add_queue() aborts when queue_size > VIRTQUEUE_MAX_SIZE, so vhost_user_blk_device_realize() should check this before calling it.

Simple reproducer:

qemu-system-x86_64 \
    -chardev null,id=foo \
    -device vhost-user-blk-pci,queue-size=4096,chardev=foo
Quoted 5 lines
---
 hw/block/vhost-user-blk.c | 5 +++++
 1 file changed, 5 insertions(+)
Reviewed-by on v2 1/1
#2 lore raw
In reply to Kevin Wolf
Quoted 9 lines · Kevin Wolf

virtio_add_queue() aborts when queue_size > VIRTQUEUE_MAX_SIZE, so vhost_user_blk_device_realize() should check this before calling it.

Simple reproducer:

qemu-system-x86_64 \
    -chardev null,id=foo \
    -device vhost-user-blk-pci,queue-size=4096,chardev=foo
Quoted 5 lines
---
 hw/block/vhost-user-blk.c | 5 +++++
 1 file changed, 5 insertions(+)
Quoted 20 lines
hw/block/vhost-user-blk.c +5 -0
index 0b5b9d44cd..f5e9682703 100644
@@ -467,6 +467,11 @@ static void vhost_user_blk_device_realize(DeviceState *dev, Error **errp)
         error_setg(errp, "vhost-user-blk: queue size must be non-zero");
         return;
     }
+    if (s->queue_size > VIRTQUEUE_MAX_SIZE) {
+        error_setg(errp, "vhost-user-blk: queue size must not exceed %d",
+                   VIRTQUEUE_MAX_SIZE);
+        return;
+    }
 
     if (!vhost_user_init(&s->vhost_user, &s->chardev, errp)) {
         return;
Signature · 1 line
2.30.2
Reviewed-by on v2 1/1
#3 lore raw
In reply to Kevin Wolf
Quoted 9 lines · Kevin Wolf

virtio_add_queue() aborts when queue_size > VIRTQUEUE_MAX_SIZE, so vhost_user_blk_device_realize() should check this before calling it.

Simple reproducer:

qemu-system-x86_64 \
    -chardev null,id=foo \
    -device vhost-user-blk-pci,queue-size=4096,chardev=foo
Quoted 5 lines
---
 hw/block/vhost-user-blk.c | 5 +++++
 1 file changed, 5 insertions(+)
author
#4 lore raw
In reply to Kevin Wolf

Am 13.04.2021 um 18:56 hat Kevin Wolf geschrieben:

Quoted 11 lines

virtio_add_queue() aborts when queue_size > VIRTQUEUE_MAX_SIZE, so vhost_user_blk_device_realize() should check this before calling it.

Simple reproducer:

qemu-system-x86_64 \
    -chardev null,id=foo \
    -device vhost-user-blk-pci,queue-size=4096,chardev=foo

Thanks for the review, applied to the block branch.

Kevin