netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mlxsw: spectrum_router: Replace 0-length array with flexible array
@ 2023-01-05 23:22 Kees Cook
  2023-01-06 10:02 ` Petr Machata
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Kees Cook @ 2023-01-05 23:22 UTC (permalink / raw)
  To: Ido Schimmel
  Cc: Kees Cook, Petr Machata, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Gustavo A. R. Silva, netdev,
	linux-kernel, linux-hardening

Zero-length arrays are deprecated[1]. Replace struct
mlxsw_sp_nexthop_group_info's "nexthops" 0-length array with a flexible
array. Detected with GCC 13, using -fstrict-flex-arrays=3:

drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c: In function 'mlxsw_sp_nexthop_group_hash_obj':
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:3278:38: warning: array subscript i is outside array bounds of 'struct mlxsw_sp_nexthop[0]' [-Warray-bounds=]
 3278 |                         val ^= jhash(&nh->ifindex, sizeof(nh->ifindex), seed);
      |                                      ^~~~~~~~~~~~
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:2954:33: note: while referencing 'nexthops'
 2954 |         struct mlxsw_sp_nexthop nexthops[0];
      |                                 ^~~~~~~~

[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays

Cc: Ido Schimmel <idosch@nvidia.com>
Cc: Petr Machata <petrm@nvidia.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: netdev@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
index c22c3ac4e2a1..09e32778b012 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
@@ -2951,7 +2951,7 @@ struct mlxsw_sp_nexthop_group_info {
 	   gateway:1, /* routes using the group use a gateway */
 	   is_resilient:1;
 	struct list_head list; /* member in nh_res_grp_list */
-	struct mlxsw_sp_nexthop nexthops[0];
+	struct mlxsw_sp_nexthop nexthops[];
 #define nh_rif	nexthops[0].rif
 };
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] mlxsw: spectrum_router: Replace 0-length array with flexible array
  2023-01-05 23:22 [PATCH] mlxsw: spectrum_router: Replace 0-length array with flexible array Kees Cook
@ 2023-01-06 10:02 ` Petr Machata
  2023-01-07 22:44   ` Petr Machata
  2023-01-06 10:10 ` Ido Schimmel
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Petr Machata @ 2023-01-06 10:02 UTC (permalink / raw)
  To: Kees Cook
  Cc: Ido Schimmel, Petr Machata, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Gustavo A. R. Silva, netdev,
	linux-kernel, linux-hardening


Kees Cook <keescook@chromium.org> writes:

> Zero-length arrays are deprecated[1]. Replace struct
> mlxsw_sp_nexthop_group_info's "nexthops" 0-length array with a flexible
> array. Detected with GCC 13, using -fstrict-flex-arrays=3:
>
> drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c: In function 'mlxsw_sp_nexthop_group_hash_obj':
> drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:3278:38: warning: array subscript i is outside array bounds of 'struct mlxsw_sp_nexthop[0]' [-Warray-bounds=]
>  3278 |                         val ^= jhash(&nh->ifindex, sizeof(nh->ifindex), seed);
>       |                                      ^~~~~~~~~~~~
> drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:2954:33: note: while referencing 'nexthops'
>  2954 |         struct mlxsw_sp_nexthop nexthops[0];
>       |                                 ^~~~~~~~
>
> [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays
>
> Cc: Ido Schimmel <idosch@nvidia.com>
> Cc: Petr Machata <petrm@nvidia.com>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
> Cc: netdev@vger.kernel.org
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
>  drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
> index c22c3ac4e2a1..09e32778b012 100644
> --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
> +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
> @@ -2951,7 +2951,7 @@ struct mlxsw_sp_nexthop_group_info {
>  	   gateway:1, /* routes using the group use a gateway */
>  	   is_resilient:1;
>  	struct list_head list; /* member in nh_res_grp_list */
> -	struct mlxsw_sp_nexthop nexthops[0];
> +	struct mlxsw_sp_nexthop nexthops[];
>  #define nh_rif	nexthops[0].rif
>  };

Thanks. I'll pass this through our nightly and report back.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] mlxsw: spectrum_router: Replace 0-length array with flexible array
  2023-01-05 23:22 [PATCH] mlxsw: spectrum_router: Replace 0-length array with flexible array Kees Cook
  2023-01-06 10:02 ` Petr Machata
@ 2023-01-06 10:10 ` Ido Schimmel
  2023-01-06 16:12 ` Gustavo A. R. Silva
  2023-01-09  7:40 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 6+ messages in thread
From: Ido Schimmel @ 2023-01-06 10:10 UTC (permalink / raw)
  To: Kees Cook
  Cc: Petr Machata, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Gustavo A. R. Silva, netdev, linux-kernel,
	linux-hardening

On Thu, Jan 05, 2023 at 03:22:29PM -0800, Kees Cook wrote:
> Zero-length arrays are deprecated[1]. Replace struct
> mlxsw_sp_nexthop_group_info's "nexthops" 0-length array with a flexible
> array. Detected with GCC 13, using -fstrict-flex-arrays=3:
> 
> drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c: In function 'mlxsw_sp_nexthop_group_hash_obj':
> drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:3278:38: warning: array subscript i is outside array bounds of 'struct mlxsw_sp_nexthop[0]' [-Warray-bounds=]
>  3278 |                         val ^= jhash(&nh->ifindex, sizeof(nh->ifindex), seed);
>       |                                      ^~~~~~~~~~~~
> drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:2954:33: note: while referencing 'nexthops'
>  2954 |         struct mlxsw_sp_nexthop nexthops[0];
>       |                                 ^~~~~~~~
> 
> [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays
> 
> Cc: Ido Schimmel <idosch@nvidia.com>
> Cc: Petr Machata <petrm@nvidia.com>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
> Cc: netdev@vger.kernel.org
> Signed-off-by: Kees Cook <keescook@chromium.org>

Reviewed-by: Ido Schimmel <idosch@nvidia.com>

Thanks

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] mlxsw: spectrum_router: Replace 0-length array with flexible array
  2023-01-05 23:22 [PATCH] mlxsw: spectrum_router: Replace 0-length array with flexible array Kees Cook
  2023-01-06 10:02 ` Petr Machata
  2023-01-06 10:10 ` Ido Schimmel
@ 2023-01-06 16:12 ` Gustavo A. R. Silva
  2023-01-09  7:40 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 6+ messages in thread
From: Gustavo A. R. Silva @ 2023-01-06 16:12 UTC (permalink / raw)
  To: Kees Cook
  Cc: Ido Schimmel, Petr Machata, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, netdev, linux-kernel,
	linux-hardening

On Thu, Jan 05, 2023 at 03:22:29PM -0800, Kees Cook wrote:
> Zero-length arrays are deprecated[1]. Replace struct
> mlxsw_sp_nexthop_group_info's "nexthops" 0-length array with a flexible
> array. Detected with GCC 13, using -fstrict-flex-arrays=3:
> 
> drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c: In function 'mlxsw_sp_nexthop_group_hash_obj':
> drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:3278:38: warning: array subscript i is outside array bounds of 'struct mlxsw_sp_nexthop[0]' [-Warray-bounds=]
>  3278 |                         val ^= jhash(&nh->ifindex, sizeof(nh->ifindex), seed);
>       |                                      ^~~~~~~~~~~~
> drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:2954:33: note: while referencing 'nexthops'
>  2954 |         struct mlxsw_sp_nexthop nexthops[0];
>       |                                 ^~~~~~~~
> 
> [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays
> 
> Cc: Ido Schimmel <idosch@nvidia.com>
> Cc: Petr Machata <petrm@nvidia.com>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
> Cc: netdev@vger.kernel.org
> Signed-off-by: Kees Cook <keescook@chromium.org>

Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Thanks!
--
Gustavo

> ---
>  drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
> index c22c3ac4e2a1..09e32778b012 100644
> --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
> +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
> @@ -2951,7 +2951,7 @@ struct mlxsw_sp_nexthop_group_info {
>  	   gateway:1, /* routes using the group use a gateway */
>  	   is_resilient:1;
>  	struct list_head list; /* member in nh_res_grp_list */
> -	struct mlxsw_sp_nexthop nexthops[0];
> +	struct mlxsw_sp_nexthop nexthops[];
>  #define nh_rif	nexthops[0].rif
>  };
>  
> -- 
> 2.34.1
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] mlxsw: spectrum_router: Replace 0-length array with flexible array
  2023-01-06 10:02 ` Petr Machata
@ 2023-01-07 22:44   ` Petr Machata
  0 siblings, 0 replies; 6+ messages in thread
From: Petr Machata @ 2023-01-07 22:44 UTC (permalink / raw)
  To: Petr Machata
  Cc: Kees Cook, Ido Schimmel, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Gustavo A. R. Silva, netdev,
	linux-kernel, linux-hardening


Petr Machata <petrm@nvidia.com> writes:

> Kees Cook <keescook@chromium.org> writes:
>
>> Zero-length arrays are deprecated[1]. Replace struct
>> mlxsw_sp_nexthop_group_info's "nexthops" 0-length array with a flexible
>> array.

[...]

> Thanks. I'll pass this through our nightly and report back.

Looking good.

Tested-by: Petr Machata <petrm@nvidia.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] mlxsw: spectrum_router: Replace 0-length array with flexible array
  2023-01-05 23:22 [PATCH] mlxsw: spectrum_router: Replace 0-length array with flexible array Kees Cook
                   ` (2 preceding siblings ...)
  2023-01-06 16:12 ` Gustavo A. R. Silva
@ 2023-01-09  7:40 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-01-09  7:40 UTC (permalink / raw)
  To: Kees Cook
  Cc: idosch, petrm, davem, edumazet, kuba, pabeni, gustavoars, netdev,
	linux-kernel, linux-hardening

Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:

On Thu,  5 Jan 2023 15:22:29 -0800 you wrote:
> Zero-length arrays are deprecated[1]. Replace struct
> mlxsw_sp_nexthop_group_info's "nexthops" 0-length array with a flexible
> array. Detected with GCC 13, using -fstrict-flex-arrays=3:
> 
> drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c: In function 'mlxsw_sp_nexthop_group_hash_obj':
> drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:3278:38: warning: array subscript i is outside array bounds of 'struct mlxsw_sp_nexthop[0]' [-Warray-bounds=]
>  3278 |                         val ^= jhash(&nh->ifindex, sizeof(nh->ifindex), seed);
>       |                                      ^~~~~~~~~~~~
> drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c:2954:33: note: while referencing 'nexthops'
>  2954 |         struct mlxsw_sp_nexthop nexthops[0];
>       |                                 ^~~~~~~~
> 
> [...]

Here is the summary with links:
  - mlxsw: spectrum_router: Replace 0-length array with flexible array
    https://git.kernel.org/netdev/net/c/2ab6478d1266

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-01-09  7:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-05 23:22 [PATCH] mlxsw: spectrum_router: Replace 0-length array with flexible array Kees Cook
2023-01-06 10:02 ` Petr Machata
2023-01-07 22:44   ` Petr Machata
2023-01-06 10:10 ` Ido Schimmel
2023-01-06 16:12 ` Gustavo A. R. Silva
2023-01-09  7:40 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).