From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from omta40.uswest2.a.cloudfilter.net (omta40.uswest2.a.cloudfilter.net [35.89.44.39]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 575DF62C for ; Fri, 18 Aug 2023 01:25:41 +0000 (UTC) Received: from eig-obgw-5004a.ext.cloudfilter.net ([10.0.29.221]) by cmsmtp with ESMTP id WncWq47KrbK1VWoDdqk2LN; Fri, 18 Aug 2023 01:24:05 +0000 Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with ESMTPS id WoDdqi1uZD5qiWoDdqd1UX; Fri, 18 Aug 2023 01:24:05 +0000 X-Authority-Analysis: v=2.4 cv=dMe1JcVb c=1 sm=1 tr=0 ts=64dec835 a=1YbLdUo/zbTtOZ3uB5T3HA==:117 a=WzbPXH4gqzPVN0x6HrNMNA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=UttIx32zK-AA:10 a=wYkD_t78qR0A:10 a=NEAV23lmAAAA:8 a=VwQbUJbxAAAA:8 a=8b9GpE9nAAAA:8 a=JfrnYn6hAAAA:8 a=cm27Pg_UAAAA:8 a=HvF037n1xESchLcPDVoA:9 a=QEXdDO2ut3YA:10 a=AjGcO6oz07-iQ99wixmX:22 a=T3LWEMljR5ZiDmsYVIUa:22 a=1CNFftbPRP8L7MoqJWF3: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=wt9JyjAgPAPGR6Wixh0L2cZNzUJH2xdSJeUmcul+zXU=; b=fOt1P9YrKkwR7S6EO+WBSFOTvo 4BviY69h6yC/WlD7H9hQzJ9N0IquEbi+J0eRxmndLOilfz/K6d92Cxs7Llm4lbqeV80IqSDtZTPIw izYPYBAO55EZGBG4RXMEBjFqeaorvfSsOAZJob3wfV984/s18gTYitS/y7RPoWTDbCT78+i9cJeQF liYgvw85iZvbqloKqq/PROxSSVuBREBVw9ipEhEk4YEvcaVUt6efEQFdEc2YgxEymkgvmSgr6C64k xbR2pDkNybfy25EtsK2HaPvYON9YEMjX9JnkeDcM5lUrpscXW0dpu3ZD1mhCrxPWsVFBuHTLViH4e kgBXFNkA==; Received: from 187-162-21-192.static.axtel.net ([187.162.21.192]:46760 helo=[192.168.15.8]) by gator4166.hostgator.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1qWoDW-000WfM-1p; Thu, 17 Aug 2023 20:23:58 -0500 Message-ID: <996abdd6-dd83-b4b3-e347-2889e9d2e7ef@embeddedor.com> Date: Thu, 17 Aug 2023 19:24:57 -0600 Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH 11/21] dmaengine: st_fdma: Annotate struct st_fdma_desc with __counted_by Content-Language: en-US To: Kees Cook , Vinod Koul Cc: Patrice Chotard , linux-arm-kernel@lists.infradead.org, dmaengine@vger.kernel.org, Hector Martin , Sven Peter , Alyssa Rosenzweig , Ludovic Desroches , Tudor Ambarus , Lars-Peter Clausen , Zhou Wang , Jie Hai , Andy Gross , Bjorn Andersson , Konrad Dybcio , Green Wan , Orson Zhai , Baolin Wang , Chunyan Zhang , Maxime Coquelin , Alexandre Torgue , Laxman Dewangan , Jon Hunter , Thierry Reding , Peter Ujfalusi , Kunihiko Hayashi , Masami Hiramatsu , Yu Kuai , Greg Kroah-Hartman , Jordy Zomer , Jernej Skrabec , Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-msm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-tegra@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org References: <20230817235428.never.111-kees@kernel.org> <20230817235859.49846-11-keescook@chromium.org> From: "Gustavo A. R. Silva" In-Reply-To: <20230817235859.49846-11-keescook@chromium.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 - lists.linux.dev X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 187.162.21.192 X-Source-L: No X-Exim-ID: 1qWoDW-000WfM-1p X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 187-162-21-192.static.axtel.net ([192.168.15.8]) [187.162.21.192]:46760 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 338 X-Org: HG=hgshared;ORG=hostgator; X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfFNn/nYkNWCu465x55Rpji6BrcDzSlEk3XM/ityrmJF+fJouSvhRhKGR7YR/g1szFAqVQpnqpgTs1H0aneIcfV3WZ4plgYQB7CdXvHxRddgBxAGbfDxr hIHPhE+i+MDT43jHDP8ab08mMhpaGddlexQDBW3zYR0Zortpr3Zicb/SrmgzMWoS4sJNn8kRW4pr9HdBU/N+IVvGLXKOWqKQ6SM= On 8/17/23 17:58, 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 st_fdma_desc. > > [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci > > Cc: Vinod Koul > Cc: Patrice Chotard > Cc: linux-arm-kernel@lists.infradead.org > Cc: dmaengine@vger.kernel.org > Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva Thanks -- Gustavo > --- > drivers/dma/st_fdma.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/dma/st_fdma.h b/drivers/dma/st_fdma.h > index fa15b97a3bab..f296412e96b6 100644 > --- a/drivers/dma/st_fdma.h > +++ b/drivers/dma/st_fdma.h > @@ -97,7 +97,7 @@ struct st_fdma_desc { > struct st_fdma_chan *fchan; > bool iscyclic; > unsigned int n_nodes; > - struct st_fdma_sw_node node[]; > + struct st_fdma_sw_node node[] __counted_by(n_nodes); > }; > > enum st_fdma_type {