Skip to content

Commit

Permalink
HID: betop: fix slab-out-of-bounds Write in betop_probe
Browse files Browse the repository at this point in the history
commit 1e4ce41 upstream.

Syzbot reported slab-out-of-bounds Write bug in hid-betopff driver.
The problem is the driver assumes the device must have an input report but
some malicious devices violate this assumption.

So this patch checks hid_device's input is non empty before it's been used.

Reported-by: syzbot+07efed3bc5a1407bd742@syzkaller.appspotmail.com
Signed-off-by: F.A. SULAIMAN <asha.16@itfac.mrt.ac.lk>
Reviewed-by: Pavel Skripkin <paskripkin@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
F.A.Sulaiman authored and Greg Kroah-Hartman committed Oct 6, 2021
1 parent 6f56486 commit a4faa71
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions drivers/hid/hid-betopff.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,22 @@ static int betopff_init(struct hid_device *hid)
{
struct betopff_device *betopff;
struct hid_report *report;
struct hid_input *hidinput =
list_first_entry(&hid->inputs, struct hid_input, list);
struct hid_input *hidinput;
struct list_head *report_list =
&hid->report_enum[HID_OUTPUT_REPORT].report_list;
struct input_dev *dev = hidinput->input;
struct input_dev *dev;
int field_count = 0;
int error;
int i, j;

if (list_empty(&hid->inputs)) {
hid_err(hid, "no inputs found\n");
return -ENODEV;
}

hidinput = list_first_entry(&hid->inputs, struct hid_input, list);
dev = hidinput->input;

if (list_empty(report_list)) {
hid_err(hid, "no output reports found\n");
return -ENODEV;
Expand Down

0 comments on commit a4faa71

Please sign in to comment.