From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4EA7C3DA7A for ; Fri, 6 Jan 2023 05:38:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230522AbjAFFih (ORCPT ); Fri, 6 Jan 2023 00:38:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229920AbjAFFie (ORCPT ); Fri, 6 Jan 2023 00:38:34 -0500 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A9D34D714; Thu, 5 Jan 2023 21:38:30 -0800 (PST) Received: by mail-pl1-f170.google.com with SMTP id c4so679752plc.5; Thu, 05 Jan 2023 21:38:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=aUTX3hQ31eJpmnwwb1UwPf65sW8fJfvo/kP6nw0krfk=; b=Au8MT65ShOqUOwsDx16LrkDeCk5efrIoen7LvirJXU6fMqO1Zvq2n5nwsrwWlTFNVm wfvy/bl/b7bvsJ0iIe64y9Df4aTEsG4iGopokx/Sd3CNUmam23iM+Tz+UrqbdxikcrFx T94HD3Uf/gYqIaZWgXMsgEjHIFLRQSDiF+v6DNnMjZymFb7TQDwytF4u69/oZgg4R0V0 oqaB9vfmqDhRogRLC+rdGT2oyYWB/Ua4v8o6RJbrjD/XGjEIe9+MvOxPTst4gTS05D/C 6PMeIp0UkoWpeRu0ifIHq13QKEhrCLPMCRG7Fig6dh4LwPwrNHDhDvCQeLD0VOLkJAnZ mM0g== X-Gm-Message-State: AFqh2kpGTzKePPEgj5bRqTZdJl1gzClX/n8wv40lGlBMdOBvgSMv1C3k HtRYbs8r5q7jUM6V/ZfAH3pqkMOi63ULv+PYGC9o5bx4nBxNkA== X-Google-Smtp-Source: AMrXdXvNcd1XCRKiDs4wrb/kT3sZVAPRhrj+XsEx75wOAoiyXJLo18ALcvUzv4IcoSSBZ0xxms6K2S0SDMBD9Aqcf5E= X-Received: by 2002:a17:90b:2483:b0:226:412e:2ddf with SMTP id nt3-20020a17090b248300b00226412e2ddfmr1633082pjb.19.1672983509489; Thu, 05 Jan 2023 21:38:29 -0800 (PST) MIME-Version: 1.0 References: <20230106042844.give.885-kees@kernel.org> In-Reply-To: <20230106042844.give.885-kees@kernel.org> From: Vincent MAILHOL Date: Fri, 6 Jan 2023 14:38:18 +0900 Message-ID: Subject: Re: [PATCH v3] ethtool: Replace 0-length array with flexible array To: Kees Cook Cc: "David S. Miller" , Jakub Kicinski , Andrew Lunn , kernel test robot , Oleksij Rempel , Sean Anderson , Alexandru Tachici , Amit Cohen , "Gustavo A. R. Silva" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri. 6 Jan 2023 at 13:28, Kees Cook wrote: > Zero-length arrays are deprecated[1]. Replace struct ethtool_rxnfc's > "rule_locs" 0-length array with a flexible array. Detected with GCC 13, > using -fstrict-flex-arrays=3: > > net/ethtool/common.c: In function 'ethtool_get_max_rxnfc_channel': > net/ethtool/common.c:558:55: warning: array subscript i is outside array bounds of '__u32[0]' {aka 'unsigned int[]'} [-Warray-bounds=] > 558 | .fs.location = info->rule_locs[i], > | ~~~~~~~~~~~~~~~^~~ > In file included from include/linux/ethtool.h:19, > from include/uapi/linux/ethtool_netlink.h:12, > from include/linux/ethtool_netlink.h:6, > from net/ethtool/common.c:3: > include/uapi/linux/ethtool.h:1186:41: note: while referencing > 'rule_locs' > 1186 | __u32 rule_locs[0]; > | ^~~~~~~~~ > > [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays Side comment, this link does not mention the __DECLARE_FLEX_ARRAY(). It could be good to add a reference to the helper here. But of course, this is not a criticism of this patch. > Cc: "David S. Miller" > Cc: Jakub Kicinski > Cc: Andrew Lunn > Cc: kernel test robot > Cc: Oleksij Rempel > Cc: Sean Anderson > Cc: Alexandru Tachici > Cc: Amit Cohen > Cc: "Gustavo A. R. Silva" > Cc: Vincent Mailhol > Cc: netdev@vger.kernel.org > Signed-off-by: Kees Cook Reviewed-by: Vincent Mailhol > --- > v3: don't use helper (vincent) You may want to double check your other patches as well. At least this one is also using the helper when not needed: https://lore.kernel.org/netdev/20230105223642.never.980-kees@kernel.org/T/#u > v2: https://lore.kernel.org/lkml/20230105233420.gonna.036-kees@kernel.org > --- > include/uapi/linux/ethtool.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/uapi/linux/ethtool.h b/include/uapi/linux/ethtool.h > index 58e587ba0450..3135fa0ba9a4 100644 > --- a/include/uapi/linux/ethtool.h > +++ b/include/uapi/linux/ethtool.h > @@ -1183,7 +1183,7 @@ struct ethtool_rxnfc { > __u32 rule_cnt; > __u32 rss_context; > }; > - __u32 rule_locs[0]; > + __u32 rule_locs[]; > }; > > > -- > 2.34.1 >