vhost-user-blk: Fail gracefully on too large queue size
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
@@ -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
Quoted 9 lines · Kevin Wolf
virtio_add_queue()aborts whenqueue_size>VIRTQUEUE_MAX_SIZE, sovhost_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
Signed-off-by Kevin Wolf <[email protected]>--- hw/block/vhost-user-blk.c | 5 +++++ 1 file changed, 5 insertions(+)
Quoted 9 lines · Kevin Wolf
virtio_add_queue()aborts whenqueue_size>VIRTQUEUE_MAX_SIZE, sovhost_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
Signed-off-by Kevin Wolf <[email protected]>--- hw/block/vhost-user-blk.c | 5 +++++ 1 file changed, 5 insertions(+)
Quoted 20 lines
hw/block/vhost-user-blk.c +5
-0@@ -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
Quoted 9 lines · Kevin Wolf
virtio_add_queue()aborts whenqueue_size>VIRTQUEUE_MAX_SIZE, sovhost_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
Signed-off-by Kevin Wolf <[email protected]>--- hw/block/vhost-user-blk.c | 5 +++++ 1 file changed, 5 insertions(+)
Am 13.04.2021 um 18:56 hat Kevin Wolf geschrieben:
Quoted 11 lines
virtio_add_queue()aborts whenqueue_size>VIRTQUEUE_MAX_SIZE, sovhost_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