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: <53F32D79.8050401@ladisch.de>
Date:	Tue, 19 Aug 2014 12:56:57 +0200
From:	Clemens Ladisch <clemens@...isch.de>
To:	Arjun Sreedharan <arjun024@...il.com>
CC:	gregkh@...uxfoundation.org, linux-usb@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] usb: use kcalloc instead of kzalloc

Arjun Sreedharan wrote:
> kcalloc has protection from integer overflows
> which could arise from the multiplication of
> number of elements and size.

You are implying that such an overflow could arise in this code.
This is false.

> @@ -380,8 +380,7 @@ static int usb_parse_interface(struct device *ddev, int cfgno,
>
>  	if (num_ep > 0) {
>  		/* Can't allocate 0 bytes */
> -		len = sizeof(struct usb_host_endpoint) * num_ep;
> -		alt->endpoint = kzalloc(len, GFP_KERNEL);
> +		alt->endpoint = kcalloc(num_ep, sizeof(struct usb_host_endpoint), GFP_KERNEL);

bNumEndpoints is an unsigned 8-bit integer.

And even if you did not notice this, you should have noticed the if()
directly before this one.

> @@ -683,13 +682,11 @@ int usb_get_configuration(struct usb_device *dev)
>  		return -EINVAL;
>  	}
>
> -	length = ncfg * sizeof(struct usb_host_config);
> -	dev->config = kzalloc(length, GFP_KERNEL);
> +	dev->config = kcalloc(ncfg, sizeof(struct usb_host_config), GFP_KERNEL);
>  	if (!dev->config)
>  		goto err2;
>
> -	length = ncfg * sizeof(char *);
> -	dev->rawdescriptors = kzalloc(length, GFP_KERNEL);
> +	dev->rawdescriptors = kcalloc(ncfg, sizeof(char *), GFP_KERNEL);

Same oversights here.


Regards,
Clemens
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ