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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <063D6719AE5E284EB5DD2968C1650D6DB027CA6E@AcuExch.aculab.com>
Date:   Mon, 6 Feb 2017 16:09:18 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Ben Hutchings' <ben@...adent.org.uk>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>
CC:     "linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
        Petko Manolov <petkan@...leusys.com>
Subject: RE: [PATCH net 2/4] rtl8150: Use heap buffers for all register
 access

From: Ben Hutchings
> Sent: 04 February 2017 16:57
> Allocating USB buffers on the stack is not portable, and no longer
> works on x86_64 (with VMAP_STACK enabled as per default).
> 
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Ben Hutchings <ben@...adent.org.uk>
> ---
>  drivers/net/usb/rtl8150.c | 34 +++++++++++++++++++++++++++-------
>  1 file changed, 27 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c
> index 95b7bd0d7abc..c81c79110cef 100644
> --- a/drivers/net/usb/rtl8150.c
> +++ b/drivers/net/usb/rtl8150.c
> @@ -155,16 +155,36 @@ static const char driver_name [] = "rtl8150";
>  */
>  static int get_registers(rtl8150_t * dev, u16 indx, u16 size, void *data)
>  {
> -	return usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0),
> -			       RTL8150_REQ_GET_REGS, RTL8150_REQT_READ,
> -			       indx, 0, data, size, 500);
> +	void *buf;
> +	int ret;
> +
> +	buf = kmalloc(size, GFP_NOIO);
> +	if (!buf)
> +		return -ENOMEM;
> +
> +	ret = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0),
> +			      RTL8150_REQ_GET_REGS, RTL8150_REQT_READ,
> +			      indx, 0, buf, size, 500);
> +	if (ret > 0 && ret <= size)
> +		memcpy(data, buf, ret);

If ret > size something is horridly wrong.
Silently not updating the callers buffer at all cannot be right.

> +	kfree(buf);
> +	return ret;

I can't help feeling that it would be better to add a wrapper to
usb_control_msg() that does the kmalloc() and memcpy()s and
drop that into all the call sites.

	David

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ