Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2300907rdb; Mon, 9 Oct 2023 22:28:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHReWaQ1aRO9cFZMP0U0vsZ7AHAmgVKM2HaO7WfVKD1R4c5JuPEqMgTZLlpgm3C+iutn9TQ X-Received: by 2002:a81:5e0a:0:b0:59b:bed9:9a3a with SMTP id s10-20020a815e0a000000b0059bbed99a3amr19062339ywb.41.1696915704911; Mon, 09 Oct 2023 22:28:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696915704; cv=none; d=google.com; s=arc-20160816; b=sZS+T18KGKsfV3BqyJyKEnv5srLztpGgs5sFbsnMSQC/FQof0eX2/l09zt+Iz/Uoam bTOHbHTkzG7weE4EvFxsuxy5o8sAST7f4B3Ihv0syGiiLpYpIIQG3kKn49Kvuk31zOXk +bb1pgWPxzJlQR4k8V2WLfjBoRDokgBuBRXB16z4xYg69QlhpGv5TyTsFiICmbRZBvfF qZ4OIeE3CRA1Luj/eXRE0n1W8s9WEzwgbJyn8Tlg8XBiWZyQ/XI00K2prjrsB2h3L4h8 cxvKMYZfplW5RDM7KVICoSvSU+ULS6kqQDlxFcryYef2Km51Ane9DIEuSaFBt7OgFbUG ZCoA== 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 :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=UhBzoQl6b6SPgBCx3O6qpCX6Jh+GHE2nQg1Lh1Bbdvc=; fh=w2WOdUneWydyFutguGVgXuLZs4JamgZKH5bPTz82XbE=; b=YS+AG6F7gYcO/Rh3bvr/Db/12JXmc9nd7+pz19X5Igcju5/qM4fmQYfolAUZJpPLtP RrXoWzRoaB1xYWnGZrA5qvvUwVt48fozJRBEB+Auk50c7ZYvGRYb/EYAAvYDqOuVHkdB kiyfxo4c/AVQWy+iw6Tn7VFp2O4RkosqskiskwBjAoV8/f8JWBHUt+COMWUkBa+ngXDy L4gnHmLp5m0riUha432R86jOVbYCafXuS6aE+CqmH7xkbwk3ZnUHQxNygWaqCL3ohdss IBDxMRhBwB28+YNuBUIt0k+srCJvALhXnfnDsyQ1Aiiw3Cto4UVPAKBN6VQv09DjaI76 yZDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=sUJg8M77; 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=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id v3-20020a655683000000b00578889362a2si5044171pgs.663.2023.10.09.22.28.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 22:28:24 -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=@wanadoo.fr header.s=t20230301 header.b=sUJg8M77; 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=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id CA53780C2E06; Mon, 9 Oct 2023 22:28:21 -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 S1346584AbjJJF2F (ORCPT + 99 others); Tue, 10 Oct 2023 01:28:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346354AbjJJF2E (ORCPT ); Tue, 10 Oct 2023 01:28:04 -0400 Received: from smtp.smtpout.orange.fr (smtp-16.smtpout.orange.fr [80.12.242.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49678D3 for ; Mon, 9 Oct 2023 22:27:56 -0700 (PDT) Received: from [192.168.1.18] ([86.243.2.178]) by smtp.orange.fr with ESMTPA id q5HZqevR01Bgiq5HZqbsce; Tue, 10 Oct 2023 07:27:54 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1696915674; bh=UhBzoQl6b6SPgBCx3O6qpCX6Jh+GHE2nQg1Lh1Bbdvc=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=sUJg8M77dK2uUmiq5tDeHAGl5t8tBzowgZDea1fMdllYtFrUVU6nFeUaWAf9Wo06Z esfa5UPwLBbtN6f36c8onGpTL8vfUy1mRZ2gb+etSvA6Aftn1jYzJPSsKjBlkrveuS pFMS5/QPWTbDI+j7Rtv/9XZCxOU8Ga6T2Ii+aZZ3tPw2X8ER19weJsjCL0EfxghF2s MF/+yi2da4MgzK3RdkIq9ajWAPH8ZjCVv2MadKxaZ6PFiJCbzR35oNa3oZYrtOe57s qCVQFEYjLL+upHzUtCo4nxDeVuiPm1aX6UgFVci7cupr5gQZY0hjXjjnQ8sTSZc8/2 pTNufJQc3eNww== X-ME-Helo: [192.168.1.18] X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Tue, 10 Oct 2023 07:27:54 +0200 X-ME-IP: 86.243.2.178 Message-ID: Date: Tue, 10 Oct 2023 07:27:48 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [ovs-dev] [PATCH net-next 2/2] net: openvswitch: Annotate struct mask_array with __counted_byUse struct_size() To: Ilya Maximets , keescook@chromium.org, Pravin B Shelar , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Gustavo A. R. Silva" , Nathan Chancellor , Nick Desaulniers , Tom Rix Cc: dev@openvswitch.org, netdev@vger.kernel.org, llvm@lists.linux.dev, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org References: <8be59c9e06fca8eff2f264abb4c2f74db0b19a9e.1696156198.git.christophe.jaillet@wanadoo.fr> <689fe81f-e2b4-9f99-4005-8ae330afb869@ovn.org> Content-Language: fr From: Christophe JAILLET In-Reply-To: <689fe81f-e2b4-9f99-4005-8ae330afb869@ovn.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no 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]); Mon, 09 Oct 2023 22:28:22 -0700 (PDT) X-Spam-Level: ** Le 02/10/2023 à 18:51, Ilya Maximets a écrit : > On 10/1/23 13:07, Christophe JAILLET 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 checking via CONFIG_UBSAN_BOUNDS >> (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family >> functions). >> >> Signed-off-by: Christophe JAILLET >> --- >> This patch is part of a work done in parallel of what is currently worked >> on by Kees Cook. >> >> My patches are only related to corner cases that do NOT match the >> semantic of his Coccinelle script[1]. >> >> In this case, in tbl_mask_array_alloc(), several things are allocated with >> a single allocation. Then, some pointer arithmetic computes the address of >> the memory after the flex-array. >> >> [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci >> --- >> net/openvswitch/flow_table.h | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/net/openvswitch/flow_table.h b/net/openvswitch/flow_table.h >> index 9e659db78c05..8d9e83b4d62c 100644 >> --- a/net/openvswitch/flow_table.h >> +++ b/net/openvswitch/flow_table.h >> @@ -48,7 +48,7 @@ struct mask_array { >> int count, max; >> struct mask_array_stats __percpu *masks_usage_stats; >> u64 *masks_usage_zero_cntr; >> - struct sw_flow_mask __rcu *masks[]; >> + struct sw_flow_mask __rcu *masks[] __counted_by(size); > > Did you mean 'max'? There is no 'size' in the structure. Hi, Of courtse, yes. I'll resend. 'size' is the name of the variable that is written in mask_array->max in tbl_mask_array_alloc() > > Also, the patch subject is messed up a bit. Yes. Will fix it as well. CJ > > Best regards, Ilya Maximets. >