Skip to content

Commit

Permalink
virtio_vdpa: reject invalid vq indices
Browse files Browse the repository at this point in the history
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>
Link: https://lore.kernel.org/r/20210701114652.21956-1-vincent.whitchurch@axis.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
  • Loading branch information
vwax authored and mstsirkin committed Aug 11, 2021
1 parent c8d182b commit cb5d2c1
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/virtio/virtio_vdpa.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit cb5d2c1

Please sign in to comment.