uvcvideo: Prevent heap overflow in uvc driver
Subsystems (2)
PATCH v2 1/1 uvcvideo: Prevent heap overflow in uvc driver
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 <[email protected]>
---
Fixes CVE-2017-0627.
v2: Combination of v1 with the fix suggested by Richard Simmons
Perform validation after uvc_ctrl_fill_xu_info()
Take into account that ctrl->info.size is in bytes
Also validate mapping->sizedrivers/media/usb/uvc/uvc_ctrl.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/media/usb/uvc/uvc_ctrl.c +7 -0
@@ -2002,6 +2002,13 @@ int uvc_ctrl_add_mapping(struct uvc_video_chain *chain, goto done; } +/* validate that the user provided bit-size and offset is valid */ +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', "
Signature · 1 line
2.7.4
Quoted 7 lines · Guenter Roeck
The size of
uvc_control_mappingis 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 <[email protected]>
Signed-off-by Guenter Roeck <[email protected]>
Any comments ?
Thanks,
Guenter
Quoted 32 lines
---
Fixes CVE-2017-0627.v2: Combination of v1 with the fix suggested by Richard Simmons
Perform validation after uvc_ctrl_fill_xu_info() Take into account that ctrl->info.size is in bytes Also validate mapping->sizedrivers/media/usb/uvc/uvc_ctrl.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/media/usb/uvc/uvc_ctrl.c +7
-0@@ -2002,6 +2002,13 @@ int uvc_ctrl_add_mapping(struct uvc_video_chain *chain, goto done; } +/* validate that the user provided bit-size and offset is valid */ +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', "Signature · 1 line
2.7.4
Any comments / feedback ?
Thanks,
Guenter
Quoted 39 lines · Guenter Roeck
The size of
uvc_control_mappingis 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 <[email protected]>
Signed-off-by Guenter Roeck <[email protected]>---
Fixes CVE-2017-0627.v2: Combination of v1 with the fix suggested by Richard Simmons
Perform validation after uvc_ctrl_fill_xu_info() Take into account that ctrl->info.size is in bytes Also validate mapping->sizedrivers/media/usb/uvc/uvc_ctrl.c | 7 +++++++ 1 file changed, 7 insertions(+)drivers/media/usb/uvc/uvc_ctrl.c +7
-0@@ -2002,6 +2002,13 @@ int uvc_ctrl_add_mapping(struct uvc_video_chain *chain, goto done; } +/* validate that the user provided bit-size and offset is valid */ +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', "Signature · 1 line
2.7.4
Hi Guenter,
Thank you for the patch and sorry for the late reply.
Quoted 7 lines · On Friday 30 Jun 2017 09:21:56 Guenter Roeck wrote:
The size of
uvc_control_mappingis 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 <[email protected]>
Signed-off-by Guenter Roeck <[email protected]>
This looks good to me.
and taken in my tree for v4.14 with a Cc: [email protected] tag to get it backported to stable kernels.
Quoted 19 lines
---
Fixes CVE-2017-0627.v2: Combination of v1 with the fix suggested by Richard Simmons
Perform validation after uvc_ctrl_fill_xu_info() Take into account that ctrl->info.size is in bytes Also validate mapping->sizedrivers/media/usb/uvc/uvc_ctrl.c | 7 +++++++ 1 file changed, 7 insertions(+)(quoted diff) +0
-0
b/drivers/media/usb/uvc/uvc_ctrl.cindexc2ee6e39fd0c..d3e3164f43fd100644drivers/media/usb/uvc/uvc_ctrl.c +0
-0@@ -2002,6 +2002,13 @@ int uvc_ctrl_add_mapping(struct uvc_video_chain *chain, goto done; }
drivers/media/usb/uvc/uvc_ctrl.c int uvc_ctrl_add_mapping(struct uvc_video_chain · line 2014
Quoted 10 lines
drivers/media/usb/uvc/uvc_ctrl.c +7
-0+/* validate that the user provided bit-size and offset is valid */ +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',
"
Signature · 3 lines
Regards, Laurent Pinchart