HID: hid-thrustmaster: Fix warning in thrustmaster_probe by adding endpoint check
authorKarol Przybylski <karprzy7@gmail.com>
Thu, 5 Dec 2024 22:22:21 +0000 (23:22 +0100)
committerJiri Kosina <jkosina@suse.com>
Thu, 9 Jan 2025 08:57:35 +0000 (09:57 +0100)
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: syzbot+040e8b3db6a96908d470@syzkaller.appspotmail.com
Tested-by: syzbot+040e8b3db6a96908d470@syzkaller.appspotmail.com
Signed-off-by: Karol Przybylski <karprzy7@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
drivers/hid/hid-thrustmaster.c

index cf1679b0d4fbb5194e1aa4d63c62db88a09f2b8b..6c3e758bbb09e3a2cec0b44d125d05a7e5b18ae6 100644 (file)
@@ -170,6 +170,14 @@ 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]);