From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A9973FB3F for ; Tue, 3 Oct 2023 23:33:55 +0000 (UTC) Received: from omta034.useast.a.cloudfilter.net (omta034.useast.a.cloudfilter.net [44.202.169.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3911CB8 for ; Tue, 3 Oct 2023 16:33:54 -0700 (PDT) Received: from eig-obgw-5009a.ext.cloudfilter.net ([10.0.29.176]) by cmsmtp with ESMTP id nn1GqT437IBlVnotLq6STS; Tue, 03 Oct 2023 23:33:27 +0000 Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with ESMTPS id notlqjrmlmWDSnotlq9X7q; Tue, 03 Oct 2023 23:33:53 +0000 X-Authority-Analysis: v=2.4 cv=HY0H8wI8 c=1 sm=1 tr=0 ts=651ca4e1 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=Ikd4Dj_1AAAA:8 a=VwQbUJbxAAAA:8 a=J1Y8HTJGAAAA:8 a=1XWaLZrsAAAA:8 a=20KFwNOVAAAA:8 a=NEAV23lmAAAA:8 a=cm27Pg_UAAAA:8 a=YSKGN3ub9cUXa_79IdMA:9 a=QEXdDO2ut3YA:10 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=YH/AzHDtLtkSEGt7f3Aw5RIuOoFUwUUQWzrJUM+SNVg=; b=FJwdy7+XrdhVMaIBv+J5fhB78l V8yT1VCXDuhn0PacsFLb2Q91XIFt1AS6ShKoVNS7wn3fyMT8FBAkLDvnwjL1YcYcDaO+IX2pjhO5L h7ovVuHJ+m9KiWfooJbQr2PuzxqoFJvWzJxvPbk9d0q/rVzoZAuN0sfm2YBjrxl6HUXvUNZTmhBNY jBBwkuf2vEAWjhUoKjEe2Sr919q5kjzzH8snes0a/VBTfMpmI/VFaV0Q4oFlzJaQJB+S65CEZy14g jquaqYm6ddGHx2EZQ+iZD59gkYcvIUjt1yXeUTQiK8K6UP4Cp0udpddc98Yukv2jgB2wyyEtoI6NL NGu2VvaA==; Received: from 94-238-9-39.abo.bbox.fr ([94.238.9.39]:44052 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 1qnotk-001PAI-0m; Tue, 03 Oct 2023 18:33:52 -0500 Message-ID: Date: Wed, 4 Oct 2023 01:33:46 +0200 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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] net/mlx5: Annotate struct mlx5_flow_handle with __counted_by Content-Language: en-US To: Kees Cook , Saeed Mahameed Cc: Leon Romanovsky , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-rdma@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 References: <20231003231730.work.166-kees@kernel.org> From: "Gustavo A. R. Silva" In-Reply-To: <20231003231730.work.166-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: 1qnotk-001PAI-0m 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]:44052 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 25 X-Org: HG=hgshared;ORG=hostgator; X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfOmizrLj07n4Qk4zuq/UrQyyCa/MYPG/LBLQgBz9RR/6XF3YCFnUIL4nSiRJvojyQYviq8NvIeybHQyoRWAruTWDjxb62b4tNyK9yGXKiit/lyeI30QJ NZHCT5HBQVOxSVu/7VaXUx2DcC7LMxjV3gteS8Vo+lRYssOkBCWGBMrT4hnB70HwEAMPxsgjtle50IvsGB/AddE5Cpj49BXo37M= X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net On 10/4/23 01:17, 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 mlx5_flow_handle. > > Cc: Saeed Mahameed > Cc: Leon Romanovsky > Cc: "David S. Miller" > Cc: Eric Dumazet > Cc: Jakub Kicinski > Cc: Paolo Abeni > Cc: netdev@vger.kernel.org > Cc: linux-rdma@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/mellanox/mlx5/core/fs_core.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h > index 4aed1768b85f..78eb6b7097e1 100644 > --- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h > +++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h > @@ -181,7 +181,7 @@ struct mlx5_flow_rule { > > struct mlx5_flow_handle { > int num_rules; > - struct mlx5_flow_rule *rule[]; > + struct mlx5_flow_rule *rule[] __counted_by(num_rules); > }; > > /* Type of children is mlx5_flow_group */