summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Skripkin <paskripkin@gmail.com>2022-02-20 19:01:14 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-03-16 14:26:40 +0100
commit56185434e1e50acecee56d8f5850135009b87947 (patch)
treec3d5870246044766398065b55e0aad737a9105fe
parentec7332452d905e546bde5ad0f48515c551717828 (diff)
downloadlinux-stable-56185434e1e50acecee56d8f5850135009b87947.tar.gz
linux-stable-56185434e1e50acecee56d8f5850135009b87947.tar.bz2
linux-stable-56185434e1e50acecee56d8f5850135009b87947.zip
HID: hid-thrustmaster: fix OOB read in thrustmaster_interrupts
[ Upstream commit fc3ef2e3297b3c0e2006b5d7b3d66965e3392036 ] 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: c49c33637802 ("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/hid/hid-thrustmaster.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/hid/hid-thrustmaster.c b/drivers/hid/hid-thrustmaster.c
index 03b935ff02d5..9da4240530dd 100644
--- a/drivers/hid/hid-thrustmaster.c
+++ b/drivers/hid/hid-thrustmaster.c
@@ -158,6 +158,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;