OpenCloudOS-Kernel/Documentation/usb
Reilly Grant d883f52e1f usb: devio: Add ioctl to disallow detaching kernel USB drivers.
The new USBDEVFS_DROP_PRIVILEGES ioctl allows a process to voluntarily
relinquish the ability to issue other ioctls that may interfere with
other processes and drivers that have claimed an interface on the
device.

This commit also includes a simple utility to be able to test the
ioctl, located at Documentation/usb/usbdevfs-drop-permissions.c

Example (with qemu-kvm's input device):

    $ lsusb
    ...
    Bus 001 Device 002: ID 0627:0001 Adomax Technology Co., Ltd

    $ usb-devices
    ...
    C:  #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=100mA
    I:  If#= 0 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=00 Prot=02 Driver=usbhid

    $ sudo ./usbdevfs-drop-permissions /dev/bus/usb/001/002
    OK: privileges dropped!
    Available options:
    [0] Exit now
    [1] Reset device. Should fail if device is in use
    [2] Claim 4 interfaces. Should succeed where not in use
    [3] Narrow interface permission mask
    Which option shall I run?: 1
    ERROR: USBDEVFS_RESET failed! (1 - Operation not permitted)
    Which test shall I run next?: 2
    ERROR claiming if 0 (1 - Operation not permitted)
    ERROR claiming if 1 (1 - Operation not permitted)
    ERROR claiming if 2 (1 - Operation not permitted)
    ERROR claiming if 3 (1 - Operation not permitted)
    Which test shall I run next?: 0

After unbinding usbhid:

    $ usb-devices
    ...
    I:  If#= 0 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=00 Prot=02 Driver=(none)

    $ sudo ./usbdevfs-drop-permissions /dev/bus/usb/001/002
    ...
    Which option shall I run?: 2
    OK: claimed if 0
    ERROR claiming if 1 (1 - Operation not permitted)
    ERROR claiming if 2 (1 - Operation not permitted)
    ERROR claiming if 3 (1 - Operation not permitted)
    Which test shall I run next?: 1
    OK: USBDEVFS_RESET succeeded
    Which test shall I run next?: 0

After unbinding usbhid and restricting the mask:

    $ sudo ./usbdevfs-drop-permissions /dev/bus/usb/001/002
    ...
    Which option shall I run?: 3
    Insert new mask: 0
    OK: privileges dropped!
    Which test shall I run next?: 2
    ERROR claiming if 0 (1 - Operation not permitted)
    ERROR claiming if 1 (1 - Operation not permitted)
    ERROR claiming if 2 (1 - Operation not permitted)
    ERROR claiming if 3 (1 - Operation not permitted)

Signed-off-by: Reilly Grant <reillyg@chromium.org>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Emilio López <emilio.lopez@collabora.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-03-05 12:05:01 -08:00
..
CREDITS
URB.txt USB: URB documentation: claim complete() will be run with IRQs enabled 2013-08-12 11:43:48 -07:00
WUSB-Design-overview.txt usb: hub: rename khubd to hub_wq in documentation and comments 2014-09-23 22:33:19 -07:00
acm.txt
anchors.txt trivial: Miscellaneous documentation typo fixes 2009-06-12 18:01:47 +02:00
authorization.txt usb: interface authorization: Documentation part 2015-09-22 12:08:40 -07:00
bulk-streams.txt USB: Support for allocating USB 3.0 streams. 2010-05-20 13:21:38 -07:00
callbacks.txt USB: documentation update for the pre_reset method 2011-04-29 17:24:29 -07:00
chipidea.txt Documentation: usb: chipidea: Update test procedure for HNP polling 2016-03-04 15:14:37 +02:00
dma.txt doc: fix broken references 2011-09-27 18:08:04 +02:00
dwc3.txt doc: fix a few typos 2012-04-05 17:02:52 -07:00
ehci.txt USB: EHCI: Allow users to override 80% max periodic bandwidth 2011-07-08 14:51:33 -07:00
error-codes.txt USB: report submission of active URBs 2012-11-11 18:10:46 -08:00
functionfs.txt FunctionFS: enable multiple functions 2012-05-14 09:25:44 -07:00
gadget-testing.txt Documentation: usb: update usb-tools repository address 2015-12-16 10:07:30 -06:00
gadget_configfs.txt gadget_configfs.txt: fix spelling of 'function' 2014-10-29 14:30:15 +01:00
gadget_hid.txt usb: gadget: hid: add configfs support 2014-11-06 16:18:19 -06:00
gadget_multi.txt doc: Fix typo in USB Gadget Documentation 2014-01-10 15:33:54 +01:00
gadget_printer.txt
gadget_serial.txt Documentation: usb: gadget_serial: update generic serial setup instruction 2015-01-12 12:13:24 -06:00
hotplug.txt usb: hub: rename khubd to hub_wq in documentation and comments 2014-09-23 22:33:19 -07:00
iuu_phoenix.txt
linux-cdc-acm.inf USB: linux-cdc-acm.inf: add support for the acm_ms gadget 2011-11-29 09:59:29 +09:00
linux.inf USB: gadget: g_multi: fixed vendor and product ID in inf files 2011-04-29 16:45:22 -07:00
mass-storage.txt doc: spelling error changes 2014-05-05 15:32:05 +02:00
misc_usbsevseg.txt USB: Added driver for a Delcom USB 7-segment LED Display 2008-10-17 14:40:51 -07:00
mtouchusb.txt Documentation: Fix Broken URL "freshmeat" 2012-02-21 11:43:45 +01:00
ohci.txt
persist.txt usb: add decriptor of persist fail for some morph usb devices 2012-08-10 12:06:39 -07:00
power-management.txt usb: core: lpm: fix usb3_hardware_lpm sysfs node 2015-12-01 14:58:18 -08:00
proc_usb_info.txt proc_usb_info.txt: Correct documentation about endianness of config descriptors 2013-08-12 12:24:27 -07:00
rio.txt
usb-help.txt
usb-serial.txt Documentation usb serial: fixed how to provide vendor and product id 2015-05-07 09:44:04 -06:00
usbdevfs-drop-permissions.c usb: devio: Add ioctl to disallow detaching kernel USB drivers. 2016-03-05 12:05:01 -08:00
usbip_protocol.txt usbip: move usbip_protocol.txt to Documentation 2016-03-03 19:44:06 -08:00
usbmon.txt doc: usbmon: fix spelling s/unpriviledged/unprivileged/ 2015-01-09 12:25:54 -08:00
wusb-cbaf doc: fix a few typos 2012-04-05 17:02:52 -07:00