usb: ch9: Replace 1-element array with flexible array
PATCH v2 1/1 usb: ch9: Replace 1-element array with flexible array
Since commit df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3"), UBSAN_BOUNDS no longer pretends 1-element arrays are unbounded. Walking wData 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.
Reported-by kernel test robot <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc kernel test robot <[email protected]>
Cc "Gustavo A. R. Silva" <[email protected]>
Cc Dan Williams <[email protected]>
Cc "Jó Ágila Bitsch" <[email protected]>
Signed-off-by Kees Cook <[email protected]>
---
v2: fix commit log to avoid bogus Fixes tag (gustavo, gregkh)
v1: https://lore.kernel.org/all/[email protected]/
--- include/uapi/linux/usb/ch9.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
include/uapi/linux/usb/ch9.h +4 -1
@@ -376,7 +376,10 @@ struct usb_string_descriptor {__u8 bLength;__u8 bDescriptorType; -__le16 wData[1 ];/* UTF-16LE encoded */ +union { +__le16 legacy_padding; + __DECLARE_FLEX_ARRAY(__le16, wData); /* UTF-16LE encoded */ + }; } __attribute__ ((packed));/* note that "string" zero is special, it holds language codes that
Signature · 1 line
2.34.1