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 v2 3/4] drivers/vhost/blk: hold requests failed with ENOSPC
Date: Tue, 1 Dec 2026 01:16:00 +0000 [thread overview]
Message-ID: <010701a22f2c4847-38bad130-c982-4aca-b188-34cef50a16a0-000000@eu-central-1.amazonses.com> (raw)
In-Reply-To: <20261130162507.1822477-4-alexander.ivanov@virtuozzo.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] vhost-blk: copy_to_user/put_user under held_mutex in
vhost_blk_get_held_reqs()
--
commit 62edbcac7057e5e5f630f73cc2f1f51290486cdd
Author: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
drivers/vhost/blk: hold requests failed with ENOSPC
This commit lets userspace choose, through VHOST_BLK_SET_ERROR_POLICY, whether vhost-blk holds requests that fail with ENOSPC instead of completing them with VIRTIO_BLK_S_IOERR. Held requests are signalled through an eventfd, and VHOST_BLK_GET_HELD_REQS returns them to userspace.
> diff --git a/drivers/vhost/blk.c b/drivers/vhost/blk.c
> --- a/drivers/vhost/blk.c
> +++ b/drivers/vhost/blk.c
[ ... ]
> +static long vhost_blk_get_held_reqs(struct vhost_blk *blk,
> + struct vhost_blk_held_reqs __user *argp)
> +{
> + long ret;
> + u32 nr;
> +
> + ret = vhost_blk_get_held_nr(argp, &nr);
> + if (ret)
> + return ret;
> +
> + mutex_lock(&blk->held_mutex);
> + if (nr < blk->nr_held)
> + ret = -E2BIG;
> + else if (copy_to_user(argp->reqs, blk->held,
> + blk->nr_held * sizeof(*blk->held)))
> + ret = -EFAULT;
> +
> + if (ret != -EFAULT && put_user(blk->nr_held, &argp->nr))
> + ret = -EFAULT;
> + mutex_unlock(&blk->held_mutex);
> +
> + return ret;
> +}
[Severity: Low]
Can the copy_to_user() and put_user() calls here stall the vhost worker? Both can fault and sleep for an unbounded time while held_mutex is held, for example on a userfaultfd-registered or swapped-out buffer.
Meanwhile vhost_blk_handle_host_kick() -> vhost_blk_hold_req() takes the same held_mutex with vq->mutex held. The worker then blocks, and completions on that virtqueue are delayed with it.
Only the device owner can issue this ioctl, so it mostly hurts its own device. Would it be cleaner to snapshot the list under held_mutex and copy to user space after dropping it?
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/20261130162507.1822477-1-alexander.ivanov@virtuozzo.com?part=3
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-12-01 1:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 16:25 [Devel] [PATCH hci-8.2 v2 0/4] drivers/vhost/blk: hold requests failed with ENOSPC until QEMU resubmits them Alexander Ivanov
2026-11-30 16:25 ` [Devel] [PATCH hci-8.2 v2 1/4] drivers/vhost: split the descriptor chain walk out of vhost_get_vq_desc() Alexander Ivanov
2026-12-01 1:11 ` no-reply
2026-11-30 16:25 ` [Devel] [PATCH hci-8.2 v2 2/4] drivers/vhost/blk: split request parsing out of the guest kick handler Alexander Ivanov
2026-12-01 1:11 ` no-reply
2026-11-30 16:25 ` [Devel] [PATCH hci-8.2 v2 3/4] drivers/vhost/blk: hold requests failed with ENOSPC Alexander Ivanov
2026-12-01 1:16 ` no-reply [this message]
2026-12-01 8:16 ` Alexander Ivanov
2026-11-30 16:25 ` [Devel] [PATCH hci-8.2 v2 4/4] drivers/vhost/blk: add the VHOST_BLK_RESUBMIT ioctl Alexander Ivanov
2026-12-01 1:19 ` no-reply
2026-12-01 8:23 ` Alexander Ivanov
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=010701a22f2c4847-38bad130-c982-4aca-b188-34cef50a16a0-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.