1 From 7e09f7d5c790278ab98e5f2c22307ebe8ad6e8ba Mon Sep 17 00:00:00 2001
2 From: Guenter Roeck <linux@roeck-us.net>
3 Date: Tue, 8 Aug 2017 08:56:21 -0400
4 Subject: media: uvcvideo: Prevent heap overflow when accessing mapped controls
6 From: Guenter Roeck <linux@roeck-us.net>
8 commit 7e09f7d5c790278ab98e5f2c22307ebe8ad6e8ba upstream.
10 The size of uvc_control_mapping is user controlled leading to a
11 potential heap overflow in the uvc driver. This adds a check to verify
12 the user provided size fits within the bounds of the defined buffer
15 Originally-from: Richard Simmons <rssimmo@amazon.com>
17 Signed-off-by: Guenter Roeck <linux@roeck-us.net>
18 Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
19 Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
20 Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
21 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
24 drivers/media/usb/uvc/uvc_ctrl.c | 7 +++++++
25 1 file changed, 7 insertions(+)
27 --- a/drivers/media/usb/uvc/uvc_ctrl.c
28 +++ b/drivers/media/usb/uvc/uvc_ctrl.c
29 @@ -2002,6 +2002,13 @@ int uvc_ctrl_add_mapping(struct uvc_vide
33 + /* Validate the user-provided bit-size and offset */
34 + if (mapping->size > 32 ||
35 + mapping->offset + mapping->size > ctrl->info.size * 8) {
40 list_for_each_entry(map, &ctrl->info.mappings, list) {
41 if (mapping->id == map->id) {
42 uvc_trace(UVC_TRACE_CONTROL, "Can't add mapping '%s', "