KSPP / linux

Linux kernel source tree (Kernel Self Protection Project)
https://kernsec.org/wiki/index.php/Kernel_Self_Protection_Project
Other
80 stars 5 forks source link

Replace fake flexible array with C99 flexible-array member in drivers/usb/host/oxu210hp-hcd.c #259

Closed GustavoARSilva closed 1 year ago

GustavoARSilva commented 1 year ago
93 /* Section 2.2 Host Controller Capability Registers */
  94 struct ehci_caps {
  95         /* these fields are specified as 8 and 16 bit registers,
  96          * but some hosts can't perform 8 or 16 bit PCI accesses.
  97          */
  98         u32             hc_capbase;
...
 167         /* CONFIGFLAG: offset 0x40 */
 168         u32             configured_flag;
 169 #define FLAG_CF         (1<<0)          /* true: we'll support "high speed" */
 170 
 171         /* PORTSC: offset 0x44 */
 172         u32             port_status[0]; /* up to N_PORTS */
...
 197 } __packed;

-Warray-bounds warnings with GCC-13 and -fstrict-flex-arrays=3:

drivers/usb/host/oxu210hp-hcd.c:3983:30: warning: array subscript i is outside array bounds of ‘u32[0]’ {aka ‘unsigned int[]’} [-Warray-bounds=]
drivers/usb/host/oxu210hp-hcd.c:3986:38: warning: array subscript i is outside array bounds of ‘u32[0]’ {aka ‘unsigned int[]’} [-Warray-bounds=]
drivers/usb/host/oxu210hp-hcd.c:3971:30: warning: array subscript i is outside array bounds of ‘u32[0]’ {aka ‘unsigned int[]’} [-Warray-bounds=]
drivers/usb/host/oxu210hp-hcd.c:3978:30: warning: array subscript i is outside array bounds of ‘u32[0]’ {aka ‘unsigned int[]’} [-Warray-bounds=]
drivers/usb/host/oxu210hp-hcd.c:3523:30: warning: array subscript i is outside array bounds of ‘u32[0]’ {aka ‘unsigned int[]’} [-Warray-bounds=]
drivers/usb/host/oxu210hp-hcd.c:2774:39: warning: array subscript port is outside array bounds of ‘u32[0]’ {aka ‘unsigned int[]’} [-Warray-bounds=]
drivers/usb/host/oxu210hp-hcd.c:3569:35: warning: array subscript <unknown> is outside array bounds of ‘u32[0]’ {aka ‘unsigned int[]’} [-Warray-bounds=]
drivers/usb/host/oxu210hp-hcd.c:3888:36: warning: array subscript port is outside array bounds of ‘u32[0]’ {aka ‘unsigned int[]’} [-Warray-bounds=]
drivers/usb/host/oxu210hp-hcd.c:2911:45: warning: array subscript i is outside array bounds of ‘u32[0]’ {aka ‘unsigned int[]’} [-Warray-bounds=]
GustavoARSilva commented 1 year ago

https://lore.kernel.org/linux-hardening/Y%2FgynI9Wv8RZTD8M@work/