diff options
author | Vincent Whitchurch <[email protected]> | 2021-07-01 13:46:52 +0200 |
---|---|---|
committer | Michael S. Tsirkin <[email protected]> | 2021-08-11 06:44:23 -0400 |
commit | cb5d2c1f6cc0e5769099a7d44b9d08cf58cae206 (patch) | |
tree | da27808259b428408a686df937051774cee91d6d | |
parent | c8d182bd387a09a8b95303c8086238e8bf61fcfc (diff) |
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 <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Michael S. Tsirkin <[email protected]>
Acked-by: Jason Wang <[email protected]>
Reviewed-by: Stefano Garzarella <[email protected]>
-rw-r--r-- | drivers/virtio/virtio_vdpa.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/virtio/virtio_vdpa.c b/drivers/virtio/virtio_vdpa.c index e1a141135992..72eaef2caeb1 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); |