Message ID | 20230105232224.never.150-kees@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp544609wrt; Thu, 5 Jan 2023 15:34:47 -0800 (PST) X-Google-Smtp-Source: AMrXdXtfNv3KTdOQOU/dYPAvflWa172TmpAP/VQ3wPPyIiFz1vyzsIx9A1pjzHD0mV7DxDKAlI2s X-Received: by 2002:a17:902:f80c:b0:185:441e:90dd with SMTP id ix12-20020a170902f80c00b00185441e90ddmr59961692plb.67.1672961687274; Thu, 05 Jan 2023 15:34:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672961687; cv=none; d=google.com; s=arc-20160816; b=HCy9/vfme7F0PKuojXdPK5lXDDldoY9nfpliDXts45ACHUJRbvIOP6/rd99x0CXolj 6tGhQHVbP7R5YNxsgSiibDJ8QKE7nDw+bETKGsDOiYrUygL3HmN0pRBTd9B0TDaxWTT5 8w+RvR5zTzOuepxWHkbRP93NPwLtQvrefhoKQAUXPvs6Lpw4/1Eimm8iXpoqZvApETs3 R5EWHj0xOH8KT7P0z8FIhsn4SA0OTP1n5L8l21pY6Cl0GlRSxs48b1Iq8O7KbJkar/w0 vPCUJbePIud15rLBV8E5HvMkhHWFp1E5zpS94OWZ4DmfdHe+onC1n/QYeptxY2rQ3nk5 AjIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=QWqazbyRLoTC8Db/Whc37KnLoFkdsyWjRIzge1/UbpU=; b=lBJ1HUT0Xr1Ljz8dMdFkgErkQejQ6Xl14iLQm00Set8KTQH0IGTHJ2l+3B/zNXxLSP +ua4yvWg4vjb6uY17ZrSgnSwyN2fooCTBepWIdEvIVbOdFdsLcct+WcwNypSL4fd0k/H gs1vzPkTC9Bs2O+vj1HD418Fj5Syu/icW5/t9M87W8IeOw9qB82xGb0w7AXXYTpPAseA eS/IB01ANB/j7vVKT1WNC7XAqnaHIl6hLxBBrf3HFhOTouD/9m5XBGkcakaiDsjXj7tL 61ZMpfKoJCNv9Wp5aEVlfmoMilKE+OGR3j4pBwEBW1WF8g8V9d6R0FI8zg5DNFHCBrpM 5pqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=VnP0aHc4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g7-20020a1709029f8700b00189891763f3si36668281plq.600.2023.01.05.15.34.29; Thu, 05 Jan 2023 15:34:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=VnP0aHc4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235681AbjAEXWk (ORCPT <rfc822;tmhikaru@gmail.com> + 99 others); Thu, 5 Jan 2023 18:22:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230402AbjAEXWc (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 5 Jan 2023 18:22:32 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A053269516 for <linux-kernel@vger.kernel.org>; Thu, 5 Jan 2023 15:22:31 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id o21so11348632pjw.0 for <linux-kernel@vger.kernel.org>; Thu, 05 Jan 2023 15:22:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=QWqazbyRLoTC8Db/Whc37KnLoFkdsyWjRIzge1/UbpU=; b=VnP0aHc4axpEKI97b+IZ6oWN+okfDvFssMTLbHzN1OGnrqMPIb5h1awy2f07zRIQ4C icvlH9o1vRj7vrO9ELlRp1Xq0S33XjDuaBdRVjnqLg4SuSZuqU0V/qlkYFJQQstBeRRB R8NVulvpT2OY9NfJ3exH2qhtJveVptIOOHduA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=QWqazbyRLoTC8Db/Whc37KnLoFkdsyWjRIzge1/UbpU=; b=qnhXZ6hHRKbpUBk5L2yWM7E5fxrfX/HH0Km89Im1nG5mOF/GY844VtRFBwNrwlUH0u gdVJ3M7geFwZJuEs4aPNWXlgFkpQrzPtAYbLEsIqOYnExkO5OmbkgtaFpXPpUABbDUAZ px2pfKP5oDZGu8u4+Eh2483JOCGKWTBrI38pnr5Yz5UJZN9C6VcfhMca8BXGfeALDVl0 S6JoZOZYlOKRAvIONK8E+PdEk2F+PzqLwrFJGOg9R1vOhHyaFY5CsaCmPxsuzx7WvwCL +BugSV4e4RjEXUcxL+Vr55mYJ4b5Ll8a++HWMdfR4H8fg2urkuL1gukD628oZoZVT2x2 zXAA== X-Gm-Message-State: AFqh2kp08k5WYNrlwKx1MYPTH7prMLHk4HyYIS5QSehiADFf2rxjXXwY UTk9rwUsRkHvL0+XTItMHC/vsQNzDhaIvNm9 X-Received: by 2002:a17:902:e886:b0:192:fd24:8bb with SMTP id w6-20020a170902e88600b00192fd2408bbmr5499697plg.62.1672960951150; Thu, 05 Jan 2023 15:22:31 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id t12-20020a170902b20c00b001801aec1f6bsm6793044plr.141.2023.01.05.15.22.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 15:22:30 -0800 (PST) From: Kees Cook <keescook@chromium.org> To: Ido Schimmel <idosch@nvidia.com> Cc: Kees Cook <keescook@chromium.org>, Petr Machata <petrm@nvidia.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, "Gustavo A. R. Silva" <gustavoars@kernel.org>, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH] mlxsw: spectrum_router: Replace 0-length array with flexible array Date: Thu, 5 Jan 2023 15:22:29 -0800 Message-Id: <20230105232224.never.150-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2016; h=from:subject:message-id; bh=KtszOhTtBHOJMBXcCf68gEIjIaPlW6ySs3tOC7kDi+Q=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBjt1u072FInbSWvkK9ROyDtbUdMqOT90bc67eQi6SZ JhBI0k6JAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCY7dbtAAKCRCJcvTf3G3AJkbqD/ 9m8DMcoU3/EnqRmO+0JA6ww4B2FpQawFlaOMIre43dMKbaCRiqdqo5mTurO6wxot9WWkwOz7p0V524 wQj9tp7YVXDHj1Vdk6H+fgpw9bDzfaL0JxFuEJrMDNEYpqjI4XrlYZ90En5XBYsqNgBKcHQG+MlkED z4EUXUh6WxBjC4vsXGgD5rNylMDn9jvNkgEUOyy+ljjyuPmxEmRSkyRsyqSAq+Ie+fJTNx/B5GHF55 8VDyc8ambbbn4eGqINNZUW1EdMQDQsi5b8EAfQMVX8B9bcppv8q0javJO4paFRlxNhjx3M6+reDLc+ rEuHeB2cbQRDYE8GEINDJGGkunoSezzKZ2wYZOPx1B6fIEfPrAj9duIdV0NaZkEHqCfAmzTP+B/VYm lQK+kfHYHDsE08/FGRx15VbQrkuSKioY0X0ZPp6MlQyGjRyXOu2qXjFYexxEjftQY4I6ru4I8XILVd KrcmpcXTyPP3R9+3Eu91oH2MaSABeg2pdLpyc57/8r2RBXza4nvGdJTqB/Kb9yL8Zb289T4nz6Gzfi h4QNCEaKdl2lSkkzZ9AxZ2z+dNtAqz5UmjUW4gahE179cK0HlakAUOCjohizdYsAW/7uW9g4Zaeq5x bPrnxgQaH51LS9qtvUrVbNbVSjQlqGOtxFMnDAZWd4qJPyE0Ba3kbJYzmP0g== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754227474094242881?= X-GMAIL-MSGID: =?utf-8?q?1754227474094242881?= |
Series |
mlxsw: spectrum_router: Replace 0-length array with flexible array
|
|
Commit Message
Kees Cook
Jan. 5, 2023, 11:22 p.m. UTC
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(-)
Comments
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.
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
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 >
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>
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!
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 };