summaryrefslogtreecommitdiff
path: root/drivers/hid
diff options
context:
space:
mode:
authorDongliang Mu <mudongliangabcd@gmail.com>2022-05-06 10:24:25 +0300
committerJiri Kosina <jkosina@suse.cz>2022-05-06 11:46:36 +0300
commitfc4ef9d5724973193bfa5ebed181dba6de3a56db (patch)
treed72e367f8d76596c65a45e7e6acb537b7f3bab51 /drivers/hid
parent1af20714fedad238362571620be0bd690ded05b6 (diff)
downloadlinux-fc4ef9d5724973193bfa5ebed181dba6de3a56db.tar.xz
HID: bigben: fix slab-out-of-bounds Write in bigben_probe
There is a slab-out-of-bounds Write bug in hid-bigbenff driver. The problem is the driver assumes the device must have an input but some malicious devices violate this assumption. Fix this by checking hid_device's input is non-empty before its usage. Reported-by: syzkaller <syzkaller@googlegroups.com> Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/hid-bigbenff.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/hid/hid-bigbenff.c b/drivers/hid/hid-bigbenff.c
index 74ad8bf98bfd..e8c5e3ac9fff 100644
--- a/drivers/hid/hid-bigbenff.c
+++ b/drivers/hid/hid-bigbenff.c
@@ -347,6 +347,12 @@ static int bigben_probe(struct hid_device *hid,
bigben->report = list_entry(report_list->next,
struct hid_report, list);
+ if (list_empty(&hid->inputs)) {
+ hid_err(hid, "no inputs found\n");
+ error = -ENODEV;
+ goto error_hw_stop;
+ }
+
hidinput = list_first_entry(&hid->inputs, struct hid_input, list);
set_bit(FF_RUMBLE, hidinput->input->ffbit);