Skip to content

Commit

Permalink
HID: hid-thrustmaster: fix OOB read in thrustmaster_interrupts
Browse files Browse the repository at this point in the history
Syzbot reported an slab-out-of-bounds Read in thrustmaster_probe() bug.
The root case is in missing validation check of actual number of endpoints.

Code should not blindly access usb_host_interface::endpoint array, since
it may contain less endpoints than code expects.

Fix it by adding missing validaion check and print an error if
number of endpoints do not match expected number

Fixes: c49c336 ("HID: support for initialization of some Thrustmaster wheels")
Reported-and-tested-by: syzbot+35eebd505e97d315d01c@syzkaller.appspotmail.com
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Pavel Skripkin authored and Jiri Kosina committed Feb 21, 2022
1 parent ac89895 commit fc3ef2e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/hid/hid-thrustmaster.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ static void thrustmaster_interrupts(struct hid_device *hdev)
return;
}

if (usbif->cur_altsetting->desc.bNumEndpoints < 2) {
kfree(send_buf);
hid_err(hdev, "Wrong number of endpoints?\n");
return;
}

ep = &usbif->cur_altsetting->endpoint[1];
b_ep = ep->desc.bEndpointAddress;

Expand Down

0 comments on commit fc3ef2e

Please sign in to comment.