linux-stable/drivers/hid/usbhid
Ioan-Adrian Ratiu e470127e96 HID: usbhid: fix recursive deadlock
The critical section protected by usbhid->lock in hid_ctrl() is too
big and because of this it causes a recursive deadlock. "Too big" means
the case statement and the call to hid_input_report() do not need to be
protected by the spinlock (no URB operations are done inside them).

The deadlock happens because in certain rare cases drivers try to grab
the lock while handling the ctrl irq which grabs the lock before them
as described above. For example newer wacom tablets like 056a:033c try
to reschedule proximity reads from wacom_intuos_schedule_prox_event()
calling hid_hw_request() -> usbhid_request() -> usbhid_submit_report()
which tries to grab the usbhid lock already held by hid_ctrl().

There are two ways to get out of this deadlock:
    1. Make the drivers work "around" the ctrl critical region, in the
    wacom case for ex. by delaying the scheduling of the proximity read
    request itself to a workqueue.
    2. Shrink the critical region so the usbhid lock protects only the
    instructions which modify usbhid state, calling hid_input_report()
    with the spinlock unlocked, allowing the device driver to grab the
    lock first, finish and then grab the lock afterwards in hid_ctrl().

This patch implements the 2nd solution.

Signed-off-by: Ioan-Adrian Ratiu <adi@adirat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2015-12-01 17:35:10 +01:00
..
hid-core.c HID: usbhid: fix recursive deadlock 2015-12-01 17:35:10 +01:00
hid-pidff.c HID: pidff: effect can't be NULL 2015-03-27 16:03:26 +01:00
hid-quirks.c Merge branches 'for-4.3/upstream-fixes', 'for-4.4/corsair', 'for-4.4/dragonrise', 'for-4.4/i2c-hid', 'for-4.4/logitech', 'for-4.4/microsoft', 'for-4.4/multitouch', 'for-4.4/roccat-sysfs-deprecation', 'for-4.4/upstream' and 'for-4.4/wacom' into for-linus 2015-11-06 21:45:15 +01:00
hiddev.c HID: use hid_hw_wait() instead of direct call to usbhid 2013-02-25 13:26:41 +01:00
Kconfig HID: Fix the generic Kconfig options 2012-06-25 17:25:00 +02:00
Makefile HID: Use Kbuild idiom in Makefiles 2015-01-21 22:23:20 +01:00
usbhid.h HID: usbhid: prevent unwanted events to be sent when re-opening the device 2014-10-29 11:04:54 +01:00
usbkbd.c HID: usbkbd: fix inconsistent debugging output 2013-11-19 11:32:04 +01:00
usbmouse.c USB: usbmouse.c: remove err() usage 2012-04-25 14:48:20 -07:00