Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp74155rdh; Sat, 23 Sep 2023 01:59:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEpE6N8DgfUKQbs2MNuX7Ztf98ZexysVkBxAr+2iZv9pUM5sT0y/JfdEGWRIbum0mve0EtR X-Received: by 2002:ac8:7f83:0:b0:414:e458:ab0e with SMTP id z3-20020ac87f83000000b00414e458ab0emr1955340qtj.68.1695459560664; Sat, 23 Sep 2023 01:59:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695459560; cv=none; d=google.com; s=arc-20160816; b=MFgAWpwo4op4MNGWCUTvigxCNkjEFP+5ooQyGjhZb2NmSaG9SEP0TfXmTU3lZK18rb 8j8RuuWHRI+6yeJYSkyniVsMBXU3sb9BPfwDgTIdNpTMP4w5PCkkajxb5GysdgsF3JXU bbj+1dtx3HAxsQ85z51IYVFNAkxffX3jsm6hxpYwVQSG/rTPKqI2/Qc3jclxcrUSj7Qx W3lPXeUYsFdnhKw8o06WGNBD49qrdV8tmnECAeofZ43wLNUJLi/xuDLFdz3syzCShgwP ERQTMv1Zi8aOreZfo/Aen4QUSXAVGvQ/VoedwKLzLG5W/3E3fJxb9reSGReqgD5Bk2AH gghQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=SRYBz0aSVx5/1XCxkHJyovL8mSLC5cqgktD5dd2jqnQ=; fh=rySVY4OQ5cPy71DM3LCRMPHo1HCIWlyHUPaw2XdYsl4=; b=Y5TJ33Imnk0YiHZEctYtJJt15d2u3d6FHYmMx5MQ97TPXBsL6UA1Z4GkZ6uyPI8ns3 HEbDOfKrwF4KFal7JuP5842+rRcPF8rKkOZD8pud02eIvYQ+uZQyQGx9Cd1LTcbMPwfD +OGTIaHLbGQB2GwY1w04bBrxiDxwFfcJBA80gpyaDfyHB/AmPcadSrREnGeV+CfPOWWW xmhN/Tb2porC1fq9wFbObSqDMOBFttDzMOyULSwCLMHojA7oDvh7HBht/e8A2SiO0x+X eGod7f+sLLUJtaBNcRrwd+m3OWm+5xLnypR2g8ClpbU1ClWguaLgogvUDLjij/spUDvo JBAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="tUhnc/sq"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id 21-20020a630d55000000b005649cee422esi5691432pgn.464.2023.09.23.01.59.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 01:59:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="tUhnc/sq"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id ED84B82D2B4D; Sat, 23 Sep 2023 01:59:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231146AbjIWI7R (ORCPT + 99 others); Sat, 23 Sep 2023 04:59:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230416AbjIWI7Q (ORCPT ); Sat, 23 Sep 2023 04:59:16 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DF20136; Sat, 23 Sep 2023 01:59:10 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 274C3C433C8; Sat, 23 Sep 2023 08:59:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695459549; bh=09E8iJecgFYMexjTYJZ5CJ3jBfm+QiwYB3b9gl5Rd3g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tUhnc/sqC/wOn9t/Ho8mYpdoZNToa8x6ToMKPC7Y7Fs4OFRmNXmR1f74PlI9UKLU3 YCOq9U+1jMLm0Pt2mOk34zT2wUvnj1/whZWWZCLEW9imKz5gF5U7WaFMA1b6n+uLjo rLo4BTYA8cxQv2YNn9qRhrHCMkY0Lp54kqv60r2Y9oabBpaiziQpyGPFE8WdCzcwg7 3IOVPohUye91FVAHJ6PVWS6QGzFjX2ZS9Ueb2vRwbotb2oCrutuF8AYxux4Mmk1Swk zyFHDJkgCWO+04LGqCVZXmFNEnCV3ijKetwc7asvEUUo7e/nkdnFI0NRTgPRvocAV7 3pYGPyFdF668Q== Date: Sat, 23 Sep 2023 11:00:11 -0600 From: "Gustavo A. R. Silva" To: Kees Cook Cc: "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org, Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: Re: [PATCH] PCI: hv: Annotate struct hv_dr_state with __counted_by Message-ID: References: <20230922175257.work.900-kees@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230922175257.work.900-kees@kernel.org> X-Spam-Status: No, score=2.4 required=5.0 tests=DATE_IN_FUTURE_06_12, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, 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 agentk.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 (agentk.vger.email [0.0.0.0]); Sat, 23 Sep 2023 01:59:17 -0700 (PDT) X-Spam-Level: ** On Fri, Sep 22, 2023 at 10:52:57AM -0700, 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 checking 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 hv_dr_state. > > [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci > > Cc: "K. Y. Srinivasan" > Cc: Haiyang Zhang > Cc: Wei Liu > Cc: Dexuan Cui > Cc: Lorenzo Pieralisi > Cc: "Krzysztof WilczyƄski" > Cc: Rob Herring > Cc: Bjorn Helgaas > Cc: linux-hyperv@vger.kernel.org > Cc: linux-pci@vger.kernel.org > Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva Thanks -- Gustavo > --- > drivers/pci/controller/pci-hyperv.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c > index bed3cefdaf19..30c7dfeccb16 100644 > --- a/drivers/pci/controller/pci-hyperv.c > +++ b/drivers/pci/controller/pci-hyperv.c > @@ -545,7 +545,7 @@ struct hv_pcidev_description { > struct hv_dr_state { > struct list_head list_entry; > u32 device_count; > - struct hv_pcidev_description func[]; > + struct hv_pcidev_description func[] __counted_by(device_count); > }; > > struct hv_pci_dev { > -- > 2.34.1 > >