Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1828060rdg; Sat, 14 Oct 2023 21:53:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEgdI0iiTpw90qWobmT12X+Y2ELOCkwBiAfyviBJuXIsfLCD+KtQpb+W3U+ELc4VF6DDb4g X-Received: by 2002:a05:6870:4998:b0:1e9:dd69:2fc1 with SMTP id ho24-20020a056870499800b001e9dd692fc1mr7118676oab.7.1697345621806; Sat, 14 Oct 2023 21:53:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697345621; cv=none; d=google.com; s=arc-20160816; b=KaHbTYd52UBiQr1CofupvQhR/vviMQfR9HhdqWuZMw8v4nQ77Y+bHd8vPQSdYeIlZe Mscw5e3I9q6ZW7B/zQgLWBl/gsn3vEsgy4l1rhfr+8aYKwMCnFhDdxz47nwf5WGRueAy NL5emj7YHL13DRXd7DniNnW5Mlixyaly/43X97jVfb4lhS35lK/nbl6tmZ4lq7zM3gTM zDFKuqaeB83YiZM+74PSnb/EJgDB8q0qb71JFqxk7J1971xoySxVLiTlHBdHm6YJ/Q+s 1nlV4ioO97nTEJLmMMptrJOoYSPLMEpqwjUEuWXbQl5HwpnlC1ir1p332hc0hTCxbsxS c/3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=fMGwmeCiI2WGZSSIY9zDXk4JfSuYvkdAr36FIasOYjU=; fh=37NeBPPAr4R80fBJnORA5NhNeiBAILywWWpKaMUkMVs=; b=ZsFTATIjh+H9svUm7pvbocRxCtAxdij7V76VvctbffbX9zAlX+QRKWWu0PwC1z0Yno Kw7upmOi6sBTMPZ2n1Z/PZfCRV9cWggPeZ99PEdY1U05WV/YjXc4/IlynsOFGukTYklQ z+YY40qHYW+3seE3ck+pGkImQLlsUqxbJARWIe2755kfux3XO66VjiWhenoRHFeyNNq5 wNU/r84GFZWzwy4I9LJrX5Lm/p/MelDzVaIVyNb89LQ736soHuL1KzPi647i2ShT9sFm 7H4R2GAllDItfJ1dBIx+1yb7CMUDjsBC8RcDJ0e7MqJuKEO/a/4phZ7M+ywy8X2PWHKU g+Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=k5IQxBjX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id g62-20020a636b41000000b0055e607f1e99si7932573pgc.882.2023.10.14.21.53.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Oct 2023 21:53:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=k5IQxBjX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id B4D2A804DD8C; Sat, 14 Oct 2023 21:53:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233472AbjJOExg (ORCPT + 99 others); Sun, 15 Oct 2023 00:53:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230091AbjJOExf (ORCPT ); Sun, 15 Oct 2023 00:53:35 -0400 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9D1DD9; Sat, 14 Oct 2023 21:53:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=fMGwmeCiI2WGZSSIY9zDXk4JfSuYvkdAr36FIasOYjU=; b=k5IQxBjXGV3CnXmP7VgfiaoFeBhRXdFbvwWcEJ86HrDH2aegcMqgy9/b I9LI0HC1txkCq9sNogIroruo9K0Hh9y5ZrXnsAxRar8tN2v4I3LVDbRSv x6yt7j8E7k1e7EcOSnJOckIDAkgHN9kLA1i0nOA4E0PtLe9QlrFZZ21U9 w=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=julia.lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.03,226,1694728800"; d="scan'208";a="68734435" Received: from 231.85.89.92.rev.sfr.net (HELO hadrien) ([92.89.85.231]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2023 06:53:30 +0200 Date: Sun, 15 Oct 2023 06:53:29 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: Kees Cook cc: Christophe JAILLET , Pravin B Shelar , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Gustavo A. R. Silva" , Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, netdev@vger.kernel.org, dev@openvswitch.org, linux-hardening@vger.kernel.org, llvm@lists.linux.dev Subject: Re: [PATCH v2 2/2] net: openvswitch: Annotate struct mask_array with __counted_by In-Reply-To: <202310141928.23985F1CA@keescook> Message-ID: References: <202310141928.23985F1CA@keescook> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 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 (snail.vger.email [0.0.0.0]); Sat, 14 Oct 2023 21:53:40 -0700 (PDT) On Sat, 14 Oct 2023, Kees Cook wrote: > On Sat, Oct 14, 2023 at 08:34:53AM +0200, 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 > > --- > > v2: Fix the subject [Ilya Maximets] > > fix the field name used with __counted_by [Ilya Maximets] > > > > v1: https://lore.kernel.org/all/f66ddcf1ef9328f10292ea75a17b584359b6cde3.1696156198.git.christophe.jaillet@wanadoo.fr/ > > > > > > 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]. What was the problem with the semantic patch in this case? thanks, julia > > > > 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..f524dc3e4862 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(max); > > }; > > Yup, this looks correct to me. Thanks! > > Reviewed-by: Kees Cook > > -- > Kees Cook >