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: <YirveIx9acrGoe4/@kroah.com>
Date:   Fri, 11 Mar 2022 07:43:04 +0100
From:   Greg KH <gregkh@...uxfoundation.org>
To:     Wei Ming Chen <jj251510319013@...il.com>
Cc:     linux-kernel@...r.kernel.org, andreyknvl@...il.com,
        balbi@...nel.org, linux-usb@...r.kernel.org
Subject: Re: [PATCH v2] usb: raw-gadget: return -EINVAL if no proper ep
 address available

On Fri, Mar 11, 2022 at 11:22:38AM +0800, Wei Ming Chen wrote:
> If we try to use raw_ioctl_ep_enable() for ep5in on a hardware that
> only support from ep1-ep4 for both in and out direction, it will return
> -EBUSY originally.
> 
> I think it will be more intuitive if we return -EINVAL, because -EBUSY
> sounds like ep5in is not available now, but might be available in the
> future.
> 
> Signed-off-by: Wei Ming Chen <jj251510319013@...il.com>
> ---
>  drivers/usb/gadget/legacy/raw_gadget.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/gadget/legacy/raw_gadget.c b/drivers/usb/gadget/legacy/raw_gadget.c
> index d86c3a36441e..e5707626c4d4 100644
> --- a/drivers/usb/gadget/legacy/raw_gadget.c
> +++ b/drivers/usb/gadget/legacy/raw_gadget.c
> @@ -758,6 +758,7 @@ static int raw_ioctl_ep_enable(struct raw_dev *dev, unsigned long value)
>  	unsigned long flags;
>  	struct usb_endpoint_descriptor *desc;
>  	struct raw_ep *ep;
> +	bool ep_props_matched = false;
>  
>  	desc = memdup_user((void __user *)value, sizeof(*desc));
>  	if (IS_ERR(desc))
> @@ -787,13 +788,14 @@ static int raw_ioctl_ep_enable(struct raw_dev *dev, unsigned long value)
>  
>  	for (i = 0; i < dev->eps_num; i++) {
>  		ep = &dev->eps[i];
> -		if (ep->state != STATE_EP_DISABLED)
> -			continue;
>  		if (ep->addr != usb_endpoint_num(desc) &&
>  				ep->addr != USB_RAW_EP_ADDR_ANY)
>  			continue;
>  		if (!usb_gadget_ep_match_desc(dev->gadget, ep->ep, desc, NULL))
>  			continue;
> +		ep_props_matched = true;
> +		if (ep->state != STATE_EP_DISABLED)
> +			continue;
>  		ep->ep->desc = desc;
>  		ret = usb_ep_enable(ep->ep);
>  		if (ret < 0) {
> @@ -815,8 +817,13 @@ static int raw_ioctl_ep_enable(struct raw_dev *dev, unsigned long value)
>  		goto out_unlock;
>  	}
>  
> -	dev_dbg(&dev->gadget->dev, "fail, no gadget endpoints available\n");
> -	ret = -EBUSY;
> +	if (!ep_props_matched) {
> +		dev_dbg(&dev->gadget->dev, "fail, bad endpoint descriptor\n");
> +		ret = -EINVAL;
> +	} else {
> +		dev_dbg(&dev->gadget->dev, "fail, no endpoints available\n");
> +		ret = -EBUSY;
> +	}
>  
>  out_free:
>  	kfree(desc);
> -- 
> 2.25.1
> 

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- This looks like a new version of a previously submitted patch, but you
  did not list below the --- line any changes from the previous version.
  Please read the section entitled "The canonical patch format" in the
  kernel file, Documentation/SubmittingPatches for what needs to be done
  here to properly describe this.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ