lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 28 Jun 2017 21:18:37 +0300
From:   Laurent Pinchart <laurent.pinchart@...asonboard.com>
To:     Guenter Roeck <linux@...ck-us.net>
Cc:     Mauro Carvalho Chehab <mchehab@...nel.org>,
        linux-media@...r.kernel.org, linux-kernel@...r.kernel.org,
        Robb Glasser <rglasser@...gle.com>
Subject: Re: [media] uvcvideo: Prevent heap overflow in uvc driver

Hi Guenter,

On Wednesday 28 Jun 2017 20:59:17 Laurent Pinchart wrote:
> On Wednesday 28 Jun 2017 07:36:43 Guenter Roeck wrote:
> > On Mon, May 22, 2017 at 12:48:04PM -0700, Guenter Roeck wrote:
> >> From: Robb Glasser <rglasser@...gle.com>
> >> 
> >> 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.
> >> 
> >> Signed-off-by: Robb Glasser <rglasser@...gle.com>
> >> [groeck: cherry picked from
> >> 
> >>  https://source.codeaurora.org/quic/la/kernel/msm-3.10
> >>  commit b7b99e55bc7770187913ed092990852ea52d7892;
> >>  updated subject]
> >> 
> >> Signed-off-by: Guenter Roeck <linux@...ck-us.net>
> >> ---
> >> Fixes CVE-2017-0627.
> > 
> > Please do not apply this patch. It is buggy.
> 
> I apologize for not noticing the initial patch, even if it looks like it was
> all for the best. Will you send a new version ?
> 
> >>  drivers/media/usb/uvc/uvc_ctrl.c | 3 +++
> >>  1 file changed, 3 insertions(+)
> >> 
> >> diff --git a/drivers/media/usb/uvc/uvc_ctrl.c
> >> b/drivers/media/usb/uvc/uvc_ctrl.c index c2ee6e39fd0c..252ab991396f
> >> 100644
> >> --- a/drivers/media/usb/uvc/uvc_ctrl.c
> >> +++ b/drivers/media/usb/uvc/uvc_ctrl.c
> >> @@ -1992,6 +1992,9 @@ int uvc_ctrl_add_mapping(struct uvc_video_chain
> >> *chain,
> >>  	if (!found)
> >>  		return -ENOENT;
> >> 
> >> +	if (ctrl->info.size < mapping->size)
> >> +		return -EINVAL;
> >> +

By the way, I believe the right fix should be

	if (mapping->offset + mapping->size > ctrl->info.size * 8)
		return -EINVAL;

Both mapping->offset and mapping->size are 8-bit integers, so there's no risk 
of overflow in the addition. If we want to safeguard against a possible future 
bug if the type of the fields change, we could add

	if (mapping->offset + mapping->size < mapping->offset)
		return -EINVAL;

> >>  	if (mutex_lock_interruptible(&chain->ctrl_mutex))
> >>  		return -ERESTARTSYS;

-- 
Regards,

Laurent Pinchart

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ