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:   Mon, 8 Nov 2021 07:56:50 +0000
From:   Minas Harutyunyan <Minas.Harutyunyan@...opsys.com>
To:     John Keeping <john@...anate.com>
CC:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        "linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] usb: dwc2: gadget: respect driver's max_speed

On 11/5/2021 9:23 PM, John Keeping wrote:
> UDCs should not enumerate faster than the max_speed set by the gadget
> driver.  Use this to further restrict the speed set in the DWC2
> parameters so that the device will not connect faster than is supported
> by the gadget driver.
> 
> For configfs-based composite devices this can be set via the max_speed
> configfs file.
> 
> Signed-off-by: John Keeping <john@...anate.com>

Acked-by: Minas Harutyunyan <Minas.Harutyunyan@...opsys.com>


> ---
>   drivers/usb/dwc2/gadget.c | 18 +++++++++++++++++-
>   1 file changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
> index 744539b78f6c..1f39c2f1be8e 100644
> --- a/drivers/usb/dwc2/gadget.c
> +++ b/drivers/usb/dwc2/gadget.c
> @@ -3377,6 +3377,7 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg,
>   	u32 val;
>   	u32 usbcfg;
>   	u32 dcfg = 0;
> +	u8 speed;
>   	int ep;
>   
>   	/* Kill any ep0 requests as controller will be reinitialized */
> @@ -3418,7 +3419,22 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg,
>   
>   	dcfg |= DCFG_EPMISCNT(1);
>   
> -	switch (hsotg->params.speed) {
> +	speed = hsotg->params.speed;
> +	if (hsotg->driver) {
> +		switch (hsotg->driver->max_speed) {
> +		case USB_SPEED_LOW:
> +			speed = DWC2_SPEED_PARAM_LOW;
> +			break;
> +		case USB_SPEED_FULL:
> +			if (speed != USB_SPEED_LOW)
> +				speed = DWC2_SPEED_PARAM_FULL;
> +			break;
> +		default:
> +			break;
> +		}
> +	}
> +
> +	switch (speed) {
>   	case DWC2_SPEED_PARAM_LOW:
>   		dcfg |= DCFG_DEVSPD_LS;
>   		break;
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ