linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stefano Garzarella <sgarzare@redhat.com>
To: Vincent Whitchurch <vincent.whitchurch@axis.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
	Jason Wang <jasowang@redhat.com>,
	kernel@axis.com, virtualization@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] virtio_vdpa: reject invalid vq indices
Date: Mon, 5 Jul 2021 17:51:33 +0200	[thread overview]
Message-ID: <20210705155133.zas2p4lebsgifz5i@steredhat> (raw)
In-Reply-To: <20210701114652.21956-1-vincent.whitchurch@axis.com>

On Thu, Jul 01, 2021 at 01:46:52PM +0200, Vincent Whitchurch wrote:
>Do not call vDPA drivers' callbacks with vq indicies larger than what
>the drivers indicate that they support.  vDPA drivers do not bounds
>check the indices.
>
>Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
>---
> drivers/virtio/virtio_vdpa.c | 3 +++
> 1 file changed, 3 insertions(+)
>
>diff --git a/drivers/virtio/virtio_vdpa.c b/drivers/virtio/virtio_vdpa.c
>index e28acf482e0c..e9b9dd03f44a 100644
>--- a/drivers/virtio/virtio_vdpa.c
>+++ b/drivers/virtio/virtio_vdpa.c
>@@ -149,6 +149,9 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev, unsigned int index,
> 	if (!name)
> 		return NULL;
>
>+	if (index >= vdpa->nvqs)
>+		return ERR_PTR(-ENOENT);
>+
> 	/* Queue shouldn't already be set up. */
> 	if (ops->get_vq_ready(vdpa, index))
> 		return ERR_PTR(-ENOENT);
>-- 
>2.28.0
>

Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>


      parent reply	other threads:[~2021-07-05 15:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-01 11:46 [PATCH] virtio_vdpa: reject invalid vq indices Vincent Whitchurch
2021-07-02  2:49 ` Jason Wang
2021-07-05 15:51 ` Stefano Garzarella [this message]

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=20210705155133.zas2p4lebsgifz5i@steredhat \
    --to=sgarzare@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=kernel@axis.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=vincent.whitchurch@axis.com \
    --cc=virtualization@lists.linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).