Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: config: fix iteration issue in 'usb_get_bos_descriptor()'

The BOS descriptor defines a root descriptor and is the base descriptor for
accessing a family of related descriptors.

Function 'usb_get_bos_descriptor()' encounters an iteration issue when
skipping the 'USB_DT_DEVICE_CAPABILITY' descriptor type. This results in
the same descriptor being read repeatedly.

To address this issue, a 'goto' statement is introduced to ensure that the
pointer and the amount read is updated correctly. This ensures that the
function iterates to the next descriptor instead of reading the same
descriptor repeatedly.

Cc: stable@vger.kernel.org
Fixes: 3dd550a2d365 ("USB: usbcore: Fix slab-out-of-bounds bug during device reset")
Signed-off-by: Niklas Neronin <niklas.neronin@linux.intel.com>
Acked-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/20231115121325.471454-1-niklas.neronin@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Niklas Neronin and committed by
Greg Kroah-Hartman
974bba5c 791cd7af

+2 -1
+2 -1
drivers/usb/core/config.c
··· 1047 1047 1048 1048 if (cap->bDescriptorType != USB_DT_DEVICE_CAPABILITY) { 1049 1049 dev_notice(ddev, "descriptor type invalid, skip\n"); 1050 - continue; 1050 + goto skip_to_next_descriptor; 1051 1051 } 1052 1052 1053 1053 switch (cap_type) { ··· 1078 1078 break; 1079 1079 } 1080 1080 1081 + skip_to_next_descriptor: 1081 1082 total_len -= length; 1082 1083 buffer += length; 1083 1084 }