All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
From: Konstantin Khorenko <khorenko@virtuozzo.com>
Subject: [Devel] [PATCH RHEL10 COMMIT] drivers/vhost/blk: harden get_id command
Date: Tue, 25 Aug 2026 15:56:57 +0200	[thread overview]
Message-ID: <202608251356.67PDuvHW802992@f0.sw.ru> (raw)
In-Reply-To: <20260825125152.259376-2-andrey.zhadchenko@virtuozzo.com>

The commit is pushed to "branch-rh10-6.12.0-211.39.1.16.x.vz10-ovz" and will appear at git at bitbucket.org:openvz/vzkernel.git
after rh10-6.12.0-211.39.1.16.9.vz10
------>
commit 052898980e0330e6cc936ebf0f937d2431cdee61
Author: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
Date:   Tue Aug 25 15:51:48 2026 +0300

    drivers/vhost/blk: harden get_id command
    
    A defensive patch.
    QEMU is fine with reporting empty serial and including null
    terminator. So we will do the same.
    
    https://virtuozzo.atlassian.net/browse/VSTOR-138640
    Feature: vhost-blk: in-kernel accelerator for virtio-blk guests
    Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko@virtuozzo.com>
    Reviewed-by: Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
    Reviewed-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 drivers/vhost/blk.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/vhost/blk.c b/drivers/vhost/blk.c
index dac03566bfca5..edd3e75873ff5 100644
--- a/drivers/vhost/blk.c
+++ b/drivers/vhost/blk.c
@@ -105,8 +105,6 @@ struct vhost_blk {
 	pid_t owner_pid;
 };
 
-static int gen;
-
 static int move_iovec(struct iovec *from, struct iovec *to,
 		      size_t len, int iov_count_from, int iov_count_to)
 {
@@ -491,7 +489,9 @@ static int vhost_blk_req_handle(struct vhost_virtqueue *vq,
 		ret = vhost_blk_req_submit(req);
 		break;
 	case VIRTIO_BLK_T_GET_ID:
-		len = strnlen(blk->serial, VIRTIO_BLK_ID_BYTES);
+		len = min_t(size_t,
+			    strnlen(blk->serial, VIRTIO_BLK_ID_BYTES) + 1,
+			    min_t(size_t, req->len, VIRTIO_BLK_ID_BYTES));
 		iov_iter_init(&iter, ITER_DEST, req->iov, req->iov_nr, req->len);
 		ret = copy_to_iter(blk->serial, len, &iter);
 		status = ret != len ? VIRTIO_BLK_S_IOERR : VIRTIO_BLK_S_OK;
@@ -688,7 +688,6 @@ static int vhost_blk_open(struct inode *inode, struct file *file)
 	}
 
 	memset(blk->serial, 0, sizeof(blk->serial));
-	snprintf(blk->serial, VIRTIO_BLK_ID_BYTES, "vhost-blk%d", gen++);
 
 	atomic_set(&blk->req_inflight[0], 0);
 	atomic_set(&blk->req_inflight[1], 0);

  reply	other threads:[~2026-08-25 13:56 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-25 12:51 [Devel] [PATCH VZ10 v3 0/5] vhost-blk: fix protocol handling and backend setup Andrey Zhadchenko
2026-08-25 12:51 ` [Devel] [PATCH VZ10 v3 1/5] drivers/vhost/blk: harden get_id command Andrey Zhadchenko
2026-08-25 13:56   ` Konstantin Khorenko [this message]
2026-08-25 12:51 ` [Devel] [PATCH VZ10 v3 2/5] drivers/vhost/blk: report correct used-ring lengths Andrey Zhadchenko
2026-08-25 13:56   ` [Devel] [PATCH RHEL10 COMMIT] " Konstantin Khorenko
2026-08-25 12:51 ` [Devel] [PATCH VZ10 v3 3/5] drivers/vhost/blk: fix flush support Andrey Zhadchenko
2026-08-25 13:56   ` [Devel] [PATCH RHEL10 COMMIT] " Konstantin Khorenko
2026-08-25 12:51 ` [Devel] [PATCH VZ10 v3 4/5] drivers/vhost/blk: fix sector alignment calculation Andrey Zhadchenko
2026-08-25 13:56   ` [Devel] [PATCH RHEL10 COMMIT] " Konstantin Khorenko
2026-08-25 12:51 ` [Devel] [PATCH VZ10 v3 5/5] drivers/vhost/blk: rework queue/backend setup Andrey Zhadchenko
2026-08-25 13:22   ` Konstantin Khorenko
2026-08-25 13:27     ` Andrey Zhadchenko
2026-08-25 13:42   ` Konstantin Khorenko
2026-08-25 13:57   ` [Devel] [PATCH RHEL10 COMMIT] " Konstantin Khorenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202608251356.67PDuvHW802992@f0.sw.ru \
    --to=khorenko@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.