Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp2631051rwl; Fri, 6 Jan 2023 08:57:08 -0800 (PST) X-Google-Smtp-Source: AMrXdXtEsvVgxiOemnFNuDcvi9Po9shGF6HES7I6UFZZLQnBor2jSHRiCcMZ9VxIwyshPY7XOh02 X-Received: by 2002:a17:902:b402:b0:188:d434:9c67 with SMTP id x2-20020a170902b40200b00188d4349c67mr54720054plr.32.1673024228262; Fri, 06 Jan 2023 08:57:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673024228; cv=none; d=google.com; s=arc-20160816; b=tLMoianb2xLm9PzF9Iz4gQAB4P/mthRk2IWPoVKR3g9sU/Cw3NvhpS5EVNwjkrC6Ny IK1nB0iG8ejfR4Hk2NhN84Da1ME1smHpq+pp6v5FbIWImmcW6qn2DTWL8JuR4EqouqUc m5xu+Xh50GKvnfCoAKCdIwhjx3kRPicyXVxHwRuLXRB9KwCBmdHNT+upqQBCI/bSh98H 4l8ewa5qbh4OnwTU3IXG5vp6HIAYK1bKE6bdhUUNKWg5xkgVHws/GRy82eKvCpYjFkqN F7FYDyOf1bFgHRIo9Z/g33MwNiKkrutzNtOALxCge20Mn9TWerQuJxgpEFgrIKa0InL0 RRww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=HoXoO9ybnTiUl6io77nHEppgl5Q6R5X3zgI2Jlxqmis=; b=gZKbR2n6udsh/ZOSexk89UJcTxX9ySxnA28UnGYv9mF7tzwS+4UMcVY4n7Apw75V8w yrj/Zqi/ikaGmhaj0Yo2oRY+uWJ7GQiJogK3iIuhaRBtk7XAsO/ZeEdp2e33aTw6kkG9 b+gPd36XckPkQooWDM74ajnPpmozr08s6SKHicxic6R1MErd2ShjmwM8AOKCr4nfzhk2 yIQjCH6qywe7rAQl32GycopQIVpK9VS5k5tn6mdYuSusouJo8FiJlNnSvHUSF3dfs0tW xxsA1kM1+iAUmR77vNfrQc1ssfdkBZ/LHKU2vFmW24InT3N29u7DisPcTTqqc0OYDnBc pwgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UuhiSQBW; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q15-20020a170902dacf00b00188c26e5be1si1490943plx.551.2023.01.06.08.57.01; Fri, 06 Jan 2023 08:57:08 -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=@kernel.org header.s=k20201202 header.b=UuhiSQBW; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235273AbjAFQMq (ORCPT + 54 others); Fri, 6 Jan 2023 11:12:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234959AbjAFQMm (ORCPT ); Fri, 6 Jan 2023 11:12:42 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E940F3225F; Fri, 6 Jan 2023 08:12:41 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A2950B81C48; Fri, 6 Jan 2023 16:12:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39E16C433F0; Fri, 6 Jan 2023 16:12:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673021559; bh=d+IS0UN4ZSAffMlwGmeTMowayqSMiw0tGirs4J36qaE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UuhiSQBWy4c/P+Po6LKtVKtT3EkOd+24eEUe3Rgbz67oKs8yULtWTwhRZ0C52gdDP FwHaxIbXF5Jh2jN8HPFh73dnwIQoBh/HZXfBiYeHmCDcOcXrQD93WFva7TZVVC1aQM hBDC2ApuhuVAtcGLdZ2A48cEO/yWzPwmASSBbiqI2Tfs2d1kXqmPtYWkBXec+R5Lu5 LBf7JnD8r76bT2dKadgXp5DxFEijWLIz/zTO9ZHW2HA3FfpLhxFGxfKmi1rbSiO60H 1bMj19Imr8oQNu1D9BeW1xoVv5BDVbJhFryd/apb2Bx24oPHyDL8EOzis2xLa04Hjh LUQZShlBiPosQ== Date: Fri, 6 Jan 2023 10:12:44 -0600 From: "Gustavo A. R. Silva" To: Kees Cook Cc: Ido Schimmel , Petr Machata , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] mlxsw: spectrum_router: Replace 0-length array with flexible array Message-ID: References: <20230105232224.never.150-kees@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230105232224.never.150-kees@kernel.org> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 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 > 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 Reviewed-by: Gustavo A. R. Silva 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 >