]> git.baikalelectronics.ru Git - kernel.git/commit
usb: usbip: add missing device lock on tweak configuration cmd
authorNiels Dossche <dossche.niels@gmail.com>
Tue, 12 Apr 2022 16:50:55 +0000 (18:50 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 21 Apr 2022 17:01:25 +0000 (19:01 +0200)
commite23676502b9ebce7f3cc394c1de9ab50fadf1c95
tree84afb841804e5b97dc54b2dcbf3eff8d3bacf9a1
parentc5fb71135423cc3d6211a0b608b74f33daffda08
usb: usbip: add missing device lock on tweak configuration cmd

The function documentation of usb_set_configuration says that its
callers should hold the device lock. This lock is held for all
callsites except tweak_set_configuration_cmd. The code path can be
executed for example when attaching a remote USB device.
The solution is to surround the call by the device lock.

This bug was found using my experimental own-developed static analysis
tool, which reported the missing lock on v5.17.2. I manually verified
this bug report by doing code review as well. I runtime checked that
the required lock is not held. I compiled and runtime tested this on
x86_64 with a USB mouse. After applying this patch, my analyser no
longer reports this potential bug.

Fixes: 16e69528d500 ("staging: usbip: let client choose device configuration")
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Niels Dossche <dossche.niels@gmail.com>
Link: https://lore.kernel.org/r/20220412165055.257113-1-dossche.niels@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/usbip/stub_rx.c