Skip to contentSkip to conversation

HID: hid-thrustmaster: add endpoint check in thrustmaster_interrupts

PATCH In review Karol Przybylski 1 participant 2 messages Oct 20, 2024 – Nov 13, 2024

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

PATCH 1/1 HID: hid-thrustmaster: add endpoint check in thrustmaster_interrupts

syzbot has found a type mismatch between a USB pipe and the transfer endpoint, which is triggered by the hid-thrustmaster driver[1]. There is a number of similar, already fixed issues [2].
In this case as in others, implementing check for endpoint type fixes the issue.

[1] https://syzkaller.appspot.com/bug?extid=040e8b3db6a96908d470
[2] https://syzkaller.appspot.com/bug?extid=348331f63b034f89b622

Fixes c49c33637802 ("HID: support for initialization of some Thrustmaster wheels")
Reported-by [email protected]
---
 drivers/hid/hid-thrustmaster.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/hid/hid-thrustmaster.c +7 -0
index cf1679b0d4fb..f948189394ef 100644
@@ -170,6 +170,13 @@ static void thrustmaster_interrupts(struct hid_device *hdev)
 	ep = &usbif->cur_altsetting->endpoint[1];
 	b_ep = ep->desc.bEndpointAddress;
 
+	/* Are the expected endpoints present? */
+	u8 ep_addr[1] = {b_ep};
+	if (!usb_check_int_endpoints(usbif, ep_addr)) {
+		hid_err(hdev, "Unexpected non-int endpoint\n");
+		return;
+	}
+
 	for (i = 0; i < ARRAY_SIZE(setup_arr); ++i) {
 		memcpy(send_buf, setup_arr[i], setup_arr_sizes[i]);
 
Signature · 1 line
2.34.1
author
#1 lore raw
Quoted 36 lines · Karol Przybylski

syzbot has found a type mismatch between a USB pipe and the transfer endpoint, which is triggered by the hid-thrustmaster driver[1]. There is a number of similar, already fixed issues [2].
In this case as in others, implementing check for endpoint type fixes the issue.

[1] https://syzkaller.appspot.com/bug?extid=040e8b3db6a96908d470
[2] https://syzkaller.appspot.com/bug?extid=348331f63b034f89b622

Fixes c49c33637802 ("HID: support for initialization of some Thrustmaster wheels")
Reported-by [email protected]
---
 drivers/hid/hid-thrustmaster.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/hid/hid-thrustmaster.c +7 -1
index cf1679b0d4fb..f948189394ef 100644
@@ -170,6 +170,13 @@ static void thrustmaster_interrupts(struct hid_device *hdev)
        ep = &usbif->cur_altsetting->endpoint[1];
        b_ep = ep->desc.bEndpointAddress;
 
+       /* Are the expected endpoints present? */
+       u8 ep_addr[1] = {b_ep};
+       if (!usb_check_int_endpoints(usbif, ep_addr)) {
+               hid_err(hdev, "Unexpected non-int endpoint\n");
+               return;
+       }
+
        for (i = 0; i < ARRAY_SIZE(setup_arr); ++i) {
                memcpy(send_buf, setup_arr[i], setup_arr_sizes[i]);
 
--
Quoted 2 lines

2.34.1

Any feedback regarding this patch is appreciated. I was wondering if I should declare an additional u8 array or maybe just do inline conversion.

Best regards,
Karol