[CVE-2017-0627][Trusty][SRU][PATCH 1/1] media: uvcvideo: Prevent heap overflow when accessing mapped controls

Po-Hsu Lin po-hsu.lin at canonical.com
Tue May 8 07:57:47 UTC 2018


From: Guenter Roeck <linux at roeck-us.net>

CVE-2017-0627

The size of uvc_control_mapping is user controlled leading to a
potential heap overflow in the uvc driver. This adds a check to verify
the user provided size fits within the bounds of the defined buffer
size.

Originally-from: Richard Simmons <rssimmo at amazon.com>

Cc: stable at vger.kernel.org
Signed-off-by: Guenter Roeck <linux at roeck-us.net>
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Signed-off-by: Hans Verkuil <hans.verkuil at cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab at s-opensource.com>
(cherry picked from commit 7e09f7d5c790278ab98e5f2c22307ebe8ad6e8ba)
Signed-off-by: Po-Hsu Lin <po-hsu.lin at canonical.com>
---
 drivers/media/usb/uvc/uvc_ctrl.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
index 0eb82106..f1c1467 100644
--- a/drivers/media/usb/uvc/uvc_ctrl.c
+++ b/drivers/media/usb/uvc/uvc_ctrl.c
@@ -1949,6 +1949,13 @@ int uvc_ctrl_add_mapping(struct uvc_video_chain *chain,
 		goto done;
 	}
 
+	/* Validate the user-provided bit-size and offset */
+	if (mapping->size > 32 ||
+	    mapping->offset + mapping->size > ctrl->info.size * 8) {
+		ret = -EINVAL;
+		goto done;
+	}
+
 	list_for_each_entry(map, &ctrl->info.mappings, list) {
 		if (mapping->id == map->id) {
 			uvc_trace(UVC_TRACE_CONTROL, "Can't add mapping '%s', "
-- 
2.7.4





More information about the kernel-team mailing list