Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2276523rdb; Tue, 3 Oct 2023 16:34:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE5CM3yBncS7kK1mX5JLj3Rfr6aWKj121QtbbIlclpxLVXofnNnNtxGZt2sow9CckQNM3e6 X-Received: by 2002:a05:6a21:61c:b0:15d:9ee7:1811 with SMTP id ll28-20020a056a21061c00b0015d9ee71811mr752579pzb.36.1696376054553; Tue, 03 Oct 2023 16:34:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696376054; cv=none; d=google.com; s=arc-20160816; b=R23r1kTFHqq9ZLirMtI03OJkl+8DUvC/8r+UbL4VVNT+Dk3adx7/UQD+ybC8QsbZ+C p8P8fw1aN/5oYX4K0QNmEwLZExm3yYD2dyxJj2uhgEyY2WU7NyaG4TUSAzRBKQtRBTxm gjskZqJsa39BGQZD1vQkoxXIVjw8D3zEg8eH9J5OD6fU0s6urKlfDn1MDDFKla8yOycM 8ZbITUFe9cNXuos8U3/Z+nMuPwNfXjipguS1YPIqL7q8HDDxc00j84PIbbPnJLi/bd4K BdHjaBomsvU85s2gCBxjs685OTosazsZveQ9ATdFnwdiSmLQHvR2SiYfHH+mNEubHZca yUkA== 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=YH/AzHDtLtkSEGt7f3Aw5RIuOoFUwUUQWzrJUM+SNVg=; fh=rHvJMUWLjlN5ApEs57787J0TQG1eeCXgdO2zpIBrCfA=; b=j0wa3JF1dCvWI/eU9b26Svk++BinQp6siGa3fqGCUDbi9qllN5Ae4+PYX/TfOSDigY SBMDCsamObb19efdzXk+W3bN5t6jprOWnhuTq1iOlFms1MBoxICbzIxghWsYZi65YS5l wBpiLuHT6ZeAvPDdNQFFJjUPK2KdVCK+DQKqumD87MWRsOJZP1QeP+jEm3DUTzdWVtkQ PEnG8xsQrpH5bhj/TaNhRZzGr0jEzjBCrOPpjJfQt2Btv2aGXtCuqAPvsV+Bh7/YzNEH R2y3/qicowMW7QrWHyDZkMmFFaD2VC65J5NJTBiwnaCbSzbvWO6Q4iq/QSPLR704TDZp 3Fvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b=FJwdy7+X; 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 Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id ij20-20020a170902ab5400b001c0ab540e62si2476476plb.277.2023.10.03.16.34.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:34:14 -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=fail header.i=@embeddedor.com header.s=default header.b=FJwdy7+X; 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 Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 5F1BE812A608; Tue, 3 Oct 2023 16:34:10 -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 S234028AbjJCXeA (ORCPT + 99 others); Tue, 3 Oct 2023 19:34:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232052AbjJCXd7 (ORCPT ); Tue, 3 Oct 2023 19:33:59 -0400 Received: from omta034.useast.a.cloudfilter.net (omta034.useast.a.cloudfilter.net [44.202.169.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9FBABD for ; Tue, 3 Oct 2023 16:33:55 -0700 (PDT) Received: from eig-obgw-5009a.ext.cloudfilter.net ([10.0.29.176]) by cmsmtp with ESMTP id nn1JqT43zIBlVnotMq6STq; Tue, 03 Oct 2023 23:33:28 +0000 Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with ESMTPS id notmqjrnqmWDSnotmq9X8d; Tue, 03 Oct 2023 23:33:54 +0000 X-Authority-Analysis: v=2.4 cv=HY0H8wI8 c=1 sm=1 tr=0 ts=651ca4e2 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 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: 19 X-Org: HG=hgshared;ORG=hostgator; X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfKJ0JBbjLLmPNsnClv6L9ByG3m7bIGZkOV5aOpiiMkv2TlFw3ES1sPgYwh1lKCAsGA6rr7BnIl1aRx5D7nOTB5TasSOrVJHUcmlLZVP2j2U1Xw7x9vLC QaTFAmM0wd21hBcphVbGehsQtQ3xixIEGGz5sf4oCMJA9x+Ni6zndAXvrGl0R/Y6Z0eaiWFDDrAga+T96IcuK9cioX1RbYSUd5CppyNsd00LvF5/lxHQl8eM X-Spam-Status: No, score=-1.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, 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 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:34:10 -0700 (PDT) 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 */