]> git.baikalelectronics.ru Git - kernel.git/commitdiff
media: uvcvideo: Fix OOB read
authorRicardo Ribalda <ribalda@chromium.org>
Thu, 20 Jul 2023 17:46:54 +0000 (17:46 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Oct 2023 12:57:04 +0000 (14:57 +0200)
commit 41ebaa5e0eebea4c3bac96b72f9f8ae0d77c0bdb upstream.

If the index provided by the user is bigger than the mask size, we might do
an out of bound read.

CC: stable@kernel.org
Fixes: 40140eda661e ("media: uvcvideo: Implement mask for V4L2_CTRL_TYPE_MENU")
Reported-by: Zubin Mithra <zsm@chromium.org>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/media/usb/uvc/uvc_ctrl.c

index 067b43a1cb3eb5a132069a87d51caaf0be5ffa2e..6d7535efc09de35c79e1d10c8648fa6f9735470c 100644 (file)
@@ -1347,6 +1347,9 @@ int uvc_query_v4l2_menu(struct uvc_video_chain *chain,
        query_menu->id = id;
        query_menu->index = index;
 
+       if (index >= BITS_PER_TYPE(mapping->menu_mask))
+               return -EINVAL;
+
        ret = mutex_lock_interruptible(&chain->ctrl_mutex);
        if (ret < 0)
                return -ERESTARTSYS;