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] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.44L0.1309301030110.1352-100000@iolanthe.rowland.org>
Date:	Mon, 30 Sep 2013 10:34:27 -0400 (EDT)
From:	Alan Stern <stern@...land.harvard.edu>
To:	Robert Baldyga <r.baldyga@...sung.com>
cc:	balbi@...com, <gregkh@...uxfoundation.org>,
	<linux-usb@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
	<b.zolnierkie@...sung.com>, <m.szyprowski@...sung.com>,
	<andrzej.p@...sung.com>
Subject: Re: [PATCH v2] USB: gadget: epautoconf: fix ep maxpacket check

On Mon, 30 Sep 2013, Robert Baldyga wrote:

> Hello,
> This is update for my patch fixing maxpacket check in epautoconfig. Now code
> is better arranged for clearity and take into account super speed devices,
> as Alan Stern suggested.
> 
> This patch fixes validation of maxpacket value given in endpoint descriptor.
> Added check of maxpacket for bulk endpoints.
> 
> Correct maxpacket value is:
> 
>              FULL-SPEED  HIGH-SPEED  SUPER-SPEED
> BULK         64          512         1024
> INTERRUPT    64          1024        1024
> ISOCHRONOUS  1023        1024        1024
> 
> Signed-off-by: Robert Baldyga <r.baldyga@...sung.com>
> 
> Changelog:
> 
> v2:
> - arrange code for clearity
> - fix support for super speed devices
> 
> v1: https://lkml.org/lkml/2013/9/27/127
> ---
>  drivers/usb/gadget/epautoconf.c |   54 +++++++++++++++++++++++++++++++--------
>  1 file changed, 43 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c
> index a777f7b..2daf3ba 100644
> --- a/drivers/usb/gadget/epautoconf.c
> +++ b/drivers/usb/gadget/epautoconf.c
> @@ -136,25 +136,57 @@ ep_matches (
>  	 * the usb spec fixes high speed bulk maxpacket at 512 bytes.
>  	 */
>  	max = 0x7ff & usb_endpoint_maxp(desc);
> +
> +	if (ep->maxpacket < max)
> +		return 0;
> +
>  	switch (type) {
> -	case USB_ENDPOINT_XFER_INT:
> -		/* INT:  limit 64 bytes full speed, 1024 high/super speed */
> +	case USB_ENDPOINT_XFER_BULK:
> +		/*
> +		 * LIMITS:
> +		 * full speed:    64 bytes
> +		 * high speed:   512 bytes
> +		 * super speed: 1024 bytes
> +		 */
> +		if (max > 1024)
> +			return 0;
> +		if (!gadget_is_superspeed(gadget) && max > 512)
> +			return 0;

You might be able to do better than this.  For high speed, the bulk 
maxpacket size must be exactly 512, and for SuperSpeed it must be 
exactly 1024.

(With full speed, by contrast, it can be 8, 16, 32, or 64.)

>  		if (!gadget_is_dualspeed(gadget) && max > 64)
>  			return 0;
> -		/* FALLTHROUGH */
> +		break;
>  
> -	case USB_ENDPOINT_XFER_ISOC:
> -		/* ISO:  limit 1023 bytes full speed, 1024 high/super speed */
> -		if (ep->maxpacket < max)
> +	case USB_ENDPOINT_XFER_INT:
> +		/*
> +		 * LIMITS:
> +		 * full speed:		64 bytes
> +		 * high/super speed:  1024 bytes
> +		 * multiple transactions per microframe only for super speed

No, high speed allows up to 3 transactions per microframe.

Alan Stern

--
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