summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorTerry Junge <linuxhid@cosmicgizmosystems.com>2025-03-13 01:23:31 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-06-19 16:28:44 +0300
commit4fa7831cf0ac71a0a345369d1a6084f2b096e55e (patch)
tree298dacf6cf94c7a90c7dc076758fe54b4150b84e /include/linux
parentdd4b8e05f2a251b05bc3b2130095d87e98199866 (diff)
downloadlinux-4fa7831cf0ac71a0a345369d1a6084f2b096e55e.tar.xz
HID: usbhid: Eliminate recurrent out-of-bounds bug in usbhid_parse()
commit fe7f7ac8e0c708446ff017453add769ffc15deed upstream. Update struct hid_descriptor to better reflect the mandatory and optional parts of the HID Descriptor as per USB HID 1.11 specification. Note: the kernel currently does not parse any optional HID class descriptors, only the mandatory report descriptor. Update all references to member element desc[0] to rpt_desc. Add test to verify bLength and bNumDescriptors values are valid. Replace the for loop with direct access to the mandatory HID class descriptor member for the report descriptor. This eliminates the possibility of getting an out-of-bounds fault. Add a warning message if the HID descriptor contains any unsupported optional HID class descriptors. Reported-by: syzbot+c52569baf0c843f35495@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=c52569baf0c843f35495 Fixes: f043bfc98c19 ("HID: usbhid: fix out-of-bounds bug") Cc: stable@vger.kernel.org Signed-off-by: Terry Junge <linuxhid@cosmicgizmosystems.com> Reviewed-by: Michael Kelley <mhklinux@outlook.com> Signed-off-by: Jiri Kosina <jkosina@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/hid.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/include/linux/hid.h b/include/linux/hid.h
index 38e161a827bd..5d37e2349fae 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -736,8 +736,9 @@ struct hid_descriptor {
__le16 bcdHID;
__u8 bCountryCode;
__u8 bNumDescriptors;
+ struct hid_class_descriptor rpt_desc;
- struct hid_class_descriptor desc[1];
+ struct hid_class_descriptor opt_descs[];
} __attribute__ ((packed));
#define HID_DEVICE(b, g, ven, prod) \