[PATCH] virtio_vdpa: reject invalid vq indices

Subsystems: the rest, virtio core

STALE1904d LANDED

Landed in mainline as cb5d2c1f6cc0 on 2021-08-11.

3 messages, 3 authors, 2021-07-05 · open the first message on its own page

[PATCH] virtio_vdpa: reject invalid vq indices

From: Vincent Whitchurch <hidden>
Date: 2021-07-01 11:46:57

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 <redacted>
---
 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

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Re: [PATCH] virtio_vdpa: reject invalid vq indices

From: Jason Wang <hidden>
Date: 2021-07-02 03:01:38

在 2021/7/1 下午7:46, Vincent Whitchurch 写道:
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 <redacted>

Acked-by: Jason Wang <redacted>

quoted hunk
---
  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);
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Re: [PATCH] virtio_vdpa: reject invalid vq indices

From: Stefano Garzarella <sgarzare@redhat.com>
Date: 2021-07-05 15:51:41

On Thu, Jul 01, 2021 at 01:46:52PM +0200, Vincent Whitchurch wrote:
quoted hunk
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 <redacted>
---
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>

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help