]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
HID: usbhid: Eliminate recurrent out-of-bounds bug in usbhid_parse()
authorTerry Junge <linuxhid@cosmicgizmosystems.com>
Wed, 12 Mar 2025 22:23:31 +0000 (15:23 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Jun 2025 10:05:34 +0000 (11:05 +0100)
commit1df80d748f984290c895e843401824215dcfbfb0
treedf5b8fbc1a672088d20644f68886594d97bbda25
parent287b4f085d2ca3375cf1ee672af27410c64777e8
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: Terry Junge <linuxhid@cosmicgizmosystems.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hid/hid-hyperv.c
drivers/hid/usbhid/hid-core.c
drivers/usb/gadget/function/f_hid.c
include/linux/hid.h