From: Vincent Whitchurch Date: Thu, 1 Jul 2021 11:46:52 +0000 (+0200) Subject: virtio_vdpa: reject invalid vq indices X-Git-Tag: v5.15~554^2~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cb5d2c1f6cc0e5769099a7d44b9d08cf58cae206;p=platform%2Fkernel%2Flinux-starfive.git virtio_vdpa: reject invalid vq indices 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 Link: https://lore.kernel.org/r/20210701114652.21956-1-vincent.whitchurch@axis.com Signed-off-by: Michael S. Tsirkin Acked-by: Jason Wang Reviewed-by: Stefano Garzarella --- diff --git a/drivers/virtio/virtio_vdpa.c b/drivers/virtio/virtio_vdpa.c index e1a1411..72eaef2 100644 --- a/drivers/virtio/virtio_vdpa.c +++ b/drivers/virtio/virtio_vdpa.c @@ -151,6 +151,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);