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  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]
Date:	Sun, 24 Aug 2014 16:27:38 +0200
From:	Michal Nazarewicz <mina86@...a86.com>
To:	Robert Baldyga <r.baldyga@...sung.com>, balbi@...com
Cc:	gregkh@...uxfoundation.org, linux-usb@...r.kernel.org,
	linux-kernel@...r.kernel.org, m.szyprowski@...sung.com,
	andrzej.p@...sung.com, k.opasiak@...sung.com,
	Robert Baldyga <r.baldyga@...sung.com>
Subject: Re: [PATCH v5 2/3] usb: gadget: f_fs: add ioctl returning ep descriptor

On Thu, Aug 21 2014, Robert Baldyga <r.baldyga@...sung.com> wrote:
> This patch introduces ioctl named FUNCTIONFS_ENDPOINT_DESC, which
> returns endpoint descriptor to userspace. It works only if function
> is active.
>
> Signed-off-by: Robert Baldyga <r.baldyga@...sung.com>

With the change described below:

Acked-by: Michal Nazarewicz <mina86@...a86.com>

> ---
>  drivers/usb/gadget/function/f_fs.c  | 21 +++++++++++++++++++++
>  include/uapi/linux/usb/functionfs.h |  6 ++++++
>  2 files changed, 27 insertions(+)
>
> diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
> index 8096f22..ac7b16d 100644
> --- a/drivers/usb/gadget/function/f_fs.c
> +++ b/drivers/usb/gadget/function/f_fs.c
> @@ -1032,6 +1032,27 @@ static long ffs_epfile_ioctl(struct file *file, unsigned code,
>  		case FUNCTIONFS_ENDPOINT_REVMAP:
>  			ret = epfile->ep->num;
>  			break;
> +		case FUNCTIONFS_ENDPOINT_DESC:
> +		{
> +			int desc_idx;
> +			struct usb_endpoint_descriptor *desc;
> +
> +			switch (epfile->ffs->gadget->speed) {
> +			case USB_SPEED_SUPER:
> +				desc_idx = 2;
> +				break;
> +			case USB_SPEED_HIGH:
> +				desc_idx = 1;
> +				break;
> +			default:
> +				desc_idx = 0;
> +			}
> +			desc = epfile->ep->descs[desc_idx];
> +			ret = copy_to_user((void *)value, desc, sizeof(*desc));

This is called under a spin lock, so nope…  The simplest will be to just
unlock prior to copying and then return instead of breaking from the switch:

+			struct usb_endpoint_descriptor desc;
…
+			desc = *epfile->ep->descs[desc_idx];
+			spin_unlock_irq(&epfile->ffs->eps_lock);
+			ret = copy_to_user((void *)value, &desc, sizeof(desc));
+			return ret ? -EFAULT : 0;

> +			if (ret)
> +				ret = -EFAULT;
> +			break;
> +		}
>  		default:
>  			ret = -ENOTTY;
>  		}

-- 
Best regards,                                         _     _
.o. | Liege of Serenely Enlightened Majesty of      o' \,=./ `o
..o | Computer Science,  Michał “mina86” Nazarewicz    (o o)
ooo +--<mpn@...gle.com>--<xmpp:mina86@...ber.org>--ooO--(_)--Ooo--
--
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