[Devel] [PATCH RHEL10 COMMIT] drivers/vhost/blk: fail request instead of BUG_ON()

Konstantin Khorenko khorenko at virtuozzo.com
Fri Jun 19 19:36:09 MSK 2026


The commit is pushed to "branch-rh10-6.12.0-211.16.1.12.x.vz10-ovz" and will appear at git at bitbucket.org:openvz/vzkernel.git
after rh10-6.12.0-211.16.1.12.4.vz10
------>
commit d944bdf8ed03cb3741ad0bd7c4bf3908698ea7bf
Author: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
Date:   Fri Jun 19 16:33:12 2026 +0300

    drivers/vhost/blk: fail request instead of BUG_ON()
    
    if the request has some misaligned buffers in-between. After all
    why would we crash the host if one of the guests is crazy.
    
    https://virtuozzo.atlassian.net/browse/VSTOR-134034
    Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
    
    ======
    Patchset description:
    vhost-blk: handling of failing requests
    
    This series mainly addresses the handling of failing requests.
    Previously the driver will always retry all requests failed at
    processing and will always complete the requests if they are
    past bio submission point.
    
    Using vhost-net and vhost-scsi as a model, we adopt the following
    approach:
     - requests failed at processing phase with ENOMEM/EAGAIN are re-tried
     - requests failed at processing phase with other errors are not
    reported completed and are not processed further. It is higly likely
    they are just incorrect
     - requests failed at status write after the completion are not
    reported completed
    
    This may sometime lead to guests stalling, but the alternatives are
    always worse.
    
    Also the patchset improves logging and adds a few sanity checks.
    
    Feature: vhost-blk: in-kernel accelerator for virtio-blk guests
    Reviewed-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 drivers/vhost/blk.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/vhost/blk.c b/drivers/vhost/blk.c
index cdc82a8961870..00101816e7694 100644
--- a/drivers/vhost/blk.c
+++ b/drivers/vhost/blk.c
@@ -338,7 +338,11 @@ static int vhost_blk_bio_make(struct vhost_blk_req *req,
 	nr_pages = bio_iov_vecs_to_alloc(&iter, BIO_MAX_VECS);
 	do {
 		/* We can't handle next bio if it's start is not sector aligned */
-		BUG_ON(pos & SECTOR_MASK);
+		if (pos & SECTOR_MASK) {
+			WARN_ONCE(1, "vhost-blk: guest provided unaligned buffers");
+			ret = -EINVAL;
+			goto err_bio;
+		}
 
 		bio = bio_alloc(bdev, nr_pages,	req->bi_opf, GFP_KERNEL);
 		if (!bio) {


More information about the Devel mailing list