Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp431851rdb; Thu, 5 Oct 2023 09:57:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF/MHr1TxA40GdsTD6nn2Nncz/7OpmlzVdhC++R/VDl4ab/bZh3w3KAVqWXTjAgCwB/5QTC X-Received: by 2002:a05:6358:7245:b0:14f:6a41:5d19 with SMTP id i5-20020a056358724500b0014f6a415d19mr6640667rwa.21.1696525023460; Thu, 05 Oct 2023 09:57:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696525023; cv=none; d=google.com; s=arc-20160816; b=0ZoLyMdCN1VUgfUqUcbwR0ONNw41daSZfXePwQ2MuRbL+Wu0u2L3OAgjKyorTFsXGD jotErvBxsJHHsN4eucgfNSq/2qkqifPmPEP6FCSU9MO2TrSJJHnqeNLMI22PTLqnC9wL iGaU97N2x2X8LvLqmFhLODOyvx6ZjVfg+LfSI0vgTZFidpmSPyBZNOfta9Emj7rvkwHI wFdV13jAZN92stTheoXxME4ECvnO+8CVe/2nmumc6x1fTaiRR6ZOnTEY++GcG5y1U/fP +NqYztiBX1pBfatnviXfTbvgWqwNdfafIagSdI6uNa5VmIURO9mfsUu/65K2kyciUaxK JJ/Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3cXa0cO8yt2b6e+VGi8zgr6GOxIgX0GS3Nbuo7CXwec=; fh=NdFsn03G0BQ0yIy7PVh6T+GPRerauJ+2EiKxLNReKMQ=; b=A7BfM9Bfv1i5HKd6j9WMZYsiaKptrKorqHub6ZWnylqn4nSfWHJSUsHkxV9/GWXnDc 6vBW7j1X4sKoj4H3a7kn9tlZyq/Lj7PP76RYdIIQmPfFNH2JwqUDvtO7E718Q9zLrdg2 S5x8plAaEcbJY2haXBdeKkavpnipswI94UbRBudtP7hMAbRG15vSS3ABxlX/NengU/PU j1XvHLF3oulkUxaErW2d3+NiWEocFPnjxCMoXZx88AJlAu1KRwUNWBV7yMba/iDMf8+b ICWf0ycZlFnnbgVejWnA53Pvq/5OcB1WhOAk7JsHcuDrqGc+HnZCzWnwbZ4TFlwhPAPU d71w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=C7zQjsY0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id s17-20020a632c11000000b005895c80c902si6919pgs.438.2023.10.05.09.57.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 09:57:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=C7zQjsY0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id CFDCB833D56A; Fri, 29 Sep 2023 11:08:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233702AbjI2SHv (ORCPT + 99 others); Fri, 29 Sep 2023 14:07:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232923AbjI2SHu (ORCPT ); Fri, 29 Sep 2023 14:07:50 -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 08D0F1B0 for ; Fri, 29 Sep 2023 11:07:48 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1c5c91bec75so110129255ad.3 for ; Fri, 29 Sep 2023 11:07:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696010867; x=1696615667; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3cXa0cO8yt2b6e+VGi8zgr6GOxIgX0GS3Nbuo7CXwec=; b=C7zQjsY0bLpXxORG1txjs2Kg3j+zIgfX8oP8/R1uZrA/0JjeDf1q8nsLaVcDxcfGWZ ONHsTIGhASybM9COXhKobV5iUzQ8bpjfI+N3/giEqq5Uo/TOzZUq/yM+IVsbxrB+z4IM JSUyqdYzTOjo27v1yAwaxTL6m5dwb75cvIFhg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696010867; x=1696615667; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3cXa0cO8yt2b6e+VGi8zgr6GOxIgX0GS3Nbuo7CXwec=; b=sdggvdeUkHsgyOSbEeIz7pM6A0a98Or2O8cgA/1HGRXequG06q8hMdE2BEXb/Q2Mpp T8wyhrCqHayDqIBDQQeQ3PkbljzaC+XpMCIhN3Ni9ZmIKxrGTMew5HEME1CbJMw8Fbnp rm745O2w1g/0K3ACYUX0UEMx8pWAoY832WFhr6z/P/ezECQfoOcjU12kpcb+kkk+3Bpp T+hI1R3o9LjpxKqShBHXwYcSh03+8NuB4WJdUMs4opgzZnOA7nHDzYlnTp59TE39oCxf gq6K6bQMpNv564My+iKSuMuSfCfFXd+9Bo4y2+94bGbC+w9K9sfKXA10aIz3enqCuiEA lsHQ== X-Gm-Message-State: AOJu0YxWpJLKTiNtCCYbW7Qn6VBW1mMin36iWaiq6WpDzNRX2Pu5t+68 oTTNhpJcL6aiQYdqnYQDVVp2Qg== X-Received: by 2002:a17:903:24f:b0:1bd:bba1:be78 with SMTP id j15-20020a170903024f00b001bdbba1be78mr5817296plh.23.1696010867484; Fri, 29 Sep 2023 11:07:47 -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 p16-20020a170902e75000b001c446dea2c5sm17144513plf.143.2023.09.29.11.07.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 11:07:46 -0700 (PDT) From: Kees Cook To: Ido Schimmel Cc: Kees Cook , Petr Machata , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, "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 1/5] mlxsw: Annotate struct mlxsw_linecards with __counted_by Date: Fri, 29 Sep 2023 11:07:40 -0700 Message-Id: <20230929180746.3005922-1-keescook@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230929180611.work.870-kees@kernel.org> References: <20230929180611.work.870-kees@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1509; i=keescook@chromium.org; h=from:subject; bh=Ww0CdLXqXc4lNTAvPkI5tpHASRFsk/+Dd/7elsfsEVo=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlFxJvZ0ctS3Apt7u/ZPa2oHBqvLK7sDWQzgvto ev8sStvUCOJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZRcSbwAKCRCJcvTf3G3A JtPID/9lzDk8uueD1NLYXfN5nJTT1N04aIYmTyDtXOx9Q2ze4G6KfG72FccvuQD7QCYudQIhMti UN9kFRwzHB7UjP9+D3r86ENK4dpKPvnIeIFJpd+Hvg4vvG+DHtLDZGJIeTi4dnyw4z2ayv/4Lgy OoSQKKswKBI5hkv1uMxbxIljvEhJDhbbWhEme2fxZvzV4c8mInhVzj90PhhsRET4a5lxGwe+Al3 JMx4CP859l1P2gwm9vaxIazkD1E3IKgESNenzlG9zjXyuFTkazOjQfdFDUBiEesU4WrkZCzJeKA UuQZW27ZR8vwOh9N2cu1ONtfxOC3XRQPmnu0IDt0yyM0Vp3fEVJkAQn8Ti5J58VNHTGj9/INkms 33nE+9B37Lpmr0v5oEhgLhVfUOzIeXEoOHjnvoed9Pmw0+QqjEMq636LMMuxTp/O45pqisaLrGM nQcAqGkoQiYUXpyAzmKfzC4AGHALfiI8/0EZGSqr+5hPIGdiDEWxQiL61EQ4kgUuubp16GUcRdQ MvmN1Nz1hHJzFP1lA9sBSTnAcyDLZDYUSFP555nDHRyjzoDPbiQtCWbMEaKn6rQYBA9t1LasSzS RMn1fKyLWauhfAYUUXnimfKBeQDtWvFwT4nVKcDVN9mtuu7N0+VNU0r8/O+oSgsdzzpFTbA2Kqz XW74PgNoDQaokuQ== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 morse.vger.email 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 (morse.vger.email [0.0.0.0]); Fri, 29 Sep 2023 11:08:11 -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 checking 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 mlxsw_linecards. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Ido Schimmel Cc: Petr Machata Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: netdev@vger.kernel.org Signed-off-by: Kees Cook --- drivers/net/ethernet/mellanox/mlxsw/core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h index e5474d3e34db..c6bc5819ce43 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core.h +++ b/drivers/net/ethernet/mellanox/mlxsw/core.h @@ -624,7 +624,7 @@ struct mlxsw_linecards { struct mlxsw_linecard_types_info *types_info; struct list_head event_ops_list; struct mutex event_ops_list_lock; /* Locks accesses to event ops list */ - struct mlxsw_linecard linecards[]; + struct mlxsw_linecard linecards[] __counted_by(count); }; static inline struct mlxsw_linecard * -- 2.34.1