hid: usbhid: fix deadlock in hid_post_reset()
PATCH 1/1 hid: usbhid: fix deadlock in hid_post_reset()
You can build a USB device that includes a HID component and a storage or UAS component. The components can be reset only together. That means that hid_pre_reset() and hid_post_reset() are in the block IO error handling. Hence no memory allocation used in them may do block IO because the IO can deadlock on the mutex held while resetting a device and calling the interface drivers.
Use GFP_NOIO for all allocations in them.
--- drivers/hid/usbhid/hid-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/usbhid/hid-core.c +1 -1
@@ -1552,7 +1552,7 @@ static int hid_post_reset(struct usb_interface *intf)* configuration descriptors passed, we already know that * the size of the HID report descriptor has not changed. */ - rdesc =kmalloc (hid->dev_rsize,GFP_KERNEL ); + rdesc =kmalloc (hid->dev_rsize,GFP_NOIO );if (!rdesc)return -ENOMEM ;
Signature · 1 line
2.53.0
Jiri Kosina
maintainerQuoted 11 lines · Oliver Neukum
You can build a USB device that includes a HID component and a storage or UAS component. The components can be reset only together. That means that
hid_pre_reset()andhid_post_reset()are in the block IO error handling. Hence no memory allocation used in them may do block IO because the IO can deadlock on the mutex held while resetting a device and calling the interface drivers.
UseGFP_NOIOfor all allocations in them.Fixes dc3c78e434690 ("HID: usbhid: Check HID report descriptor contents after device reset")Signed-off-by Oliver Neukum <[email protected]>
Thanks Oliver.
Did you find this just by code inspection, or was this reported with a real device?
Thanks,
Signature · 2 lines
Jiri Kosina SUSE Labs
Quoted 2 lines · Jiri Kosina
Did you find this just by code inspection, or was this reported with a real device?
Pure inspection. We are looking at USB error handling in general right now.
Regards
Oliver
Jiri Kosina
maintainerQuoted 5 lines · Oliver Neukum
Quoted 2 lines
Did you find this just by code inspection, or was this reported with a real device?
Pure inspection. We are looking at USB error handling in general right now.
OK, thanks. Now queued in hid.git.
Signature · 2 lines
Jiri Kosina SUSE Labs