From: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
To: andrey.zhadchenko@virtuozzo.com
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.1 v2 1/3] drivers/vhost/blk: convert virtio_blk_outhdr fields to CPU byte order
Date: Thu, 29 Oct 2026 13:59:21 +0100 [thread overview]
Message-ID: <20261029125923.3352735-2-alexander.ivanov@virtuozzo.com> (raw)
In-Reply-To: <20261029125923.3352735-1-alexander.ivanov@virtuozzo.com>
hdr->type and hdr->sector are __virtio32 and __virtio64 but were used
without conversion. Since VIRTIO_F_VERSION_1 is offered, on a big-endian
host with a little-endian guest the request header was misinterpreted.
Convert both with vhost32_to_cpu()/vhost64_to_cpu() once, when the
request is set up.
https://virtuozzo.atlassian.net/browse/VSTOR-142755
Fixes: 1629db092dd7 ("drivers/vhost: vhost-blk accelerator for virtio-blk guests")
Feature: vhost-blk: in-kernel accelerator for virtio-blk guests
Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
---
drivers/vhost/blk.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/vhost/blk.c b/drivers/vhost/blk.c
index b170439a1806..7234213924d5 100644
--- a/drivers/vhost/blk.c
+++ b/drivers/vhost/blk.c
@@ -454,16 +454,18 @@ static int vhost_blk_req_handle(struct vhost_virtqueue *vq,
struct iov_iter iter;
size_t in_len;
int ret, len;
+ u32 type;
u8 status;
req = &blk_vq->req[head];
req->blk_vq = blk_vq;
req->head = head;
req->blk = blk;
- req->sector = hdr->sector;
+ req->sector = vhost64_to_cpu(vq, hdr->sector);
req->iov = blk_vq->iov;
req->bio_err = 0;
in_len = iov_length(vq->iov + out, in);
+ type = vhost32_to_cpu(vq, hdr->type);
if (in_len < sizeof(status) || in_len > INT_MAX)
return -EINVAL;
@@ -478,7 +480,7 @@ static int vhost_blk_req_handle(struct vhost_virtqueue *vq,
if (ret < 0 || req->iov_nr < 0)
return -EINVAL;
- switch (hdr->type) {
+ switch (type) {
case VIRTIO_BLK_T_OUT:
req->bi_opf = REQ_OP_WRITE;
ret = vhost_blk_req_submit(req);
--
2.53.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-10-29 13:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-29 12:59 [Devel] [PATCH hci-8.1 v2 0/3] drivers/vhost/blk: fix virtio-blk request header and payload parsing Alexander Ivanov
2026-10-29 12:59 ` Alexander Ivanov [this message]
2026-10-29 13:03 ` [Devel] [PATCH hci-8.1 v2 1/3] drivers/vhost/blk: convert virtio_blk_outhdr fields to CPU byte order no-reply
2026-10-29 12:59 ` [Devel] [PATCH hci-8.1 v2 2/3] drivers/vhost/blk: take virtio_blk_outhdr only from the readable part Alexander Ivanov
2026-10-29 13:02 ` no-reply
2026-10-29 12:59 ` [Devel] [PATCH hci-8.1 v2 3/3] drivers/vhost/blk: take req->len from one side of the descriptor chain Alexander Ivanov
2026-10-29 13:02 ` no-reply
2026-10-29 13:25 ` [Devel] [PATCH hci-8.1 v2 0/3] drivers/vhost/blk: fix virtio-blk request header and payload parsing 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=20261029125923.3352735-2-alexander.ivanov@virtuozzo.com \
--to=alexander.ivanov@virtuozzo.com \
--cc=andrey.zhadchenko@virtuozzo.com \
--cc=devel@openvz.org \
/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.