diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2019-10-03 14:53:59 -0400 |
---|---|---|
committer | Benjamin Tissoires <benjamin.tissoires@redhat.com> | 2019-10-03 15:36:40 -0400 |
commit | d9d4b1e46d9543a82c23f6df03f4ad697dab361b (patch) | |
tree | 5a405a2f78b1029f4cc6d6ee743f0bec31319b42 /drivers/hid/hid-emsff.c | |
parent | fe2199cfd1516e90e03c033c52c9a28da09d9986 (diff) |
HID: Fix assumption that devices have inputs
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.
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>
Diffstat (limited to 'drivers/hid/hid-emsff.c')
-rw-r--r-- | drivers/hid/hid-emsff.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/hid/hid-emsff.c b/drivers/hid/hid-emsff.c index 7cd5651872d3..c34f2e5a049f 100644 --- a/drivers/hid/hid-emsff.c +++ b/drivers/hid/hid-emsff.c | |||
@@ -47,13 +47,19 @@ static int emsff_init(struct hid_device *hid) | |||
47 | { | 47 | { |
48 | struct emsff_device *emsff; | 48 | struct emsff_device *emsff; |
49 | struct hid_report *report; | 49 | struct hid_report *report; |
50 | struct hid_input *hidinput = list_first_entry(&hid->inputs, | 50 | struct hid_input *hidinput; |
51 | struct hid_input, list); | ||
52 | struct list_head *report_list = | 51 | struct list_head *report_list = |
53 | &hid->report_enum[HID_OUTPUT_REPORT].report_list; | 52 | &hid->report_enum[HID_OUTPUT_REPORT].report_list; |
54 | struct input_dev *dev = hidinput->input; | 53 | struct input_dev *dev; |
55 | int error; | 54 | int error; |
56 | 55 | ||
56 | if (list_empty(&hid->inputs)) { | ||
57 | hid_err(hid, "no inputs found\n"); | ||
58 | return -ENODEV; | ||
59 | } | ||
60 | hidinput = list_first_entry(&hid->inputs, struct hid_input, list); | ||
61 | dev = hidinput->input; | ||
62 | |||
57 | if (list_empty(report_list)) { | 63 | if (list_empty(report_list)) { |
58 | hid_err(hid, "no output reports found\n"); | 64 | hid_err(hid, "no output reports found\n"); |
59 | return -ENODEV; | 65 | return -ENODEV; |