Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2270991rdb; Tue, 3 Oct 2023 16:17:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFtoOR5pR4EAn4PwOmGuqJH+46RRY4FGv0UJhW/xpiVV/99e/3snj0fhoTL4rK63QYOo9TS X-Received: by 2002:a05:6a20:8e25:b0:163:11b2:1068 with SMTP id y37-20020a056a208e2500b0016311b21068mr961664pzj.42.1696375077187; Tue, 03 Oct 2023 16:17:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696375077; cv=none; d=google.com; s=arc-20160816; b=NR2yJNx3KGRXBuB2+WJFODDvYno2DCa6DhT8EYfT5mTEFX8z6FrR1J+T9U49QJpUwG k3l45+adcXlY00z32frhVznVs0aTzb2NegVCFCeoj9ewB+sBU0LsrvlL/t0UdeR5FmNq 2VxcCOUcaI6/KOuI9HIVcizqJADtPF86ihB+ewVv07Z5ALQiQ1lkbPpoWiAf/fVerftk zZ3ozF5gMpMV6hrPfBe3zQIm8m1PSWHS7iHQWoLMR07CfC2z63KzogUoh3rR9EbpYQX5 2LvjvWic4HNtnjKvkfqynkCFDAC66Ofs/1XsHSpMuYp0oNVpyDhUtufLuPG90MvYOzQR yw1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=68h/m2Pi2zxdSKkFh1D4c3jbV9GqO3rEkPm7rE0iF3o=; fh=Oky2e2xWfEzOsGtouKk/n07hRhp9/cEeH42Wn81MMI4=; b=vegxx0E1ZD5kIna7iPMY6z10k810R0FbimGEyBuys9uM4zeiYL9V9psUrDqrFGG9X2 m0otqhGh1NheBSP8e4rCuGZSfk/jDen+QrbNxgk46GGi5Txel8DbC6I9ptdhnyJDxTMj xbHK5W6vu5DtE3lid/HV1wV/WQhp+uT7BEw5qvS/4i1X3zJFeavGGJD2eNh5jKY0RaYl EOkmhVFM49VQSZOWmZt5S7jSn6bVPg5LllGivsjVZVm+xaWNd+Gj3wJ06zO5WlM73caP Dda+xe5Z3WuDGzsi9P0Kse8IgO43QLmq1H+Jg0NZvel0R6Pc4rcZIRym2cTclkJ5h1Iz bJpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=3bx9w1Pz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id t21-20020a170902d15500b001bbc80a2a3asi2292660plt.299.2023.10.03.16.17.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:17:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=3bx9w1Pz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id BF90E812670B; Tue, 3 Oct 2023 16:17:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232616AbjJCXRj (ORCPT + 99 others); Tue, 3 Oct 2023 19:17:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232593AbjJCXRi (ORCPT ); Tue, 3 Oct 2023 19:17:38 -0400 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D9BDA6 for ; Tue, 3 Oct 2023 16:17:34 -0700 (PDT) Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-99c1c66876aso272269566b.2 for ; Tue, 03 Oct 2023 16:17:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696375053; x=1696979853; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=68h/m2Pi2zxdSKkFh1D4c3jbV9GqO3rEkPm7rE0iF3o=; b=3bx9w1Pz2fu4rHJIoaU2RQXY2OPpb+0QIgCA1wpj+ohooUs8fvoJw4TMIF3YSjXA0K wLrN+7eTDMpYM9SKzp99wz3Ybdu0bQvfdiZAG2DKYM7s4O1aBzDxTqi1cFxELcjAFfmT Ij9uLz731uineHBSJWBi/9M02Gth8hMAp+7lMdj0Sr9u09BCtldWxoVzuGTDTFL1gMdk u2onH0YPtCtr8WTdnFPw91+KR8w0RVz/ghbA9p3mjeG4l6RqDxSDSBu4dAr1REklne/F sPF6D3PKVeB05/eoaL5LmImX8c/oYVx9iynnQHex+jJ7/ID9kPbVax8UlaxL7dMx3apP oMMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696375053; x=1696979853; h=content-transfer-encoding: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=68h/m2Pi2zxdSKkFh1D4c3jbV9GqO3rEkPm7rE0iF3o=; b=CdnruacOzB2A66qT8m9OgUaDSdNx7akjzbN7l1kZEkv0JLyrlW7lQdh5SBhobdqLUs fS4YfUgYblEf4zjWGECjdDcB1dJISEJMiYf847g1F8i/N59/ShzJ0+G2ADAoFc1ZRZqD L2wI/CUxOd20I6i1SOK+JYZzUtlAHW2+mg2Mg/kuBAeDq7Fvxye7/B8HQ7GuH0CoVJRF AakW+PMnN7DPSsYGHazxP3N4ClOPrcDCUjemh+pFzFRTUrejFA0VSaWpnSe9xnx/CwSs jbkoPJUC5d3jCQ3KYihoCeHG/TEykwAvqKDtspMLLGRxAiQ9o9N6ddfEEz9HyU1ItAP6 mq7g== X-Gm-Message-State: AOJu0YxeLGOJXYCLTJQZcDxagcaYFNCeYYWm013w/rFtAu0kLg1JVFiu 8jQJIA4IT3YaTD+Grrf1EA+URVjuuQyvi2mOeo8wsA== X-Received: by 2002:a17:906:7697:b0:9b2:b119:4918 with SMTP id o23-20020a170906769700b009b2b1194918mr588755ejm.13.1696375052745; Tue, 03 Oct 2023 16:17:32 -0700 (PDT) MIME-Version: 1.0 References: <20230929180611.work.870-kees@kernel.org> <20230929180746.3005922-3-keescook@chromium.org> In-Reply-To: <20230929180746.3005922-3-keescook@chromium.org> From: Justin Stitt Date: Tue, 3 Oct 2023 16:17:20 -0700 Message-ID: Subject: Re: [PATCH 3/5] mlxsw: spectrum: Annotate struct mlxsw_sp_counter_pool with __counted_by To: Kees Cook Cc: Ido Schimmel , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Tue, 03 Oct 2023 16:17:53 -0700 (PDT) On Fri, Sep 29, 2023 at 11:08=E2=80=AFAM Kees Cook = wrote: > > Prepare for the coming implementation by GCC and Clang of the __counted_b= y > attribute. Flexible array members annotated with __counted_by can have > their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUND= S > (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family > functions). > > As found with Coccinelle[1], add __counted_by for struct mlxsw_sp_counter= _pool. > > [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/c= ounted_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 Reviewed-by: Justin Stitt > --- > drivers/net/ethernet/mellanox/mlxsw/spectrum_cnt.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_cnt.c b/drivers= /net/ethernet/mellanox/mlxsw/spectrum_cnt.c > index ee59c79156e4..50e591420bd9 100644 > --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_cnt.c > +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_cnt.c > @@ -24,7 +24,7 @@ struct mlxsw_sp_counter_pool { > spinlock_t counter_pool_lock; /* Protects counter pool allocation= s */ > atomic_t active_entries_count; > unsigned int sub_pools_count; > - struct mlxsw_sp_counter_sub_pool sub_pools[]; > + struct mlxsw_sp_counter_sub_pool sub_pools[] __counted_by(sub_poo= ls_count); > }; > > static const struct mlxsw_sp_counter_sub_pool mlxsw_sp_counter_sub_pools= [] =3D { > -- > 2.34.1 > > Thanks Justin