Skip to content

Commit 01f23c5

Browse files
committed
usb: ch9: Replace bmSublinkSpeedAttr 1-element array with flexible array
Since commit 2d47c69 ("ubsan: Tighten UBSAN_BOUNDS on GCC"), UBSAN_BOUNDS no longer pretends 1-element arrays are unbounded. Walking bmSublinkSpeedAttr will trigger a warning, so make it a proper flexible array. Add a union to keep the struct size identical for userspace in case anything was depending on the old size. False positive warning was: UBSAN: array-index-out-of-bounds in drivers/usb/host/xhci-hub.c:231:31 index 1 is out of range for type '__le32 [1]' for this line of code: ssp_cap->bmSublinkSpeedAttr[offset++] = cpu_to_le32(attr); Reported-by: Borislav Petkov <[email protected]> Closes: https://lore.kernel.org/lkml/2023062945-fencing-pebble-0411@gregkh/ Reported-by: Mirsad Todorovac <[email protected]> Closes: https://lore.kernel.org/lkml/[email protected]/ Cc: Greg Kroah-Hartman <[email protected]> Cc: "Gustavo A. R. Silva" <[email protected]> Tested-by: "Borislav Petkov (AMD)" <[email protected]> Tested-by: Mirsad Todorovac <[email protected]> Reviewed-by: "Gustavo A. R. Silva" <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Kees Cook <[email protected]>
1 parent 5e2956e commit 01f23c5

File tree

1 file changed

+5
-1
lines changed
  • include/uapi/linux/usb

1 file changed

+5
-1
lines changed

include/uapi/linux/usb/ch9.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,11 @@ struct usb_ssp_cap_descriptor {
981981
#define USB_SSP_MIN_RX_LANE_COUNT (0xf << 8)
982982
#define USB_SSP_MIN_TX_LANE_COUNT (0xf << 12)
983983
__le16 wReserved;
984-
__le32 bmSublinkSpeedAttr[1]; /* list of sublink speed attrib entries */
984+
union {
985+
__le32 legacy_padding;
986+
/* list of sublink speed attrib entries */
987+
__DECLARE_FLEX_ARRAY(__le32, bmSublinkSpeedAttr);
988+
};
985989
#define USB_SSP_SUBLINK_SPEED_SSID (0xf) /* sublink speed ID */
986990
#define USB_SSP_SUBLINK_SPEED_LSE (0x3 << 4) /* Lanespeed exponent */
987991
#define USB_SSP_SUBLINK_SPEED_LSE_BPS 0

0 commit comments

Comments
 (0)