Skip to contentSkip to conversation

HID: hid-thrustmaster: fix OOB read in thrustmaster_interrupts

PATCH New Pavel Skripkin 1 participant 1 message Feb 20, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HID: hid-thrustmaster: fix OOB read in thrustmaster_interrupts

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 [email protected]
---
 drivers/hid/hid-thrustmaster.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/hid/hid-thrustmaster.c +6 -0
index 03b935ff02d5..9da4240530dd 100644
@@ -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;
 
Signature · 1 line
2.35.1