History

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.

Kees Cook committed 3 years ago

Commit 09b69dd1 parent df49f2a1 file · +4 −1Browse files

Showing the changes to include/uapi (1 of 1 file). Show all

Unified · Split

include/uapi/linux/usb/ch9.h+4−1
@@ -376,7 +376,10 @@ struct usb_string_descriptor { · 375 unmodified lines
376376 __u8 bLength;
377377 __u8 bDescriptorType;
378378
379− __le16 wData[1]; /* UTF-16LE encoded */
379+ union {
380+ __le16 legacy_padding;
381+ __DECLARE_FLEX_ARRAY(__le16, wData); /* UTF-16LE encoded */
382+ };
380383 } __attribute__ ((packed));
381384
382385 /* note that "string" zero is special, it holds language codes that

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t