RE: [Intel-wired-lan] [PATCH] net/i40e: Replace 0-length array with flexible array
From: G, GurucharanX
Date: Thu Jan 19 2023 - 04:47:16 EST
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@xxxxxxxxxx> On Behalf Of
> Kees Cook
> Sent: Friday, January 6, 2023 5:16 AM
> To: Brandeburg, Jesse <jesse.brandeburg@xxxxxxxxx>
> Cc: Kees Cook <keescook@xxxxxxxxxxxx>; intel-wired-lan@xxxxxxxxxxxxxxxx;
> Gustavo A. R. Silva <gustavoars@xxxxxxxxxx>; linux-kernel@xxxxxxxxxxxxxxx;
> Eric Dumazet <edumazet@xxxxxxxxxx>; Nguyen, Anthony L
> <anthony.l.nguyen@xxxxxxxxx>; linux-hardening@xxxxxxxxxxxxxxx;
> netdev@xxxxxxxxxxxxxxx; Jakub Kicinski <kuba@xxxxxxxxxx>; Paolo Abeni
> <pabeni@xxxxxxxxxx>; David S. Miller <davem@xxxxxxxxxxxxx>
> Subject: [Intel-wired-lan] [PATCH] net/i40e: Replace 0-length array with
> flexible array
>
> Zero-length arrays are deprecated[1]. Replace struct i40e_lump_tracking's
> "list" 0-length array with a flexible array. Detected with GCC 13, using -fstrict-
> flex-arrays=3:
>
> In function 'i40e_put_lump',
> inlined from 'i40e_clear_interrupt_scheme' at
> drivers/net/ethernet/intel/i40e/i40e_main.c:5145:2:
> drivers/net/ethernet/intel/i40e/i40e_main.c:278:27: warning: array subscript
> <unknown> is outside array bounds of 'u16[0]' {aka 'short unsigned int[]'} [-
> Warray-bounds=]
> 278 | pile->list[i] = 0;
> | ~~~~~~~~~~^~~
> drivers/net/ethernet/intel/i40e/i40e.h: In function
> 'i40e_clear_interrupt_scheme':
> drivers/net/ethernet/intel/i40e/i40e.h:179:13: note: while referencing 'list'
> 179 | u16 list[0];
> | ^~~~
>
> [1]
> https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-
> length-and-one-element-arrays
>
> Cc: Jesse Brandeburg <jesse.brandeburg@xxxxxxxxx>
> Cc: Tony Nguyen <anthony.l.nguyen@xxxxxxxxx>
> Cc: "David S. Miller" <davem@xxxxxxxxxxxxx>
> Cc: Eric Dumazet <edumazet@xxxxxxxxxx>
> Cc: Jakub Kicinski <kuba@xxxxxxxxxx>
> Cc: Paolo Abeni <pabeni@xxxxxxxxxx>
> Cc: "Gustavo A. R. Silva" <gustavoars@xxxxxxxxxx>
> Cc: intel-wired-lan@xxxxxxxxxxxxxxxx
> Cc: netdev@xxxxxxxxxxxxxxx
> Signed-off-by: Kees Cook <keescook@xxxxxxxxxxxx>
> ---
> drivers/net/ethernet/intel/i40e/i40e.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
Tested-by: Gurucharan G <gurucharanx.g@xxxxxxxxx> (A Contingent worker at Intel)