[Devel] [PATCH hci-8.1] drivers/vhost/blk: fail guest writes to a read-only backend
no-reply at sashiko.virtuozzo.com
no-reply at sashiko.virtuozzo.com
Wed Oct 28 12:39:23 MSK 2026
> When a disk is attached read-only, QEMU opens the backing block device
> O_RDONLY and advertises VIRTIO_BLK_F_RO. vhost_blk_set_backend() checks
> only that the fd is a block device, and requests are submitted as bios
> straight to the bdev, so a guest that ignores VIRTIO_BLK_F_RO and sends
> VIRTIO_BLK_T_OUT gets VIRTIO_BLK_S_OK and modifies the disk.
>
> Complete VIRTIO_BLK_T_OUT with VIRTIO_BLK_S_IOERR when the backend file
> lacks FMODE_WRITE or the bdev itself is read-only, as the userspace
> virtio-blk device does. The bdev is checked per request since it can be
> switched read-only at runtime. Flush stays allowed: it does not modify
> data.
>
> Fixes: d8722ff88c5d ("drivers/vhost: vhost-blk accelerator for virtio-blk guests")
> https://virtuozzo.atlassian.net/browse/VSTOR-152127
> Feature: vhost-blk: in-kernel accelerator for virtio-blk guests
>
> Signed-off-by: Alexander Ivanov <alexander.ivanov at virtuozzo.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261028093536.3072110-1-alexander.ivanov@virtuozzo.com?part=1
More information about the Devel
mailing list