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 arrays with C99 flexible-array members in drivers/net/wireless/ath/carl9170/fwcmd.h #267

Closed GustavoARSilva closed 1 year ago

GustavoARSilva commented 1 year ago
315 struct carl9170_rsp {
316         struct carl9170_cmd_head hdr;
317 
318         union {
319                 struct carl9170_rf_init_result  rf_init_res;
320                 struct carl9170_u32_list        rreg_res;
321                 struct carl9170_u32_list        echo;
322 #ifdef __CARL9170FW__
323                 struct carl9170_tx_status       tx_status[0];
324 #endif /* __CARL9170FW__ */
325                 struct _carl9170_tx_status      _tx_status[0];
326                 struct carl9170_gpio            gpio;
327                 struct carl9170_tsf_rsp         tsf;
328                 struct carl9170_psm             psm;
329                 struct carl9170_tally_rsp       tally;
330                 u8 data[CARL9170_MAX_CMD_PAYLOAD_LEN];
331         } __packed;
332 } __packed __aligned(4);

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

drivers/net/wireless/ath/carl9170/tx.c:702:61: warning: array subscript i is outside array bounds of ‘const struct _carl9170_tx_status[0]’ [-Warray-bounds=]
drivers/net/wireless/ath/carl9170/tx.c:701:65: warning: array subscript i is outside array bounds of ‘const struct _carl9170_tx_status[0]’ [-Warray-bounds=]
GustavoARSilva commented 1 year ago

Patch: https://lore.kernel.org/linux-hardening/ZBSl2M+aGIO1fnuG@work/