Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp74270rdh; Sat, 23 Sep 2023 01:59:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG3hGYnFZj8Xl9avmupEtqRrH+elDCFeW/HUcucS96uOd0gaS5uy1EIYhD7wsuHtl+y1Bp+ X-Received: by 2002:a05:6358:2823:b0:135:47e8:76e2 with SMTP id k35-20020a056358282300b0013547e876e2mr2244095rwb.4.1695459584578; Sat, 23 Sep 2023 01:59:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695459584; cv=none; d=google.com; s=arc-20160816; b=cuUqXUo5RMl8E2yraho90aPbQoottirQG8Ptn0zuA1EsqIed91bUaJaH+Lwv3heKb8 FvxjBoitDwxkF45HUDTNUIfR3R7qUokmF7CUX4x95XJiPcPxTSDBQ5fJrrZ8SacsoA6C +z8xEeXsQfBkD9qnuQHmi5KkTb+I1j87cbYmd7r0qBCyxqal6zoB12Ahsd/8yi+bHStn vAIigG2jNn1mBqDf92rbFKdQHAay38gcAflAtwTVs8gZI9y6UjUaHMpL0hOHKm/xRME1 9il9cDPMhqnj+EmK5GyXm2K9hg+kFoSNPrilWfdgDiPhgI9ae5Gnn6VfEgV3cvrpauJh pw0w== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=MMe3k6rs4nig4w6rbqD8pvt/cCPJ/q8N90kT2NBlzU8=; fh=sa8nn1U4nQOzeV2BXe2Q/1K9hg7lhRHSrmlcF18MHik=; b=Kxy2OQAtPk0sOR06c78WS6/k/pY7dfSHQrF8QwIUdc2tUIpPg/LisutknklY9Slo7t KmZYxkdBK8b1CJZXrmLIr4jrrqNYtk+omO5Te9BkjM7A8VPZJvzqWXJIG38WmxCiIlrX 1++peU/HUwN/8voA6dr6giWKOHR05QlDFiV7It8xSfi4R7XWhuX6Avu5/biZ6/3jEnPG eNqRzMrtUJeuqP0GloFMdpV4hcYSDMIe2dcKgtZUREHFEYPAnXLX5rgdi57l7Yw+9gtb qQR7s+q8L8jiEPQrQocRMkJAaGu3MIkgKkq8uTa2c0Z1TVyJgX2G4o0QqPLPOvOj7kC2 Fwow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HpEvuWBf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id l3-20020a056a00140300b0068e4037c5f7si5699122pfu.388.2023.09.23.01.59.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 01:59:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HpEvuWBf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id DEF268359486; Sat, 23 Sep 2023 01:59:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231146AbjIWI7l (ORCPT + 99 others); Sat, 23 Sep 2023 04:59:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231150AbjIWI7h (ORCPT ); Sat, 23 Sep 2023 04:59:37 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41DCB19F for ; Sat, 23 Sep 2023 01:59:32 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69F15C433C8; Sat, 23 Sep 2023 08:59:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695459571; bh=H52331EVg7A5/+bK/CkdwvyqaImONzevbLINXxNt+x4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=HpEvuWBfhxR/SSWFuXvHoDHil+6oKCVuE8hGCjzOfTPIWbeQ37p/iBHkPx++K+aS/ bxkeIKDodmcyqytigm95aEYLKRC219jPm8VfdVuztMAj7pw3InXoRxqT+4k8FnTXbB I8ET3lUevsJrfaX9JEQWhhzGhALZ1+mUjE5ajXVgg9KFUIgcbDeE/QZIRp/+DKnQ8K iZuJC5+xl830vvBtIM/ZeHmUesP2/R4lWT0akhJuSpwPCumVrtmv1hNUk7VHq8KuFd DSNd7s2AtnjuJPQm2SBLPFvXa1WsR6FWkeLxO4v5aK6XcU+65V9JAhKFHIgJfFgH77 pC/6S2SVGlhKA== Date: Sat, 23 Sep 2023 11:00:33 -0600 From: "Gustavo A. R. Silva" To: Kees Cook Cc: Alexandre Belloni , Jeremy Kerr , Joel Stanley , linux-i3c@lists.infradead.org, Nathan Chancellor , Nick Desaulniers , Tom Rix , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , Matt Johnston , Krzysztof Kozlowski , Jack Chen , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: Re: [PATCH] i3c: dw: Annotate struct dw_i3c_xfer with __counted_by Message-ID: References: <20230922175011.work.800-kees@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230922175011.work.800-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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Sat, 23 Sep 2023 01:59:41 -0700 (PDT) X-Spam-Level: ** On Fri, Sep 22, 2023 at 10:50:11AM -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 dw_i3c_xfer. > > [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci > > Cc: Alexandre Belloni > Cc: Jeremy Kerr > Cc: Joel Stanley > Cc: linux-i3c@lists.infradead.org > Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva Thanks -- Gustavo > --- > drivers/i3c/master/dw-i3c-master.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/i3c/master/dw-i3c-master.c b/drivers/i3c/master/dw-i3c-master.c > index 9332ae5f6419..ef5751e91cc9 100644 > --- a/drivers/i3c/master/dw-i3c-master.c > +++ b/drivers/i3c/master/dw-i3c-master.c > @@ -233,7 +233,7 @@ struct dw_i3c_xfer { > struct completion comp; > int ret; > unsigned int ncmds; > - struct dw_i3c_cmd cmds[]; > + struct dw_i3c_cmd cmds[] __counted_by(ncmds); > }; > > struct dw_i3c_i2c_dev_data { > -- > 2.34.1 > >