Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp1592796rwl; Thu, 5 Jan 2023 16:24:31 -0800 (PST) X-Google-Smtp-Source: AMrXdXvwT7z7NiSWbd8GAXuUQCDxnStPB+8rUfall3+cKh4iadd3RwGZh0CXmsq83eIsVwrLy6R/ X-Received: by 2002:a17:907:a788:b0:7fd:ec83:b8b8 with SMTP id vx8-20020a170907a78800b007fdec83b8b8mr46714523ejc.19.1672964670915; Thu, 05 Jan 2023 16:24:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672964670; cv=none; d=google.com; s=arc-20160816; b=Qgi+L8XihHTrItWS1QPIX6gGAfHuxLpPeGZmfNDEFFwmOGMYDUx42g0JAB2M1rSL1z U3d5nlEBQQCGN2BN/yZkSvp42Yk2AKl3Pll7nKvvkULzgPkVL8yMH4Anp6phWcx57CYk ZQXtnHgA60+bQN0BzfVj49LJT3JOHas08l9Tr006bOuvrRLiSAqwhMFpI++xqz2UHmme xEdlbCXSDAQ/+6jLgHLv3h8rGMdfpX+gMsO7eYURdjQDT4p6qhXGf+qi109iDizScino kKISfKjJHFtfNwWbWXmLo9hulRzKzLzHj2r7TgKq9lxH+eng2dd7t3RkFK5B/etqItYY Na2A== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hd39-20020a17090796a700b00779e6c93108si38624952ejc.598.2023.01.05.16.24.17; Thu, 05 Jan 2023 16:24:30 -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 + 55 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 ); 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 ; Thu, 5 Jan 2023 15:22:31 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id o21so11348632pjw.0 for ; 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 To: Ido Schimmel Cc: Kees Cook , Petr Machata , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Gustavo A. R. Silva" , 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: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Petr Machata Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: "Gustavo A. R. Silva" Cc: netdev@vger.kernel.org Signed-off-by: Kees Cook --- 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