[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250414123119-mutt-send-email-mst@kernel.org>
Date: Mon, 14 Apr 2025 12:32:29 -0400
From: "Michael S. Tsirkin" <mst@...hat.com>
To: Dongli Zhang <dongli.zhang@...cle.com>
Cc: virtualization@...ts.linux.dev, kvm@...r.kernel.org,
netdev@...r.kernel.org, jasowang@...hat.com,
michael.christie@...cle.com, pbonzini@...hat.com,
stefanha@...hat.com, eperezma@...hat.com, joao.m.martins@...cle.com,
joe.jin@...cle.com, si-wei.liu@...cle.com,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 9/9] vhost: add WARNING if log_num is more than limit
On Wed, Apr 02, 2025 at 11:29:54PM -0700, Dongli Zhang wrote:
> Since long time ago, the only user of vq->log is vhost-net. The concern is
> to add support for more devices (i.e. vhost-scsi or vsock) may reveals
> unknown issue in the vhost API. Add a WARNING.
>
> Suggested-by: Joao Martins <joao.m.martins@...cle.com>
> Signed-off-by: Dongli Zhang <dongli.zhang@...cle.com>
Userspace can trigger this I think, this is a problem since
people run with reboot on warn.
Pls grammar issues in comments... I don't think so.
> ---
> drivers/vhost/vhost.c | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
> diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
> index 494b3da5423a..b7d51d569646 100644
> --- a/drivers/vhost/vhost.c
> +++ b/drivers/vhost/vhost.c
> @@ -2559,6 +2559,15 @@ static int get_indirect(struct vhost_virtqueue *vq,
> if (access == VHOST_ACCESS_WO) {
> *in_num += ret;
> if (unlikely(log && ret)) {
> + /*
> + * Since long time ago, the only user of
> + * vq->log is vhost-net. The concern is to
> + * add support for more devices (i.e.
> + * vhost-scsi or vsock) may reveals unknown
> + * issue in the vhost API. Add a WARNING.
> + */
> + WARN_ON_ONCE(*log_num >= vq->dev->iov_limit);
> +
> log[*log_num].addr = vhost64_to_cpu(vq, desc.addr);
> log[*log_num].len = vhost32_to_cpu(vq, desc.len);
> ++*log_num;
> @@ -2679,6 +2688,15 @@ int vhost_get_vq_desc(struct vhost_virtqueue *vq,
> * increment that count. */
> *in_num += ret;
> if (unlikely(log && ret)) {
> + /*
> + * Since long time ago, the only user of
> + * vq->log is vhost-net. The concern is to
> + * add support for more devices (i.e.
> + * vhost-scsi or vsock) may reveals unknown
> + * issue in the vhost API. Add a WARNING.
> + */
> + WARN_ON_ONCE(*log_num >= vq->dev->iov_limit);
> +
> log[*log_num].addr = vhost64_to_cpu(vq, desc.addr);
> log[*log_num].len = vhost32_to_cpu(vq, desc.len);
> ++*log_num;
> --
> 2.39.3
Powered by blists - more mailing lists