[RAMEN9610-21500]HID: Fix assumption that devices have inputs
authorAlan Stern <stern@rowland.harvard.edu>
Thu, 3 Oct 2019 18:53:59 +0000 (14:53 -0400)
committerchenyt9 <chenyt9@lenovo.com>
Mon, 15 Jun 2020 08:42:56 +0000 (16:42 +0800)
commit13aa7a802b8ed6c0f50831efb5acc135a3b1d1f1
tree453163122b33ce8fe52cc287cea0f4db11639bcd
parent24383ab8652a90e205b2cd8af576abb131e3cfd2
[RAMEN9610-21500]HID: Fix assumption that devices have inputs

commit d9d4b1e46d9543a82c23f6df03f4ad697dab361b upstream.

The syzbot fuzzer found a slab-out-of-bounds write bug in the hid-gaff
driver.  The problem is caused by the driver's assumption that the
device must have an input report.  While this will be true for all
normal HID input devices, a suitably malicious device can violate the
assumption.

The same assumption is present in over a dozen other HID drivers.
This patch fixes them by checking that the list of hid_inputs for the
hid_device is nonempty before allowing it to be used.

Change-Id: I5213393e2b1e827aa027083542ebd43775a7ce6f
Reported-and-tested-by: syzbot+403741a091bf41d4ae79@syzkaller.appspotmail.com
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: <stable@vger.kernel.org>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 914c944b359cd3d385eac482af4bae3ba68d15b1)
13 files changed:
drivers/hid/hid-axff.c
drivers/hid/hid-dr.c
drivers/hid/hid-emsff.c
drivers/hid/hid-gaff.c
drivers/hid/hid-holtekff.c
drivers/hid/hid-lg2ff.c
drivers/hid/hid-lg3ff.c
drivers/hid/hid-lg4ff.c
drivers/hid/hid-lgff.c
drivers/hid/hid-logitech-hidpp.c
drivers/hid/hid-sony.c
drivers/hid/hid-tmff.c
drivers/hid/hid-zpff.c