Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2271435rdb; Tue, 3 Oct 2023 16:19:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHSp5BC/qgg6TlcGFWdI+FgekRVYehkIoCWWhkSF59dTYcfUEN9Ui1QzvGh6Vz1u5JSzKvC X-Received: by 2002:a05:6870:c085:b0:1dc:10c4:cc07 with SMTP id c5-20020a056870c08500b001dc10c4cc07mr1019240oad.28.1696375156913; Tue, 03 Oct 2023 16:19:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696375156; cv=none; d=google.com; s=arc-20160816; b=dxRMGov/vggGegSWoe2xAuTnlh2hQ5O71LdaQDV9uE3S+0i3A9NrJ3VLYr0EL3p81L A8ONkJgoF7yexE1O6QhIvfjdBEkYlGfOnAakLyA6ppMkllW22wsrBpkLs/YGZ/iAJoD+ wzhjQTk1jO/70XLXSsBv4DqUg0XKN+0Q875IDR1yXWPVkJKqLyMLy2Wm7ILWBxO+pjTl o1R9xWQoCxLqbI0mEVXduuTl0Wr+OE/q+YPGoI/DH+TZgE2tsOw6iHSnpTkEpTR/s6Bo ldClrL61mXcVgJ5y8UUBD+e2u9GC731XujBMmtJCW5OTKbncIlYZnwZ5JnOsCg+H9vKH mahg== 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=mWNIdeN2XwgWHo5X2YYBIvg85yUsaTggFd2yH1rpeNo=; fh=ponEMxNzELYktnz4OSZlReNXqUw9QjU02Oavw3PcfWM=; b=IFrV3LjZ6K5sa0os/wz9EXiixDn4UY/FXFV1p/ke1gM0mmuXmHi+wJLqZ5vUUgJdBy iubzY1ylT5CWjraQbb89Eic6goOGQ3qN0aY0IeHp4N/gjVnz4KpzmQCs5QdUn12xZ2NN rSOOm0/9FNEKkiai426b/juaoS7pedvSayNXkJzTXGr3S6DvqrOtj6HQ4HfLSBUc66g8 kbRHXPJZLjfs5Au0kBVcMEUZDTUI1m13leIeANKQ0pkGUOm4DVofpz50Slj4BdRaCHlv 89Ja+W0zb6NsLT0wd1UgrTPp9KDmaQSzFJssG02YSSb4izWsqPNeafrTQUPfbaUydUCw Es8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=FUNXClyp; 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 x9-20020a17090abc8900b002790c6760dbsi265258pjr.70.2023.10.03.16.19.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:19:16 -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=FUNXClyp; 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 8849B8310D11; Tue, 3 Oct 2023 16:19:15 -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 S234830AbjJCXTI (ORCPT + 99 others); Tue, 3 Oct 2023 19:19:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234997AbjJCXTE (ORCPT ); Tue, 3 Oct 2023 19:19:04 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECBB811F for ; Tue, 3 Oct 2023 16:18:54 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-690f7d73a3aso1179636b3a.0 for ; Tue, 03 Oct 2023 16:18:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696375133; x=1696979933; 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=mWNIdeN2XwgWHo5X2YYBIvg85yUsaTggFd2yH1rpeNo=; b=FUNXClypEDIPztwRcBTngVP9vRWTx93FHRHaondl5dE8i10zMxU7OUsF1NznK1ZMZD mWVFInGRdpMUqq49AJjcmIRsziaNWsjioN44l5SSk2JHOBtC+0+3M8/aAwpJNF8kPtqk fmC9Nm/jMRK8ylLmVzTiWfN/4aU3qld/roQGc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696375133; x=1696979933; 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=mWNIdeN2XwgWHo5X2YYBIvg85yUsaTggFd2yH1rpeNo=; b=h3IAVpCxV7fBXwjvotCJYCPyvfUbbSX8AI8SszAickm8nYBxiQbpjz4XusJyb1JczQ 1YqXxWEox5lMTNCsgeGCG7SVhsBLyl5RLfVVXJPmGF1NzsnZv5d+JaseB5S+Q97tMRsF LBeqTrZJ81deoIBlq5hLEPbd7PzarxYrP9SKH0qe0vhpniMFdxNRX+Ya/SD1adArD9jm BiJBeepXeQBLlCmwEsxXZU4/bRcL5wD97CxCm9ZLAL+HZkyjMvUxg4vdaUphFDufcTae U3ZQLlFY5kJ7qONh6bYtmswGEc6xUQGHGkGeHBy5qFaPy6Dpg6f/Kjl5Y51qeqPkt7y7 nNSQ== X-Gm-Message-State: AOJu0YzCLMUJ2rhEWn22asAJfoB7oDqCtCxZ279Am2vMyfEqW9CRLJjn jsmYqR6lf7YDhbqe2EILoOLgmg== X-Received: by 2002:a05:6a00:1511:b0:690:cb8f:3320 with SMTP id q17-20020a056a00151100b00690cb8f3320mr1061401pfu.24.1696375133553; Tue, 03 Oct 2023 16:18:53 -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 f30-20020a63755e000000b005777a50c14csm1948843pgn.0.2023.10.03.16.18.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:18:53 -0700 (PDT) From: Kees Cook To: Simon Horman Cc: Kees Cook , Simon Horman , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Yinjun Zhang , Leon Romanovsky , Yu Xiao , Sixiang Chen , 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: nsp: Annotate struct nfp_eth_table with __counted_by Date: Tue, 3 Oct 2023 16:18:51 -0700 Message-Id: <20231003231850.work.335-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1591; i=keescook@chromium.org; h=from:subject:message-id; bh=kyIpUckdxhoPI7wg/1i7aDtbMCbDJmvf94yOHZ/LMos=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlHKFaqeDk2zRE3th7z8cYZ1dn2zrPeWsHfJfCM Cuy93rmm6WJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZRyhWgAKCRCJcvTf3G3A JtivD/921uPevWfkg8Iip9YGwRkTHQCT/UJ598wTfO+mlFZfgD8SEx3AvBWVtFAqDbrflleiDp7 R58oBrQcmRqVIpJKsm718xxHUhMOtY3JGgUQYiv6bAN4lISc2z5Ju2QzD1IrXquWHev+ayiwS7n 7KZVM+Gd+Sr/EQvetaHmNqzDWdIBpT5mdQLxQmX4+hCsrGzMAXlei3f84qoOw9V2e9u+n43W93H Z7rbuFzJIXu4IKLlngEXXY/RFZVr88AIIkpwz8/OLLEnYTJ7SkChFnM3/yMejx9Xsp9zCyfF/5w b+riLsgZTZzyAUN4l7+Pgl9Kqq1+xXc6+mV5O0MJ8pdzoA3aiUcTiMZqhJds8Ti0POEk+7pauBr d/n6Dnx+fZtx58xQUgpRvrVLtZkQ8pFgcNr3b3KNXXy3c2zxAv15kOKKK5jHD4/FpOINsE3FVfx SUZS2QHF0QVAWCxGH9+5QJn5SOVWKlzi0AFHyV6bRb0yyRkkp8+8Gj9xDDJMarG0yDVlaW6lPTT oYsKlppQ44FxNQ9UEDX3nZpTULabRuehfovG2KPpb4amory077swEoE6JUbBUf8rm9K09YA8FDk wyXGduO9eqahqe3FfT3xbGGSFV+k4JvfrMZrTP0+Eu5N659fq3paOBy8VsG3ts4pnnXNddDgEGP okULyFU CI3chMuA== 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:15 -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_eth_table. Cc: Simon Horman Cc: Jakub Kicinski Cc: "David S. Miller" Cc: Eric Dumazet Cc: Paolo Abeni Cc: Yinjun Zhang Cc: Leon Romanovsky Cc: Yu Xiao Cc: Sixiang Chen 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/nfpcore/nfp_nsp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.h b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.h index 6e044ac04917..00264af13b49 100644 --- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.h +++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.h @@ -241,7 +241,7 @@ struct nfp_eth_table { u64 link_modes_supp[2]; u64 link_modes_ad[2]; - } ports[]; + } ports[] __counted_by(count); }; struct nfp_eth_table *nfp_eth_read_ports(struct nfp_cpp *cpp); -- 2.34.1