[Devel] [PATCH VZ10 v2 6/7] drivers/vhost/blk: fail request instead of BUG_ON()

Andrey Zhadchenko andrey.zhadchenko at virtuozzo.com
Fri Jun 19 16:33:12 MSK 2026


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>
---
 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) {
-- 
2.43.5



More information about the Devel mailing list