All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Kees Cook <keescook@chromium.org>, Vinod Koul <vkoul@kernel.org>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Alexandre Torgue <alexandre.torgue@foss.st.com>,
	dmaengine@vger.kernel.org,
	linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org,
	Hector Martin <marcan@marcan.st>, Sven Peter <sven@svenpeter.dev>,
	Alyssa Rosenzweig <alyssa@rosenzweig.io>,
	Ludovic Desroches <ludovic.desroches@microchip.com>,
	Tudor Ambarus <tudor.ambarus@linaro.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Zhou Wang <wangzhou1@hisilicon.com>, Jie Hai <haijie1@huawei.com>,
	Andy Gross <agross@kernel.org>,
	Bjorn Andersson <andersson@kernel.org>,
	Konrad Dybcio <konrad.dybcio@linaro.org>,
	Green Wan <green.wan@sifive.com>,
	Orson Zhai <orsonzhai@gmail.com>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	Chunyan Zhang <zhang.lyra@gmail.com>,
	Patrice Chotard <patrice.chotard@foss.st.com>,
	Laxman Dewangan <ldewangan@nvidia.com>,
	Jon Hunter <jonathanh@nvidia.com>,
	Thierry Reding <thierry.reding@gmail.com>,
	Peter Ujfalusi <peter.ujfalusi@gmail.com>,
	Kunihiko Hayashi <hayashi.kunihiko@socionext.com>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Yu Kuai <yukuai3@huawei.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jordy Zomer <jordy@pwning.systems>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Tom Rix <trix@redhat.com>,
	linux-kernel@vger.kernel.org, asahi@lists.linux.dev,
	linux-arm-msm@vger.kernel.org, linux-tegra@vger.kernel.org,
	llvm@lists.linux.dev, linux-hardening@vger.kernel.org
Subject: Re: [PATCH 14/21] dmaengine: stm32-mdma: Annotate struct stm32_mdma_device with __counted_by
Date: Thu, 17 Aug 2023 19:26:02 -0600	[thread overview]
Message-ID: <1f6873bb-e6d3-fdff-5e20-72332469def2@embeddedor.com> (raw)
In-Reply-To: <20230817235859.49846-14-keescook@chromium.org>



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 stm32_mdma_device.
> Additionally, since the element count member must be set before accessing
> the annotated flexible array member, move its initialization earlier.
> 
> [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
> 
> Cc: Vinod Koul <vkoul@kernel.org>
> Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
> Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
> Cc: dmaengine@vger.kernel.org
> Cc: linux-stm32@st-md-mailman.stormreply.com
> Cc: linux-arm-kernel@lists.infradead.org
> Signed-off-by: Kees Cook <keescook@chromium.org>

Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Thanks
--
Gustavo

> ---
>   drivers/dma/stm32-mdma.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/dma/stm32-mdma.c b/drivers/dma/stm32-mdma.c
> index 926d6ecf1274..0c7d2295856e 100644
> --- a/drivers/dma/stm32-mdma.c
> +++ b/drivers/dma/stm32-mdma.c
> @@ -256,7 +256,7 @@ struct stm32_mdma_device {
>   	u32 nr_ahb_addr_masks;
>   	u32 chan_reserved;
>   	struct stm32_mdma_chan chan[STM32_MDMA_MAX_CHANNELS];
> -	u32 ahb_addr_masks[];
> +	u32 ahb_addr_masks[] __counted_by(nr_ahb_addr_masks);
>   };
>   
>   static struct stm32_mdma_device *stm32_mdma_get_dev(
> @@ -1611,13 +1611,13 @@ static int stm32_mdma_probe(struct platform_device *pdev)
>   			      GFP_KERNEL);
>   	if (!dmadev)
>   		return -ENOMEM;
> +	dmadev->nr_ahb_addr_masks = count;
>   
>   	dmadev->nr_channels = nr_channels;
>   	dmadev->nr_requests = nr_requests;
>   	device_property_read_u32_array(&pdev->dev, "st,ahb-addr-masks",
>   				       dmadev->ahb_addr_masks,
>   				       count);
> -	dmadev->nr_ahb_addr_masks = count;
>   
>   	dmadev->base = devm_platform_ioremap_resource(pdev, 0);
>   	if (IS_ERR(dmadev->base))

WARNING: multiple messages have this Message-ID (diff)
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Kees Cook <keescook@chromium.org>, Vinod Koul <vkoul@kernel.org>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Alexandre Torgue <alexandre.torgue@foss.st.com>,
	dmaengine@vger.kernel.org,
	linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org,
	Hector Martin <marcan@marcan.st>, Sven Peter <sven@svenpeter.dev>,
	Alyssa Rosenzweig <alyssa@rosenzweig.io>,
	Ludovic Desroches <ludovic.desroches@microchip.com>,
	Tudor Ambarus <tudor.ambarus@linaro.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Zhou Wang <wangzhou1@hisilicon.com>, Jie Hai <haijie1@huawei.com>,
	Andy Gross <agross@kernel.org>,
	Bjorn Andersson <andersson@kernel.org>,
	Konrad Dybcio <konrad.dybcio@linaro.org>,
	Green Wan <green.wan@sifive.com>,
	Orson Zhai <orsonzhai@gmail.com>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	Chunyan Zhang <zhang.lyra@gmail.com>,
	Patrice Chotard <patrice.chotard@foss.st.com>,
	Laxman Dewangan <ldewangan@nvidia.com>,
	Jon Hunter <jonathanh@nvidia.com>,
	Thierry Reding <thierry.reding@gmail.com>,
	Peter Ujfalusi <peter.ujfalusi@gmail.com>,
	Kunihiko Hayashi <hayashi.kunihiko@socionext.com>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Yu Kuai <yukuai3@huawei.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jordy Zomer <jordy@pwning.systems>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Tom Rix <trix@redhat.com>,
	linux-kernel@vger.kernel.org, asahi@lists.linux.dev,
	linux-arm-msm@vger.kernel.org, linux-tegra@vger.kernel.org,
	llvm@lists.linux.dev, linux-hardening@vger.kernel.org
Subject: Re: [PATCH 14/21] dmaengine: stm32-mdma: Annotate struct stm32_mdma_device with __counted_by
Date: Thu, 17 Aug 2023 19:26:02 -0600	[thread overview]
Message-ID: <1f6873bb-e6d3-fdff-5e20-72332469def2@embeddedor.com> (raw)
In-Reply-To: <20230817235859.49846-14-keescook@chromium.org>



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 stm32_mdma_device.
> Additionally, since the element count member must be set before accessing
> the annotated flexible array member, move its initialization earlier.
> 
> [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
> 
> Cc: Vinod Koul <vkoul@kernel.org>
> Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
> Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
> Cc: dmaengine@vger.kernel.org
> Cc: linux-stm32@st-md-mailman.stormreply.com
> Cc: linux-arm-kernel@lists.infradead.org
> Signed-off-by: Kees Cook <keescook@chromium.org>

Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Thanks
--
Gustavo

> ---
>   drivers/dma/stm32-mdma.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/dma/stm32-mdma.c b/drivers/dma/stm32-mdma.c
> index 926d6ecf1274..0c7d2295856e 100644
> --- a/drivers/dma/stm32-mdma.c
> +++ b/drivers/dma/stm32-mdma.c
> @@ -256,7 +256,7 @@ struct stm32_mdma_device {
>   	u32 nr_ahb_addr_masks;
>   	u32 chan_reserved;
>   	struct stm32_mdma_chan chan[STM32_MDMA_MAX_CHANNELS];
> -	u32 ahb_addr_masks[];
> +	u32 ahb_addr_masks[] __counted_by(nr_ahb_addr_masks);
>   };
>   
>   static struct stm32_mdma_device *stm32_mdma_get_dev(
> @@ -1611,13 +1611,13 @@ static int stm32_mdma_probe(struct platform_device *pdev)
>   			      GFP_KERNEL);
>   	if (!dmadev)
>   		return -ENOMEM;
> +	dmadev->nr_ahb_addr_masks = count;
>   
>   	dmadev->nr_channels = nr_channels;
>   	dmadev->nr_requests = nr_requests;
>   	device_property_read_u32_array(&pdev->dev, "st,ahb-addr-masks",
>   				       dmadev->ahb_addr_masks,
>   				       count);
> -	dmadev->nr_ahb_addr_masks = count;
>   
>   	dmadev->base = devm_platform_ioremap_resource(pdev, 0);
>   	if (IS_ERR(dmadev->base))

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2023-08-18  1:25 UTC|newest]

Thread overview: 100+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-17 23:58 [PATCH 00/21] dmaengine: Annotate with __counted_by Kees Cook
2023-08-17 23:58 ` Kees Cook
2023-08-17 23:58 ` [PATCH 01/21] dmaengine: apple-admac: Annotate struct admac_data " Kees Cook
2023-08-17 23:58   ` Kees Cook
2023-08-18  1:22   ` Gustavo A. R. Silva
2023-08-18  1:22     ` Gustavo A. R. Silva
2023-08-17 23:58 ` [PATCH 02/21] dmaengine: at_hdmac: Annotate struct at_desc " Kees Cook
2023-08-17 23:58   ` Kees Cook
2023-08-18  2:14   ` Gustavo A. R. Silva
2023-08-18  2:14     ` Gustavo A. R. Silva
2023-08-18  9:29   ` Tudor Ambarus
2023-08-18  9:29     ` Tudor Ambarus
2023-08-17 23:58 ` [PATCH 03/21] dmaengine: axi-dmac: Annotate struct axi_dmac_desc " Kees Cook
2023-08-17 23:58   ` Kees Cook
2023-08-18  2:14   ` Gustavo A. R. Silva
2023-08-18  2:14     ` Gustavo A. R. Silva
2023-08-17 23:58 ` [PATCH 04/21] dmaengine: fsl-edma: Annotate struct fsl_edma_desc " Kees Cook
2023-08-17 23:58   ` Kees Cook
2023-08-18  1:23   ` Gustavo A. R. Silva
2023-08-18  1:23     ` Gustavo A. R. Silva
2023-08-17 23:58 ` [PATCH 05/21] dmaengine: hisilicon: Annotate struct hisi_dma_dev " Kees Cook
2023-08-17 23:58   ` Kees Cook
2023-08-18  1:23   ` Gustavo A. R. Silva
2023-08-18  1:23     ` Gustavo A. R. Silva
2023-08-17 23:58 ` [PATCH 06/21] dmaengine: moxart-dma: Annotate struct moxart_desc " Kees Cook
2023-08-17 23:58   ` Kees Cook
2023-08-18  1:23   ` Gustavo A. R. Silva
2023-08-18  1:23     ` Gustavo A. R. Silva
2023-08-17 23:58 ` [PATCH 07/21] dmaengine: qcom: bam_dma: Annotate struct bam_async_desc " Kees Cook
2023-08-17 23:58   ` Kees Cook
2023-08-18  1:24   ` Gustavo A. R. Silva
2023-08-18  1:24     ` Gustavo A. R. Silva
2023-08-17 23:58 ` [PATCH 08/21] dmaengine: sa11x0: Annotate struct sa11x0_dma_desc " Kees Cook
2023-08-17 23:58   ` Kees Cook
2023-08-18  1:24   ` Gustavo A. R. Silva
2023-08-18  1:24     ` Gustavo A. R. Silva
2023-08-17 23:58 ` [PATCH 09/21] dmaengine: sf-pdma: Annotate struct sf_pdma " Kees Cook
2023-08-17 23:58   ` Kees Cook
2023-08-18  1:24   ` Gustavo A. R. Silva
2023-08-18  1:24     ` Gustavo A. R. Silva
2023-08-17 23:58 ` [PATCH 10/21] dmaengine: sprd: Annotate struct sprd_dma_dev " Kees Cook
2023-08-17 23:58   ` Kees Cook
2023-08-18  1:24   ` Gustavo A. R. Silva
2023-08-18  1:24     ` Gustavo A. R. Silva
2023-08-18  7:18   ` Chunyan Zhang
2023-08-18  7:18     ` Chunyan Zhang
2023-08-17 23:58 ` [PATCH 11/21] dmaengine: st_fdma: Annotate struct st_fdma_desc " Kees Cook
2023-08-17 23:58   ` Kees Cook
2023-08-18  1:24   ` Gustavo A. R. Silva
2023-08-18  1:24     ` Gustavo A. R. Silva
2023-08-17 23:58 ` [PATCH 12/21] dmaengine: stm32-dma: Annotate struct stm32_dma_desc " Kees Cook
2023-08-17 23:58   ` Kees Cook
2023-08-18  1:25   ` Gustavo A. R. Silva
2023-08-18  1:25     ` Gustavo A. R. Silva
2023-08-17 23:58 ` [PATCH 13/21] dmaengine: stm32-mdma: Annotate struct stm32_mdma_desc " Kees Cook
2023-08-17 23:58   ` Kees Cook
2023-08-18  1:25   ` Gustavo A. R. Silva
2023-08-18  1:25     ` Gustavo A. R. Silva
2023-08-17 23:58 ` [PATCH 14/21] dmaengine: stm32-mdma: Annotate struct stm32_mdma_device " Kees Cook
2023-08-17 23:58   ` Kees Cook
2023-08-18  1:26   ` Gustavo A. R. Silva [this message]
2023-08-18  1:26     ` Gustavo A. R. Silva
2023-08-17 23:58 ` [PATCH 15/21] dmaengine: tegra: Annotate struct tegra_dma_desc " Kees Cook
2023-08-17 23:58   ` Kees Cook
2023-08-18  2:15   ` Gustavo A. R. Silva
2023-08-18  2:15     ` Gustavo A. R. Silva
2023-08-17 23:58 ` [PATCH 16/21] dmaengine: tegra210-adma: Annotate struct tegra_adma " Kees Cook
2023-08-17 23:58   ` Kees Cook
2023-08-18  2:15   ` Gustavo A. R. Silva
2023-08-18  2:15     ` Gustavo A. R. Silva
2023-08-17 23:58 ` [PATCH 17/21] dmaengine: ti: edma: Annotate struct edma_desc " Kees Cook
2023-08-17 23:58   ` Kees Cook
2023-08-18  2:15   ` Gustavo A. R. Silva
2023-08-18  2:15     ` Gustavo A. R. Silva
2023-08-17 23:58 ` [PATCH 18/21] dmaengine: ti: omap-dma: Annotate struct omap_desc " Kees Cook
2023-08-17 23:58   ` Kees Cook
2023-08-18  2:15   ` Gustavo A. R. Silva
2023-08-18  2:15     ` Gustavo A. R. Silva
2023-08-17 23:58 ` [PATCH 19/21] dmaengine: uniphier-xdmac: Annotate struct uniphier_xdmac_desc " Kees Cook
2023-08-17 23:58   ` Kees Cook
2023-08-18  2:15   ` Gustavo A. R. Silva
2023-08-18  2:15     ` Gustavo A. R. Silva
2023-08-17 23:58 ` [PATCH 20/21] dmaengine: uniphier-xdmac: Annotate struct uniphier_xdmac_device " Kees Cook
2023-08-17 23:58   ` Kees Cook
2023-08-18  2:16   ` Gustavo A. R. Silva
2023-08-18  2:16     ` Gustavo A. R. Silva
2023-08-17 23:58 ` [PATCH 21/21] dmaengine: usb-dmac: Annotate struct usb_dmac_desc " Kees Cook
2023-08-17 23:58   ` Kees Cook
2023-08-18  2:17   ` Gustavo A. R. Silva
2023-08-18  2:17     ` Gustavo A. R. Silva
2023-09-15 20:08 ` [PATCH 00/21] dmaengine: Annotate " Kees Cook
2023-09-15 20:08   ` Kees Cook
2023-09-22 17:16   ` Kees Cook
2023-09-22 17:16     ` Kees Cook
2023-09-28 11:11     ` Vinod Koul
2023-09-28 11:11       ` Vinod Koul
2023-09-28 11:56 ` Vinod Koul
2023-09-28 11:56   ` Vinod Koul
2023-09-28 23:42   ` Kees Cook
2023-09-28 23:42     ` Kees Cook

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1f6873bb-e6d3-fdff-5e20-72332469def2@embeddedor.com \
    --to=gustavo@embeddedor.com \
    --cc=agross@kernel.org \
    --cc=alexandre.torgue@foss.st.com \
    --cc=alyssa@rosenzweig.io \
    --cc=andersson@kernel.org \
    --cc=asahi@lists.linux.dev \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=green.wan@sifive.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=haijie1@huawei.com \
    --cc=hayashi.kunihiko@socionext.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=jonathanh@nvidia.com \
    --cc=jordy@pwning.systems \
    --cc=keescook@chromium.org \
    --cc=konrad.dybcio@linaro.org \
    --cc=lars@metafoo.de \
    --cc=ldewangan@nvidia.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=linux-tegra@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=ludovic.desroches@microchip.com \
    --cc=marcan@marcan.st \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=mhiramat@kernel.org \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=orsonzhai@gmail.com \
    --cc=patrice.chotard@foss.st.com \
    --cc=peter.ujfalusi@gmail.com \
    --cc=sven@svenpeter.dev \
    --cc=thierry.reding@gmail.com \
    --cc=trix@redhat.com \
    --cc=tudor.ambarus@linaro.org \
    --cc=vkoul@kernel.org \
    --cc=wangzhou1@hisilicon.com \
    --cc=yukuai3@huawei.com \
    --cc=zhang.lyra@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.