]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.9.52/media-uvcvideo-prevent-heap-overflow-when-accessing-mapped-controls.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.9.52 / media-uvcvideo-prevent-heap-overflow-when-accessing-mapped-controls.patch
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
5
6 From: Guenter Roeck <linux@roeck-us.net>
7
8 commit 7e09f7d5c790278ab98e5f2c22307ebe8ad6e8ba upstream.
9
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
13 size.
14
15 Originally-from: Richard Simmons <rssimmo@amazon.com>
16
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>
22
23 ---
24 drivers/media/usb/uvc/uvc_ctrl.c | 7 +++++++
25 1 file changed, 7 insertions(+)
26
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
30 goto done;
31 }
32
33 + /* Validate the user-provided bit-size and offset */
34 + if (mapping->size > 32 ||
35 + mapping->offset + mapping->size > ctrl->info.size * 8) {
36 + ret = -EINVAL;
37 + goto done;
38 + }
39 +
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', "