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]
Date:	Mon, 28 Jul 2014 08:42:44 +0200
From:	Marek Szyprowski <m.szyprowski@...sung.com>
To:	Michal Nazarewicz <mina86@...a86.com>,
	Robert Baldyga <r.baldyga@...sung.com>, balbi@...com
Cc:	gregkh@...uxfoundation.org, linux-usb@...r.kernel.org,
	linux-kernel@...r.kernel.org, andrzej.p@...sung.com
Subject: Re: [PATCH v2 2/3] usb: gadget: f_fs: add ioctl returning ep descriptor

Hello,

On 2014-07-25 16:15, Michal Nazarewicz wrote:
> On Fri, Jul 25 2014, Robert Baldyga wrote:
>> This patch introduces ioctl named FUNCTIONFS_ENDPOINT_DESC, which
>> returns endpoint descriptor to userspace. It works only if function
>> is active.
> I would argue that user space should never need to know the real
> descriptor.  Is this ioctl needed for anything in particular?

Some proprietary broken usb protocols might embed real physical endpoint
(or interface) number into the data stream. In such case functionfs driver
is unable to do proper endpoint/interface number fixup.

>
>> Signed-off-by: Robert Baldyga <r.baldyga@...sung.com>
>> ---
>>   drivers/usb/gadget/f_fs.c           | 17 +++++++++++++++++
>>   include/uapi/linux/usb/functionfs.h |  6 ++++++
>>   2 files changed, 23 insertions(+)
>>
>> diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
>> index 490b30f..a2e18cc 100644
>> --- a/drivers/usb/gadget/f_fs.c
>> +++ b/drivers/usb/gadget/f_fs.c
>> @@ -1031,6 +1031,23 @@ 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;
>> +
>> +			if (epfile->ffs->gadget->speed == USB_SPEED_SUPER)
>> +				desc_idx = 2;
>> +			else if (epfile->ffs->gadget->speed == USB_SPEED_HIGH)
>> +				desc_idx = 1;
>> +			else
>> +				desc_idx = 0;
>> +			desc = epfile->ep->descs[desc_idx];
>> +			ret = copy_to_user((void *)value, desc, sizeof(*desc));
>> +			if (ret)
>> +				ret = -EFAULT;
>> +			break;
>> +		}
>>   		default:
>>   			ret = -ENOTTY;
>>   		}
>> diff --git a/include/uapi/linux/usb/functionfs.h b/include/uapi/linux/usb/functionfs.h
>> index 1dc473a..1ab6f06 100644
>> --- a/include/uapi/linux/usb/functionfs.h
>> +++ b/include/uapi/linux/usb/functionfs.h
>> @@ -197,6 +197,12 @@ struct usb_functionfs_event {
>>    */
>>   #define	FUNCTIONFS_ENDPOINT_REVMAP	_IO('g', 129)
>>   
>> +/*
>> + * Returns endpoint descriptor. In funciton is not active returns -ENODEV.
>> + */
>> +#define	FUNCTIONFS_ENDPOINT_DESC	_IOR('g', 130, \
>> +					     struct usb_endpoint_descriptor)
>> +
>>   
>>   
>>   #endif /* _UAPI__LINUX_FUNCTIONFS_H__ */
>> -- 
>> 1.9.1

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland

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