From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D181CE7A88 for ; Sat, 23 Sep 2023 08:55:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230406AbjIWIz1 (ORCPT ); Sat, 23 Sep 2023 04:55:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230204AbjIWIzZ (ORCPT ); Sat, 23 Sep 2023 04:55:25 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 265A0136; Sat, 23 Sep 2023 01:55:20 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BE79BC433C7; Sat, 23 Sep 2023 08:55:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695459319; bh=lseakF6M2dlhTAVWNVK3bOAsavTxJDpelRRD6WFVyqM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OuhpNCZ9pA/PjelUbm7C5AC7eEHLWgQTWDcs6fnqF8fSTroxBm2WuVxfByP7lIgEI W31HIc3p60iYfcgSz6Noo3GWdnDE7R6SpRKw0zb/Rj7Ds4Rrny6OEnTeOIi6W0i8Xf w7pO4haVIbSFNVEq93YgfQJ2mVC/wAAyS0tw4QSeiAp3fGogE8Yrw+b8EGoVqqCGKu BRzwRmQR7qchrGZC4jIMQOZmxDKvMKJu2+0i4QgQSZeNPOlBTYFhLGmp1DcLr1xp2c SPG6XyJtctIOxt5YmDQgsr6/1uYCXQs+Sj19/m2XKeaYa7Wi/h0DfmPzlCPBnlLwHJ tk7pZhocEtXXA== Date: Sat, 23 Sep 2023 10:56:21 -0600 From: "Gustavo A. R. Silva" To: Kees Cook Cc: Jorge Lopez , Hans de Goede , Mark Gross , Nathan Chancellor , Nick Desaulniers , Tom Rix , platform-driver-x86@vger.kernel.org, llvm@lists.linux.dev, Ilpo =?iso-8859-1?Q?J=E4rvinen?= , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] platform/x86: hp-bioscfg: Annotate struct bios_args with __counted_by Message-ID: References: <20230922175420.work.701-kees@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230922175420.work.701-kees@kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 22, 2023 at 10:54:21AM -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 bios_args. > > [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci > > Cc: Jorge Lopez > Cc: Hans de Goede > Cc: Mark Gross > Cc: Nathan Chancellor > Cc: Nick Desaulniers > Cc: Tom Rix > Cc: platform-driver-x86@vger.kernel.org > Cc: llvm@lists.linux.dev > Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva Thanks -- Gustavo > --- > drivers/platform/x86/hp/hp-bioscfg/biosattr-interface.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/platform/x86/hp/hp-bioscfg/biosattr-interface.c b/drivers/platform/x86/hp/hp-bioscfg/biosattr-interface.c > index dea54f35b8b5..4da99cb7218d 100644 > --- a/drivers/platform/x86/hp/hp-bioscfg/biosattr-interface.c > +++ b/drivers/platform/x86/hp/hp-bioscfg/biosattr-interface.c > @@ -19,7 +19,7 @@ struct bios_args { > u32 command; > u32 commandtype; > u32 datasize; > - u8 data[]; > + u8 data[] __counted_by(datasize); > }; > > /** > -- > 2.34.1 > >