linux/Documentation/DocBook
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
..
media [media] Postpone the addition of MEDIA_IOC_G_TOPOLOGY 2016-01-11 12:35:17 -02:00
.gitignore Docs/DocBook: Add .db files to .gitignore 2015-09-13 14:38:50 -06:00
80211.tmpl nl80211: allow BSS data to include CLOCK_BOOTTIME timestamp 2015-10-13 10:32:17 +02:00
alsa-driver-api.tmpl ALSA: DocBook: Add soc-ops.c and soc-compress.c 2015-10-28 12:37:50 +01:00
crypto-API.tmpl crypto: doc - make URL into hyperlink 2015-08-10 23:19:06 +08:00
debugobjects.tmpl
device-drivers.tmpl [media] DocBook: Move media-framework.txt contents to media-device.h 2016-01-11 12:19:04 -02:00
deviceiobook.tmpl
filesystems.tmpl doc: Update doc about journalling layer 2015-07-23 20:59:39 +02:00
gadget.tmpl Revert "DocBook: Avoid building man pages repeatedly and inconsistently" 2015-08-06 12:44:44 -06:00
genericirq.tmpl
gpu.tmpl apple-gmux: Add initial documentation 2016-01-11 15:56:23 +01:00
iio.tmpl Doc: Docbook/iio: Fix typo in iio.tmpl 2015-11-20 17:09:05 -07:00
kernel-api.tmpl Revert "DocBook: Avoid building man pages repeatedly and inconsistently" 2015-08-06 12:44:44 -06:00
kernel-hacking.tmpl Documentation: extend use case for EXPORT_SYMBOL_GPL() 2015-06-05 07:39:46 +09:00
kernel-locking.tmpl
kgdb.tmpl KGDB/KDB New: 2015-02-20 15:13:29 -08:00
libata.tmpl
librs.tmpl
lsm.tmpl
Makefile DocBook: make index.html generation less verbose by default 2015-11-20 17:04:43 -07:00
media_api.tmpl [media] use https://linuxtv.org for LinuxTV URLs 2015-12-04 10:38:59 -02:00
mtdnand.tmpl mtd: nand: update the documentation to reflect framework changes 2015-12-18 11:26:01 -08:00
networking.tmpl
rapidio.tmpl
regulator.tmpl
s390-drivers.tmpl
scsi.tmpl Doc: Docbook: Change wikipedia's URL from http to https in scsi.tmpl 2015-06-22 10:29:32 -06:00
sh.tmpl
stylesheet.xsl DocBook: Generate consistent IDs 2015-07-10 11:03:16 -06:00
tracepoint.tmpl
uio-howto.tmpl pdfdocs: Fix 'make pdfdocs' failure for 'uio-howto.tmpl' 2015-02-03 15:48:51 -08:00
usb.tmpl usb: devio: Add ioctl to disallow detaching kernel USB drivers. 2016-03-05 12:05:01 -08:00
w1.tmpl
writing-an-alsa-driver.tmpl ALSA: Remove transfer_ack_{begin,end} callbacks from struct snd_pcm_runtime 2015-10-22 17:16:23 +02:00
writing_musb_glue_layer.tmpl
writing_usb_driver.tmpl
z8530book.tmpl