Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp443330rdh; Sat, 23 Sep 2023 18:41:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHhxWgKd45/m/EOOSP2006DsbBpYJwsWmz05mxpxURd3THo/ZLGJV0c5WhClRFdSdgjrqI8 X-Received: by 2002:a05:622a:4c8:b0:413:5d52:ee17 with SMTP id q8-20020a05622a04c800b004135d52ee17mr3510111qtx.42.1695519704145; Sat, 23 Sep 2023 18:41:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695519704; cv=none; d=google.com; s=arc-20160816; b=V3vWm9NIawEXa6P1aQIqa5c71yj0VVqdaapXfPPkRB72b0/y9Ykl00s/ngqm5zS0sC 2FNEMwIuH4nMxDmDTDe1mu+MFYaO+wfp0xrXb5aWNhOulkzgkWIjm674XHTvPjA0Oc1g 1S1f4rFlZpwbIp0m2ozAw3OfhxYDokLyEkdlpDm20OFKa6/A9Q/ygDDTYJAWjBvN2EF7 TpIKJIDxHguOhoN5KkiJ7zFBLCf06WqFpDUd7fhJob9q3VVjNUPEbyKblBtGBzJAqhS2 HKpqrZyt69AsUum43nUC0Fg4WDSuQvYKYydItsB3EqDsJoQkSo3OHQ1K1+XXjabEoQNj rtpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=u5/PPzzCx21+32s0aYlv06SUgr2FZ2QgBdbWkjoYS+I=; fh=qJrpsi84TLp/KaZc+ImJgZlTP0OmOp/3oDA1H7a2VYM=; b=CPv5pHbdE6mHjoKvI7UbtnYhSYoxeIij34OD5CJRCOpmrJpRWm8zZsp2zhjmP0WbxX +5E4akD1rL76LTkGo6bMoiRbQIE9triRMAYyR3djiydcaVNRiKosUA03uh+ZWrdCTse+ y9KgyhZVno6GHjpJ5EVf4U4xcE9lXEnDcQN81zcTJGmaSdunjW2S6YX5+LSzaJ0CKkwg xQR18/Vk3gmDpk7bSBuMeqYw/lF2mM933TSQXrLgGW2ht0rum8mNKaIpKuLsg/kpVoBA C3U1aTrCTC9m0KNZ9rantxVHtUyVC0P8FXwxJrRyGe9KLr/vYg4fAUBUKhDOMU1F+kFY 7aCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b=b3N8+G3i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id ca37-20020a056a0206a500b00578a43e3b0bsi7965272pgb.655.2023.09.23.18.41.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 18:41:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b=b3N8+G3i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id AB242801F815; Sat, 23 Sep 2023 18:41:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229732AbjIXBln (ORCPT + 99 others); Sat, 23 Sep 2023 21:41:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229535AbjIXBlm (ORCPT ); Sat, 23 Sep 2023 21:41:42 -0400 Received: from omta34.uswest2.a.cloudfilter.net (omta34.uswest2.a.cloudfilter.net [35.89.44.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32526113; Sat, 23 Sep 2023 18:41:36 -0700 (PDT) Received: from eig-obgw-5003a.ext.cloudfilter.net ([10.0.29.159]) by cmsmtp with ESMTP id jjIJqfzocOzKlkE7rqKiI6; Sun, 24 Sep 2023 01:41:35 +0000 Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with ESMTPS id kE7qqeYMmVpk9kE7qqZQuC; Sun, 24 Sep 2023 01:41:35 +0000 X-Authority-Analysis: v=2.4 cv=CLw54DnD c=1 sm=1 tr=0 ts=650f93cf a=1YbLdUo/zbTtOZ3uB5T3HA==:117 a=P7XfKmiOJ4/qXqHZrN7ymg==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=zNV7Rl7Rt7sA:10 a=wYkD_t78qR0A:10 a=NEAV23lmAAAA:8 a=VwQbUJbxAAAA:8 a=cm27Pg_UAAAA:8 a=HvF037n1xESchLcPDVoA:9 a=QEXdDO2ut3YA:10 a=AjGcO6oz07-iQ99wixmX:22 a=xmb-EsYY8bH0VWELuYED:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=embeddedor.com; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=u5/PPzzCx21+32s0aYlv06SUgr2FZ2QgBdbWkjoYS+I=; b=b3N8+G3iXbFmFhxj4q7r9muAw1 KvvzLR7CvUcWRrdR8QBo8wxAVUgKCFGxgzu4Is/AKbZqLOaS5vuPTI+Ca/E6ih3pD34ebHep9DtcG m+ofHrytuiDCICg98GyPRCigslGsbt2n1xxZh0h2JqEHQ3F9hOr1fb1xGxTU5cCBPllZkrEdUkMN7 n9oPKNrqPQwTlitJh8HPOHjV9edYLxaT06HFNWdttdINU/coat8B2DFvwDWifaeMonxiQII3GaQp2 hHB3bZBng4BRUwcWbvGYETdlehXLAOr6trq+BI6vcPhpQpXR2N4JgQs7sYBQw5O6VkDJnputtnCYC 7izDHduw==; Received: from [94.239.20.48] (port=47808 helo=[192.168.1.98]) by gator4166.hostgator.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1qjy7a-003gjN-1c; Sat, 23 Sep 2023 03:36:14 -0500 Message-ID: Date: Sat, 23 Sep 2023 10:37:20 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH] mfd: iqs62x: Annotate struct iqs62x_fw_blk with __counted_by Content-Language: en-US To: Kees Cook , Lee Jones Cc: Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org References: <20230922175337.work.150-kees@kernel.org> From: "Gustavo A. R. Silva" In-Reply-To: <20230922175337.work.150-kees@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 94.239.20.48 X-Source-L: No X-Exim-ID: 1qjy7a-003gjN-1c X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: ([192.168.1.98]) [94.239.20.48]:47808 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 0 X-Org: HG=hgshared;ORG=hostgator; X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfNhtPmp6hj9JVqci7JT5arQ6uJSf5/LayDtJWoi9cjI2XUElLTpqrhz7Hq3gyBFkuwYjsoQEe3wlbAzAs5z3fPiXkabSakHSpHW0/LWkdgvwdSHLNii+ aQwl3flD2T/EkXtOsZQYuXx2K+sMyXLENxpbfy/rp4z0XbSznpuaWdksU2B5NKqjBc447SOuHDRYQAH/mqgFIpEAHTVHigkBbUXlCyXkoMPqMAKK0mIehUMi G2Yjry6/iyf65IeA4HR73bF8dWx3lnv0aAeMHC/eHLk= X-Spam-Status: No, score=-2.0 required=5.0 tests=DATE_IN_FUTURE_06_12, DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.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 (morse.vger.email [0.0.0.0]); Sat, 23 Sep 2023 18:41:41 -0700 (PDT) On 9/22/23 11:53, 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 iqs62x_fw_blk. > > [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci > > Cc: Lee Jones > Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva Thanks -- Gustavo > --- > drivers/mfd/iqs62x.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/mfd/iqs62x.c b/drivers/mfd/iqs62x.c > index e03b4d38fbb0..1b465590567c 100644 > --- a/drivers/mfd/iqs62x.c > +++ b/drivers/mfd/iqs62x.c > @@ -96,7 +96,7 @@ struct iqs62x_fw_blk { > u8 addr; > u8 mask; > u8 len; > - u8 data[]; > + u8 data[] __counted_by(len); > }; > > struct iqs62x_info {