From patchwork Fri Jan 6 04:28:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 39934 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp638223wrt; Thu, 5 Jan 2023 20:49:06 -0800 (PST) X-Google-Smtp-Source: AMrXdXt1PJliaVnILuWnAXCBgfge/DJyGRrxFzjKDhvSQrA2E/tjVJunT+EWA4NVFRHdYd9OGUIk X-Received: by 2002:a17:90b:3597:b0:219:b1f0:ddf0 with SMTP id mm23-20020a17090b359700b00219b1f0ddf0mr57890668pjb.36.1672980546307; Thu, 05 Jan 2023 20:49:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672980546; cv=none; d=google.com; s=arc-20160816; b=P0Wjt9rxmcKwC13IlaMRTg61Km0thXbRYLc6TvcC2F6sz60jT32AMArKjrKqzeqOYJ g9gS/udvQ/MfnaiwXy1hMfS6AuVt9lghtU3GqcDBy/kgqsPilf/kc43N9JcIQyRo3NQk xqsNQJ9H0DQID3K/OmWA2+HqVuIODk5sEbkNtsZHMdCa0xIHVMyEIkY+FV/3uyPh4Ndk SM+W3Pdxdx6w2yYwPP7ry9OScqEmbL79UYhLv7zl1ltuWyRyisENIrWMvt3KlBttzp59 2UUMFmXWrxlng/O9CwxVefAQcEdtEmNtkUwA8VVYLPaSqZo88yOn8mA078jCHAwDZtys UF5Q== 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=6MtouSE/c/6IpUkzqBwoQWV9c2KUTTgxJg5BS9SVs/s=; b=asRCHaseJML4fs8bpY6pt/kWcy7gfVyxCsIXUV1BqDPi++3oXPPunJiGn0Y2x2FLd0 VBqrAhyGk2/3mxGrGQe1idwQvTzsOeR8ZtKVpeTF4pMLc5ScJkD+3+WiVeYcoxyreC2I qFlT/N5LE+pbjWI5F8ryXRgvgph2Fwm4y9y5cwNfom+sdPfVDj5/lXc+TM4VUIirROy1 ABA8luGQWPJ9CPaHDLa65ORn0ULQocBtEFdEy1JTy2iqeHz1ATLWsFCuKgyvj2dHujIc MSrFS7t/GWvZiPI8YR21Jv3kkeRWlFciVigNFM8gHcD+GPHlf5ZeGaF5L5H9yJ6j8GGm behQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="l/Ap6Nw8"; 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 e17-20020a656891000000b0049cd14d3a7esi322614pgt.75.2023.01.05.20.48.53; Thu, 05 Jan 2023 20:49:06 -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="l/Ap6Nw8"; 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 S231361AbjAFE2y (ORCPT + 99 others); Thu, 5 Jan 2023 23:28:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230164AbjAFE2w (ORCPT ); Thu, 5 Jan 2023 23:28:52 -0500 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12BCB551C6 for ; Thu, 5 Jan 2023 20:28:51 -0800 (PST) Received: by mail-pj1-x102d.google.com with SMTP id ge16so397477pjb.5 for ; Thu, 05 Jan 2023 20:28:51 -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=6MtouSE/c/6IpUkzqBwoQWV9c2KUTTgxJg5BS9SVs/s=; b=l/Ap6Nw8wI7NGfkXN/3WQkm0HipP4d8IpiwQ8tbFwy/1MyZlpCxJmVSTHr5Z7CrVyC 6Q84LVsMaaEY0zSlrdKyPYz1zxeU46YvTNbDmyUgyd2Ik8PVgJ63sq/6mBYkfr2vUtz6 HrDNREcM9613KaaDMFTY+467qiJC/fxw1Aego= 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=6MtouSE/c/6IpUkzqBwoQWV9c2KUTTgxJg5BS9SVs/s=; b=ocXadK/9qjg6e4M938/14Ho0TcslR6VMkFVPaVIJpH4xjFMLgMsrL2jREMhx95lo8w 6lDFTVZV8tNHB3oUI1UQj5spPaCF8Q0g5yf7lhgm3daDXSF4cyQkLOqYU2ZIw/TMS1g+ YhjBPwQOValJUFUEvwx2BYTqas/q9OQeD6JdaaUVtsLjxZv3AqClr9TwkXDPEDS7BvUr SVQBQj+QPphTiQqOtAbDnAF1pqHAg4bb5VVa0Cekf8MkecqJRnZMoWmTisiLFu8nrqSK io8uyf0DEYaYgfowFD85Qz/5NaPbEm5LCbcnmAovEDBeffOmPHEkd4cVXj2HkClKlhyl 7vEg== X-Gm-Message-State: AFqh2koerxVj2xZCgJZPNT8NAvsD1kOzRUmoeyBmet9wxNMqSjr/TgV1 KDt6B5NvjOrXcC8TllJ3co0Q2Q== X-Received: by 2002:a17:902:b414:b0:186:748e:9383 with SMTP id x20-20020a170902b41400b00186748e9383mr50928233plr.46.1672979330555; Thu, 05 Jan 2023 20:28:50 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id n15-20020a170902d2cf00b00192902287d1sm18749402plc.288.2023.01.05.20.28.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 20:28:49 -0800 (PST) From: Kees Cook To: "David S. Miller" Cc: Kees Cook , Jakub Kicinski , Andrew Lunn , kernel test robot , Oleksij Rempel , Sean Anderson , Alexandru Tachici , Amit Cohen , "Gustavo A. R. Silva" , Vincent Mailhol , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH v3] ethtool: Replace 0-length array with flexible array Date: Thu, 5 Jan 2023 20:28:48 -0800 Message-Id: <20230106042844.give.885-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2121; h=from:subject:message-id; bh=DKp2Eu0HGyg7pTlg/vHwD58jjHq4zOalTg6VuLkK1Ds=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBjt6OAkODbjy1W2ZpLP5aLSnBaokwWRxffKKlCCKzH RHrHiN2JAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCY7ejgAAKCRCJcvTf3G3AJr/wEA CjCp54OIIN2hDjgjrgLc704V/PLrFQSVrJOFBtEnITgTrIx/F9Z4fveot6egvNwYQaeSRQOXiXX6Eb UJHDIwUEuJIn7uhw2o038rVPEF0VtiSchIEOKwyco97aqwmJcqIVlnPzMdUHv5Qptc7G1Pt62Vbmya LFmtlSv/xPCNCaTj+Pp+YTwcj+ijyHZ6Ei9tDce3t71RYp0GUeV/Fgq3FQ94iirCk3ikGqi9huXNti niTraWIXywXJfMr0a8KBOhHnbB48a2o7u1VXC1gE6pHKBqk2NbtyiBu4XgJmJXSckR18FXSNc0II+e xMaQxAghjlxv3DtSrN/H30pqrqAbo/TXEGfoar67rK252904iDkGtPns4MBiVplVIpvyuOKttjwvJN PYkE9pTq6jz/zMeD/LxRaTvwgs8CxGIeqeA3ooEmXkyxuKIncVG+SNk3tEOPoBLjbwx20ALn+n0yDf VfqQJV+nrVunJrFiMW483YCw5E4wgY4Ln3zQSqncqgiitjaP2Jbyn/ZXTvQBFjp85GyMsT/mchyoog 2VKLajUDA+rRpYMW/YYZ3GPlOdwNss3i/eSg1+moD3+9vJwU3KiSBgBADWyz1M/0SkKE3Ftfi9OyVd 8uToWUkUeBWWXgyQx7wNYzuvjahqktiYzj3dWDrljeDT4cZDFRtQdtYwZ1Iw== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754220979245460804?= X-GMAIL-MSGID: =?utf-8?q?1754247249205667383?= 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 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 Reviewed-by: Gustavo A. R. Silva --- v3: don't use helper (vincent) 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[]; };