Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp1878302rwl; Thu, 5 Jan 2023 21:51:15 -0800 (PST) X-Google-Smtp-Source: AMrXdXuXchr1xr6b84QoXNJHcYW4+5Gs8sUhRbf5Ac1BxxxzbC8qwbvX0JYt+xoHiFX6KS0UY1Hr X-Received: by 2002:a17:906:4e54:b0:812:d53e:1084 with SMTP id g20-20020a1709064e5400b00812d53e1084mr51611789ejw.70.1672984274850; Thu, 05 Jan 2023 21:51:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672984274; cv=none; d=google.com; s=arc-20160816; b=edqD1cVjzyYvtPB0b1/57qKh8xs+UbAlWjuRbgalQQdGR1lerm0oegALxZVLfDTg8J Qrj9GHVwMHGS8sUQN08lQlD5or36cF1Go09tlh9GF5Nx7TGF/aNQkZagsizxlXmk/E97 guopdRN4yMGwy2mqJnmPzm4JYOgxRdu5+2/b57aRN2dnnNs8mtql15k+HHoip9J1SUTt RnWqARtNVAs0AKFAA/0xGxuAwBXQFqwOYb96urCGMhXrLMEtvu4V4dFGE3gr6pOtbl62 V6zouwFtgghQ9ff+9px+kqi1dM0XUCocztw6TXXbCfsyvfxExSByusUV9FFAsEEKGYbI eDhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=aUTX3hQ31eJpmnwwb1UwPf65sW8fJfvo/kP6nw0krfk=; b=MBkNKK1xVNWPElwAR8dAb5L/1I3hmZo6yPus2gAiQ3oI6ccditpEQjhyiRffu6OsJJ fJMV/p+yP6rKkWfD1QWSUGbTD2v8A8YwriUBlcDOu3dImkPiKpr+v0PTDuFsCRglE8f7 crzaQOyrIbUdaToDUb78FR2oumoAeCBaqic8Wc76cRCzyQpROOylKnGYS/hkpnODX9g6 HMKszMaPxZmDJfpKhH4sGVgC7WTvJYYHv8oOukHln2cyWeAFwNkCy5/op1SV5GWUn+Zt 0uLWdsVLjLnMxqPOYk6z1qn5uMGRDc86gwj7PV4R8ZnR8oQDapklVttoga8Qm+jE/xws qWPA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nc2-20020a1709071c0200b007c0f7b5d8e6si420499ejc.2.2023.01.05.21.51.02; Thu, 05 Jan 2023 21:51:14 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230477AbjAFFig (ORCPT + 54 others); Fri, 6 Jan 2023 00:38:36 -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-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" X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no 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 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 >