Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp806975rdb; Sun, 1 Oct 2023 06:27:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGXbOo9jpnTdPV4fqC72hN47PxJtgmObTpqZSWpR/ZGMYNmyidrOIsoypT/L/BokVY4XvPm X-Received: by 2002:a17:902:c409:b0:1c1:e818:1e76 with SMTP id k9-20020a170902c40900b001c1e8181e76mr13948144plk.6.1696166826712; Sun, 01 Oct 2023 06:27:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696166826; cv=none; d=google.com; s=arc-20160816; b=RHorKXJRizBPWka5bL5T/FsEF/Dn27ZG/bZmDKP7GHoT8t9xjy2JyLuQJycrkv38A+ EsNwI9saHkQc/kL+VqVLYM9wnlNpf4jNeo/ke7ppFxmateblrKg9eJ4x2mxrrXd35w2L Dy36pGnePvk5J11c67IfmqSuP0QIr3sJqZJvagxnmGZqq/fjotRKbAmGU3to5G5+i1Ao ctCY8BPuygUcb2JnA9m3nouYGT88JQtnclDJPi4UOnos7opTYeHBTCW5suOlX+JlDA/3 tUCS33Lxk9KxGsSLGyLuB2jNpHTND5mrZCmhF/IWJbowiKew6vQdlJ0pVvGPPm04kcr+ jL2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=v9P7JS8Eo6gg0JgpQ/a5dnlXc7ZeGy/7g3pcTmVCJ18=; fh=144h59Trx5ef5R0VkTN5OfufadNCskPabTmJJAa01IQ=; b=W3HOZPmCImIm3vvqnCRp1A/D1/Vrh2p30ikLh9RCTb21qHs40mE2i3ShFFdkV1CTLJ gGXS3TaXdNf5wqZTeCPalUpJ3qoXwSsCo63PI7754HDv9BSwdM3Lqxa4JcIohhXEBDxf hDye2VMfqLBzQOJdV+mBL3YbHIer9ILSSUaURtXAmLMfocw8jfsssxQO2aSFZ5MZNB/S JmiGE4raFGHG2G27xkrHOJU6ttAayovCp+yWjSIIt70Rrsb5SSZGHde8jSkHS29oG3Zj 4C6OCJUj+kmKEZsuJpMxNvSb4E9VxWrZtvrS1N+TlAtabVxe0aMiWFmBFDkVzHYa933+ pfqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=OcrHXPEw; 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=wanadoo.fr Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id y15-20020a17090322cf00b001c470c25409si26248991plg.327.2023.10.01.06.27.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 06:27:06 -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=@wanadoo.fr header.s=t20230301 header.b=OcrHXPEw; 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=wanadoo.fr Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 8F43F80A5FAB; Sun, 1 Oct 2023 04:10:33 -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 S234885AbjJALHn (ORCPT + 99 others); Sun, 1 Oct 2023 07:07:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234873AbjJALHk (ORCPT ); Sun, 1 Oct 2023 07:07:40 -0400 Received: from smtp.smtpout.orange.fr (smtp-26.smtpout.orange.fr [80.12.242.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A66EDD for ; Sun, 1 Oct 2023 04:07:37 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id muIKqTqNAm6tamuIRq8U3c; Sun, 01 Oct 2023 13:07:36 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1696158456; bh=v9P7JS8Eo6gg0JgpQ/a5dnlXc7ZeGy/7g3pcTmVCJ18=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=OcrHXPEwJq5ccOGM2WWXMREYaA5x0o3Tt5f28aR5RqTrPTdP8zPl6Hd6n0mtT99Tv 1KHlmqCZPA7tCaA0QYbYkbQ+SmOJPAc2RDlcL6TtG0gyKE8KZP4+U9/GKRDBW+GCp6 VzWecaU8rn3uaqyZ8qYdCITjFOtAqHPeX3w6zoM+d5R8cWW0FBa1TCFlMIuXAoNNSv yNqQoese2sMY/E4nuu0QocTSjow/jUUN7brb7p0UkkKckCpc7lPXVcsS6Fk3d0bA9m tpBLPy4DIdYTZKJVl6e1HeXg7sdsUnpTyrqCh2IyL22dIUZesYXZbSffSWzSu9wvfM IkgecWhFDL3cQ== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 01 Oct 2023 13:07:36 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: 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: linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , netdev@vger.kernel.org, dev@openvswitch.org, llvm@lists.linux.dev Subject: [PATCH net-next 2/2] net: openvswitch: Annotate struct mask_array with __counted_byUse struct_size() Date: Sun, 1 Oct 2023 13:07:23 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: <8be59c9e06fca8eff2f264abb4c2f74db0b19a9e.1696156198.git.christophe.jaillet@wanadoo.fr> References: <8be59c9e06fca8eff2f264abb4c2f74db0b19a9e.1696156198.git.christophe.jaillet@wanadoo.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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_PASS,SPF_PASS autolearn=unavailable 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]); Sun, 01 Oct 2023 04:10:33 -0700 (PDT) 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); }; struct table_instance { -- 2.34.1