Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2322247rdb; Tue, 3 Oct 2023 18:46:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGGEUM/RDM9chfNlhMk6IWyW3RR+l5UngORBpAV3L7ka2wrbB/7DOtQmHWbx3MFqUi6PYOu X-Received: by 2002:a67:f9c4:0:b0:452:8ce2:5149 with SMTP id c4-20020a67f9c4000000b004528ce25149mr923004vsq.12.1696383979080; Tue, 03 Oct 2023 18:46:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696383979; cv=none; d=google.com; s=arc-20160816; b=v5/fSj4PpvXXhk1J+e58dRvs+fc9PbuCK9UVhW5+Fe8gczOV/7eLHu06mky8XO0BJi oZHa8apqKBsIjjJvqmjOD3j0JQ6hLiHb/PSIgdi+Q9QpOoUH27WwtoZIHDyjP9a9z2j5 1Np4x8ZMncahTFVvMiYZH4XUGQNAFIxggrTj7C/Q4hTM3iARXKfiOXuvEdMgtE8ioOJC uAR6Yg87o1dzZlXVS9uRHUYo491cNHsfU6d2mAuknpOBncz0V0SPbQCeBcss9AmAzKGQ 11P+LjF09vZ8BiX2ndPHh8GA/KgbnWC9jpdS+y33x1QXnXL/7ihUdhyIrIcFPqLyKLtk gbiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=Hln1ZH+P279DPfU6DvTo+WLQ5/zWlyvXgx6IBvAK7tc=; fh=S/ju+4Q1eXMZX6b+rBG9CQsK90vAJWLdkaCpCDK0p2k=; b=GaRz3U3nGXF7Qn5NZk5IwKku2WfD3U/heXLKzXOuqn0ID1anE+hrJ6OO3PLAb9VsN9 5vb0RzOjjS9AHZKFl0ESss1w16kL2wwCwqTrwDWBZwne3mjazoj4xq4wUjmdgYch17dn 3PicGtHdXXANK0Cs1nS8n5A502ygWMBAxZ5AjV5pd+ICn9fV5wWNTWEiQqZAvkG+uyrG WR/r+qr3e/BFF/pNMSFtcTU4v422NmuGTVEvk3sgoM/zMiRkOnjXlvI3tqjWH16FqNbg fXr/Laj//sJaQCuMhixokVdRPYC0sLMTaQbWx5WbNyX/SUre22/XZVnw2/mIpQN8HZ6t Z4AQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b=Rsqkmy20; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id d2-20020a633602000000b0055c77028579si2756317pga.747.2023.10.03.18.46.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 18:46:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b=Rsqkmy20; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id C3D468026B99; Tue, 3 Oct 2023 18:46:09 -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 S240058AbjJDBqF (ORCPT + 99 others); Tue, 3 Oct 2023 21:46:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230274AbjJDBqE (ORCPT ); Tue, 3 Oct 2023 21:46:04 -0400 Received: from omta036.useast.a.cloudfilter.net (omta036.useast.a.cloudfilter.net [44.202.169.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC33CAB; Tue, 3 Oct 2023 18:46:01 -0700 (PDT) Received: from eig-obgw-5010a.ext.cloudfilter.net ([10.0.29.199]) by cmsmtp with ESMTP id npJ5qY89aNWIenqxcqHTNl; Wed, 04 Oct 2023 01:46:00 +0000 Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with ESMTPS id nqxbqBPih3s6Tnqxbq6DO7; Wed, 04 Oct 2023 01:46:00 +0000 X-Authority-Analysis: v=2.4 cv=EoDBEAQA c=1 sm=1 tr=0 ts=651cc3d8 a=1YbLdUo/zbTtOZ3uB5T3HA==:117 a=Dx1Zrv+1i3YEdDUMOX3koA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=bhdUkHdE2iEA:10 a=wYkD_t78qR0A:10 a=sIshrF94AAAA:8 a=VwQbUJbxAAAA:8 a=J1Y8HTJGAAAA:8 a=1XWaLZrsAAAA:8 a=20KFwNOVAAAA:8 a=NEAV23lmAAAA:8 a=cm27Pg_UAAAA:8 a=9VsTxJehNoVBklTQRoEA:9 a=QEXdDO2ut3YA:10 a=39svzKx7NMVfYuMjZabV:22 a=AjGcO6oz07-iQ99wixmX:22 a=y1Q9-5lHfBjTkpIzbSAN:22 a=xmb-EsYY8bH0VWELuYED:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=embeddedor.com; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Hln1ZH+P279DPfU6DvTo+WLQ5/zWlyvXgx6IBvAK7tc=; b=Rsqkmy20Bd0Hj/aUt1kEFlt4wO UXDU5uqYJhoNjew4RY7i5/p1OozvdQTIODUjDGIUf+NYIxddQf27npT0RweBg/kaFaUJqUk5V0KMP SXBFV+r4v78oVnGYWOU3epg65ajaxHg2xJxvZus1pPla4w2wDPaJpznwQgjeFNgp3g8Gpy6PGNA21 gLo5CjeXLomoWXuImB4mK3kdzoAVL2SiEcWKpEu16LhtppUrsLLkgvF6NwNyS/2nHmsdBUlhW0zSJ lf/fyOB8+dZN0VWAwfSEaoNsjoJ70djDXM1gm6V2qh99oPNjwhP/f2fw4PAWs2iD10GzUutqXlfiG Zvccsa+g==; Received: from 94-238-9-39.abo.bbox.fr ([94.238.9.39]:41938 helo=[192.168.1.98]) by gator4166.hostgator.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1qnozK-001TqT-1b; Tue, 03 Oct 2023 18:39:38 -0500 Message-ID: <63f3d89e-41f3-65c7-0a29-fb667960243f@embeddedor.com> Date: Wed, 4 Oct 2023 01:39:32 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH] nfp: Annotate struct nfp_reprs with __counted_by Content-Language: en-US To: Kees Cook , Simon Horman Cc: 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 References: <20231003231843.work.811-kees@kernel.org> From: "Gustavo A. R. Silva" In-Reply-To: <20231003231843.work.811-kees@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 94.238.9.39 X-Source-L: No X-Exim-ID: 1qnozK-001TqT-1b X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 94-238-9-39.abo.bbox.fr ([192.168.1.98]) [94.238.9.39]:41938 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 0 X-Org: HG=hgshared;ORG=hostgator; X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfCSK8tNWkHs/VqYoum/MtjJrNiGBoQUuP+UzAzTCmnJV2g3FAYnnrJzKgfL7eZeh5dA1nt1wknGzmbnpPx+bvHQiK3fyaLZBbBz/t1nv9y12BpSSij02 uYSiRzTQpIwqYv4qBI09iD2B3ougGodJeFeMwyY71DJZOozUGowZfQF2A7n2pFrVntDgoF/M9wvhOkUsaCdMreM0VNPMRXpsJnNXBAt0lq3Gu83TwQiVsABS j7DhTqrHh4S6RCbQqjePj24XEPtHXcZcj7dzVRuRXVi2VwnTC0Rq2z/t5jn4jiMm X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Tue, 03 Oct 2023 18:46:10 -0700 (PDT) On 10/4/23 01:18, Kees Cook wrote: > 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 Reviewed-by: Gustavo A. R. Silva Thanks -- Gustavo > --- > 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); > }; > > /**