From: no-reply@sashiko.virtuozzo.com
To: Alexander Ivanov <alexander.ivanov@virtuozzo.com>,
andrey.zhadchenko@virtuozzo.com
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.2 v3 4/4] drivers/vhost/blk: add the VHOST_BLK_RESUBMIT ioctl
Date: Tue, 1 Dec 2026 09:01:57 +0000 [thread overview]
Message-ID: <010701a230d6df05-7cac3ab4-aeb0-4f58-a06b-06b7058fba9e-000000@eu-central-1.amazonses.com> (raw)
In-Reply-To: <20261201085020.1884923-5-alexander.ivanov@virtuozzo.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] vhost-blk: RESUBMIT UAPI error contract does not match the code
- [Low] vhost-blk: RESUBMIT passes -EAGAIN through, undocumented, and
put_user() can mask errno
--
commit 53438eeba5481f2e3e53873a8e09498dc7a3b381
Author: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
drivers/vhost/blk: add the VHOST_BLK_RESUBMIT ioctl
This adds an owner-only ioctl that takes vq and head pairs, such as those
read with VHOST_BLK_GET_HELD_REQS. For each pair it parses the descriptor
chain and submits the request as if it had just been taken from the avail
ring.
> diff --git a/drivers/vhost/blk.c b/drivers/vhost/blk.c
> index c11b5be5d6bf..fcf51aab4203 100644
> --- a/drivers/vhost/blk.c
> +++ b/drivers/vhost/blk.c
[ ... ]
> +static int vhost_blk_resubmit_one(struct vhost_blk *blk,
> + const struct vhost_blk_held_req *r)
> +{
[ ... ]
> + ret = vhost_get_desc_chain(vq, r->head, vq->iov, ARRAY_SIZE(vq->iov),
> + &out, &in, NULL, NULL);
> + if (!ret)
> + ret = vhost_blk_handle_desc(vq, r->head, out, in);
[Severity: Low]
Can -EAGAIN reach userspace here and cause a request to be lost?
vhost_get_desc_chain() returns -EAGAIN on an IOTLB miss, and
vhost_blk_req_submit() returns it when no backend file is found. The kick
handler answers -EAGAIN with vhost_discard_vq_desc() and a requeue. Here
the head is already off the avail ring, so nothing retries it. The UAPI
comment lists -EAGAIN under "any other error", so userspace that follows
it skips to nr + 1 and the guest never gets that head back. Should -EAGAIN
be documented, or handled in the kernel?
> +out:
> + mutex_unlock(&vq->mutex);
> + return ret;
> +}
> +
> +static long vhost_blk_resubmit(struct vhost_blk *blk,
> + struct vhost_blk_held_reqs __user *argp)
> +{
[ ... ]
> + if (ret && put_user(i, &argp->nr))
> + ret = -EFAULT;
> + return ret;
> +}
[Severity: Low]
Also, when put_user() fails here, the real errno is replaced by -EFAULT.
Userspace can then no longer tell why the loop stopped, and it also
loses the index of the failing entry.
[ ... ]
> diff --git a/include/uapi/linux/vhost.h b/include/uapi/linux/vhost.h
> index 21bf6e39a85a..f024c8784974 100644
> --- a/include/uapi/linux/vhost.h
> +++ b/include/uapi/linux/vhost.h
[ ... ]
> + * error and type are ignored, reserved must be 0. On error, nr is set to the
> + * index of the entry that failed; the entries before it were resubmitted.
> + * On -ENOMEM pass the same entry again; -ENODEV and -EINTR fail the rest as
> + * well. Any other error concerns only that entry: the ones after it may still
> + * be passed from nr + 1. Fails with -ENODEV until the backend is set.
[Severity: Low]
As reported by Konstantin Khorenko on v1 [1], does this error contract
match the code? It says -ENODEV fails the rest as well, but
vhost_blk_resubmit_one() checks vhost_vq_get_backend(vq) per virtqueue.
On a multiqueue device where one vq has no backend, entries for the other
vqs can still be resubmitted.
The "any other error concerns only that entry" rule also does not hold
for -EFAULT from copy_from_user() on reqs[i]. The buffer is unreadable,
so continuing from nr + 1 makes no sense. Could the comment state the
real per-errno behaviour?
[1] https://lore.kernel.org/r/179578030084.10258.14556640974201502480.b4-review@b4
Carry the trailer below into the next revision and Sashiko will not review this patch again.
Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com>
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261201085020.1884923-1-alexander.ivanov@virtuozzo.com?part=4
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-12-01 9:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 8:50 [Devel] [PATCH hci-8.2 v3 0/4] drivers/vhost/blk: hold requests failed with ENOSPC until QEMU resubmits them Alexander Ivanov
2026-12-01 8:50 ` [Devel] [PATCH hci-8.2 v3 1/4] drivers/vhost: split the descriptor chain walk out of vhost_get_vq_desc() Alexander Ivanov
2026-12-01 8:50 ` [Devel] [PATCH hci-8.2 v3 2/4] drivers/vhost/blk: split request parsing out of the guest kick handler Alexander Ivanov
2026-12-01 8:50 ` [Devel] [PATCH hci-8.2 v3 3/4] drivers/vhost/blk: hold requests failed with ENOSPC Alexander Ivanov
2026-12-01 8:56 ` no-reply
2026-12-01 9:19 ` Konstantin Khorenko
2026-12-01 11:25 ` Alexander Ivanov
2026-12-01 8:50 ` [Devel] [PATCH hci-8.2 v3 4/4] drivers/vhost/blk: add the VHOST_BLK_RESUBMIT ioctl Alexander Ivanov
2026-12-01 9:01 ` no-reply [this message]
2026-12-01 11:14 ` Alexander Ivanov
2026-12-01 9:19 ` Konstantin Khorenko
2026-12-01 11:16 ` Alexander Ivanov
2026-12-01 9:19 ` [Devel] [PATCH hci-8.2 v3 0/4] drivers/vhost/blk: hold requests failed with ENOSPC until QEMU resubmits them 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=010701a230d6df05-7cac3ab4-aeb0-4f58-a06b-06b7058fba9e-000000@eu-central-1.amazonses.com \
--to=no-reply@sashiko.virtuozzo.com \
--cc=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.