Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2271391rdb; Tue, 3 Oct 2023 16:19:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFVHvD2g/qKZmzUwlr+Wikof6AXN8pqgBNZ6iRKc0qFUMMg3dIPm/7wDX1NQVuN/pcO8wqV X-Received: by 2002:a05:6a21:33a9:b0:15d:8366:65b8 with SMTP id yy41-20020a056a2133a900b0015d836665b8mr5096564pzb.13.1696375149631; Tue, 03 Oct 2023 16:19:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696375149; cv=none; d=google.com; s=arc-20160816; b=njWnT2NzmV92EzzK9kfNig9HBA0xhDD6ylW1hep+ST2gyWFeqLnoHgxh/4b7jyNwhW i/OSacQNvPs55apF3umKeg4qejfkX3ACNSff2vmmdBUHa69t3wObLR+OaKH/NXy89e5B qmFrQfl27NL0hBMsi1lNDeJxEhcfodOel93w8Zrc2JPVIu3YUch+SDWbA1rT+kMIb+bw dzlXU0PTCS90atEW58Pr5ldgWZYobNT5t+p/k/P2xjIwuFpYeD4YTXqtIUZ393gym0ne kBwO6qX4IaZfXt6r5re2PJ5sw83CZSRYjC0D/WrI0JXjDsigZTP6A0kASwMD900ry6hT fRhQ== 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=BfDQBScYxSUnSyfi4Uo6dvpGeAqp/VpjWLErGf4V/4Y=; fh=qRwfykGjbrvRMA2zI5rm5Z1CvY2JAodsJsqT/y8L8Ik=; b=yeG5jVWZitZ+V1r9Cuehj84xQNoIGqm74xtcobXSCoq0wFYJ4jxmwMvfCpvqH0aB8h GQD1qRfeliu5fmbDT8XEk8PqiqVe9WTXNcejHdTu2Dr5S5NMklffTbysS54yH9GJsJbe JoYiTZvTK0BsSd/ESJjs6WcyCUw2e9kG7otA4nxF6Mm8vEOD6mZAs1v1VkdT6dcHowwE Uh9VVV5+F4QX0n5gC6jdz6xH5UaRuJXVujkD0rPFbJL7LMTg7hjps1GmFL0bVY/9+OXO qdwKgSjDFxpMG515JvoZGd3iSMBd3cqWim7DbJEmA2QriUmD542zJ1fnZ0oZvzNzKlNR qSjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=c39GCY13; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id z18-20020a63e112000000b0057e0c5a34f2si2441636pgh.631.2023.10.03.16.19.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:19:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=c39GCY13; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 68E5B8310D01; Tue, 3 Oct 2023 16:19:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235144AbjJCXTC (ORCPT + 99 others); Tue, 3 Oct 2023 19:19:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234673AbjJCXS7 (ORCPT ); Tue, 3 Oct 2023 19:18:59 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3D44102 for ; Tue, 3 Oct 2023 16:18:47 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1c5db4925f9so2776065ad.1 for ; Tue, 03 Oct 2023 16:18:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696375127; x=1696979927; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=BfDQBScYxSUnSyfi4Uo6dvpGeAqp/VpjWLErGf4V/4Y=; b=c39GCY13A683WQCyXS91Ah+kckgiae7d4dciHzklFjcoQIB+TDGXGlWWf4PLFilZX8 +1E8A99I6S3jAWXv5wkfYCAKs/b1ukQNYCj43Q+2nO2oLcLFnrZYft0BjxUWbj6kvu/u ulzUIJCN3AfQrOHaGQePEgSjrvC5/4Jp2U6aA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696375127; x=1696979927; 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=BfDQBScYxSUnSyfi4Uo6dvpGeAqp/VpjWLErGf4V/4Y=; b=o3PzSfLlcFC7JYbYZguqnGWgCxesZTBt0O53Qeu4YdmGjRyxae9mHINSWypqMb1XVR /FwLoi3YjZNcqkMNB5iJkT6wbWtRStUiUYm+jFX2N35W8/zwoeoVs/vCs4b+jzkiN6Wc 1HEpwpyh1FDz+UCYE0YhHteyxCi8Kwib8KTDCqkcLazr/5VAywXvFAJbtAvEvu3OiEwZ yqXkxOYDO9oX7i1u+gPAAGzVttb9b7lJZb2JO8GVRprwQSmjiK8RIucmSZJnzNzaNPPp HycsvRrAXPTUifCLwMSYtwzzbkZ7Sppy+A4ts8qxmuEwPU53cMRGpjA3SzwnmtTRUnnh foeA== X-Gm-Message-State: AOJu0YxZBqNv0QmVFW+XWC9ZJFlx9vhARNbjxsDLmx8sejDjtz9PplXi 8PiMPgrEtaY+K5GJTN4YZm6kbA== X-Received: by 2002:a17:902:d4cb:b0:1c5:d8a3:8783 with SMTP id o11-20020a170902d4cb00b001c5d8a38783mr1089962plg.11.1696375126989; Tue, 03 Oct 2023 16:18:46 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id g2-20020a170902868200b001bde65894c8sm2155966plo.268.2023.10.03.16.18.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:18:46 -0700 (PDT) From: Kees Cook To: Simon Horman Cc: Kees Cook , Simon Horman , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , oss-drivers@corigine.com, netdev@vger.kernel.org, Louis Peens , "Gustavo A. R. Silva" , Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH] nfp: Annotate struct nfp_reprs with __counted_by Date: Tue, 3 Oct 2023 16:18:43 -0700 Message-Id: <20231003231843.work.811-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1385; i=keescook@chromium.org; h=from:subject:message-id; bh=GBdZ/bN+5XfvUCtrP1SCYpOVG1FCyQF4BGZ+0KiNObU=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlHKFT3XcaVjq8M5JxizadLIhdl5wOFCRk4jHmt IqwNVjEepmJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZRyhUwAKCRCJcvTf3G3A JjtdD/9D9R+8v9dgd3XY2WHug3rJjyK4+8aPw1mMYmILmQAYJrviLmccxjiM3F8I8PdZetcj6SX RbH4C+nQWdw5ItnpPFkHGDihNWS9JWqOKv+oGkwUa3Whsf7iRHBvZf7uB/OgbdEO293mVpH28xd KbDCTzrjImpUo55jjiQpypeXtqmMx9ETglaTTFwQcsy0AFJijWbvSS8agYnozYrZRQ/PImZqVtX SFpz7g3JLBAoGdtYE9fQ7jjJ03qrd+ZQrvXLw9SIaO9HFyflrYGihTFC1VCzd7kPAwollvn4m97 HH7yUiaKoVQDlXMiCxjF1SJJJ5QIFF+rmU+yQNBLg/yzGofvOSNIHLJHsBoI1WCt1cuuf0mnJaC +99noNzwMdxYbz2ty0nd3nkKAgq9GWcgxUmxwAnh6DyTzhCdCyXTQFbQdFIwQPWMkk3XZzW/MBM oi4Nl8a1A7APm4f2ShQWBNUF+X5+K4WiwWDDm02GDNhGbhd8g4SqOBl0/u8VfysAI6ItMlF6Bmr hypptMkfiJr5Kgaw9lCUFKeoF4buVYEhf6KaQp/5D+vPYIEYbR/LYJZQC4OIlgi8AOgnMELTjFx ToEkiMcod9orNCiC8N2Sp0fIEREqeIVvOYH/MV1ScmN7S/nb6gSwPSSvo5KhnEOicTn5xHj2QxY Xabvqd3 WXqLy3lg== 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_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 16:19:08 -0700 (PDT) Prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family functions). As found with Coccinelle[1], add __counted_by for struct nfp_reprs. Cc: Simon Horman Cc: Jakub Kicinski Cc: "David S. Miller" Cc: Eric Dumazet Cc: Paolo Abeni Cc: oss-drivers@corigine.com Cc: netdev@vger.kernel.org Link: https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci [1] Signed-off-by: Kees Cook --- drivers/net/ethernet/netronome/nfp/nfp_net_repr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.h b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.h index 48a74accbbd3..77bf4198dbde 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_repr.h +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_repr.h @@ -18,7 +18,7 @@ struct nfp_port; */ struct nfp_reprs { unsigned int num_reprs; - struct net_device __rcu *reprs[]; + struct net_device __rcu *reprs[] __counted_by(num_reprs); }; /** -- 2.34.1