Skip to content

Commit cb5d2c1

Browse files
vwaxmstsirkin
authored andcommitted
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]>
1 parent c8d182b commit cb5d2c1

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/virtio/virtio_vdpa.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ virtio_vdpa_setup_vq(struct virtio_device *vdev, unsigned int index,
151151
if (!name)
152152
return NULL;
153153

154+
if (index >= vdpa->nvqs)
155+
return ERR_PTR(-ENOENT);
156+
154157
/* Queue shouldn't already be set up. */
155158
if (ops->get_vq_ready(vdpa, index))
156159
return ERR_PTR(-ENOENT);

0 commit comments

Comments
 (0)