dmaengine: Annotate with __counted_by
Subsystems (15)
cover dmaengine: Annotate with __counted_by
Hi,
This annotates several structures with the coming __counted_by attribute for bounds checking of flexible arrays at run-time. For more details, see commit dd06e72e68bc ("Compiler Attributes: Add __counted_by macro").
Thanks!
-Kees
Kees Cook (21):
dmaengine: apple-admac: Annotate struct admac_data with __counted_by
dmaengine: at_hdmac: Annotate struct at_desc with __counted_by
dmaengine: axi-dmac: Annotate struct axi_dmac_desc with __counted_by
dmaengine: fsl-edma: Annotate struct fsl_edma_desc with __counted_by
dmaengine: hisilicon: Annotate struct hisi_dma_dev with __counted_by
dmaengine: moxart-dma: Annotate struct moxart_desc with __counted_by
dmaengine: qcom: bam_dma: Annotate struct bam_async_desc with
__counted_by
dmaengine: sa11x0: Annotate struct sa11x0_dma_desc with __counted_by
dmaengine: sf-pdma: Annotate struct sf_pdma with __counted_by
dmaengine: sprd: Annotate struct sprd_dma_dev with __counted_by
dmaengine: st_fdma: Annotate struct st_fdma_desc with __counted_by
dmaengine: stm32-dma: Annotate struct stm32_dma_desc with __counted_by
dmaengine: stm32-mdma: Annotate struct stm32_mdma_desc with
__counted_by
dmaengine: stm32-mdma: Annotate struct stm32_mdma_device with
__counted_by
dmaengine: tegra: Annotate struct tegra_dma_desc with __counted_by
dmaengine: tegra210-adma: Annotate struct tegra_adma with __counted_by
dmaengine: ti: edma: Annotate struct edma_desc with __counted_by
dmaengine: ti: omap-dma: Annotate struct omap_desc with __counted_by
dmaengine: uniphier-xdmac: Annotate struct uniphier_xdmac_desc with
__counted_by
dmaengine: uniphier-xdmac: Annotate struct uniphier_xdmac_device with
__counted_by
dmaengine: usb-dmac: Annotate struct usb_dmac_desc with __counted_by
drivers/dma/apple-admac.c | 2 +- drivers/dma/at_hdmac.c | 2 +- drivers/dma/dma-axi-dmac.c | 5 ++--- drivers/dma/fsl-edma-common.h | 2 +- drivers/dma/hisi_dma.c | 2 +- drivers/dma/moxart-dma.c | 5 ++--- drivers/dma/qcom/bam_dma.c | 2 +- drivers/dma/sa11x0-dma.c | 6 +++--- drivers/dma/sf-pdma/sf-pdma.h | 2 +- drivers/dma/sh/usb-dmac.c | 2 +- drivers/dma/sprd-dma.c | 2 +- drivers/dma/st_fdma.h | 2 +- drivers/dma/stm32-dma.c | 11 ++++------- drivers/dma/stm32-mdma.c | 9 ++++----- drivers/dma/tegra186-gpc-dma.c | 2 +- drivers/dma/tegra210-adma.c | 2 +- drivers/dma/ti/edma.c | 2 +- drivers/dma/ti/omap-dma.c | 5 ++--- drivers/dma/uniphier-xdmac.c | 8 ++++---- 19 files changed, 33 insertions(+), 40 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/21 dmaengine: apple-admac: Annotate struct admac_data with __counted_by
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 admac_data.
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
--- drivers/dma/apple-admac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/apple-admac.c +1 -1
@@ -128,7 +128,7 @@ struct admac_data {int irq;int irq_index;int nchannels; -struct admac_chan channels[]; + struct admac_chan channels[] __counted_by(nchannels); };struct admac_tx {
Signature · 1 line
2.34.1
Re: [PATCH 01/21] dmaengine: apple-admac: Annotate struct admac_data with __counted_by
Quoted 10 lines · Kees Cook
Prepare for the coming implementation by GCC and Clang of the
__counted_byattribute. Flexible array members annotated with__counted_bycan have their accesses bounds-checked at run-time checking viaCONFIG_UBSAN_BOUNDS(for array indexing) andCONFIG_FORTIFY_SOURCE(for strcpy/memcpy-family functions).As found with Coccinelle[1], add
__counted_byfor structadmac_data.[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
Quoted 8 lines
Cc Vinod Koul <[email protected]>Cc Hector Martin <[email protected]>Cc Sven Peter <[email protected]>Cc Alyssa Rosenzweig <[email protected]>Signed-off-by Kees Cook <[email protected]>
Thanks
--
Gustavo
Quoted 17 lines
--- drivers/dma/apple-admac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/dma/apple-admac.c +1
-1@@ -128,7 +128,7 @@ struct admac_data {int irq;int irq_index;int nchannels; -struct admac_chan channels[]; + struct admac_chan channels[] __counted_by(nchannels); };struct admac_tx {
PATCH 2/21 dmaengine: at_hdmac: Annotate struct at_desc with __counted_by
In reply to Kees CookPrepare 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 at_desc.
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
--- drivers/dma/at_hdmac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/at_hdmac.c +1 -1
@@ -239,7 +239,7 @@ struct at_desc {bool memset_buffer;dma_addr_t memset_paddr;int *memset_vaddr; -struct atdma_sg sg[]; + struct atdma_sg sg[] __counted_by(sglen); };/*-- Channels --------------------------------------------------------*/
Signature · 1 line
2.34.1
Re: [PATCH 02/21] dmaengine: at_hdmac: Annotate struct at_desc with __counted_by
Quoted 8 lines · Kees Cook
Prepare for the coming implementation by GCC and Clang of the
__counted_byattribute. Flexible array members annotated with__counted_bycan have their accesses bounds-checked at run-time checking viaCONFIG_UBSAN_BOUNDS(for array indexing) andCONFIG_FORTIFY_SOURCE(for strcpy/memcpy-family functions).As found with Coccinelle[1], add
__counted_byfor structat_desc.
Quoted 8 lines
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
Cc Vinod Koul <[email protected]>Cc Ludovic Desroches <[email protected]>Cc Tudor Ambarus <[email protected]>Signed-off-by Kees Cook <[email protected]>
Thanks
--
Gustavo
Quoted 17 lines
--- drivers/dma/at_hdmac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/dma/at_hdmac.c +1
-1@@ -239,7 +239,7 @@ struct at_desc {bool memset_buffer;dma_addr_t memset_paddr;int *memset_vaddr; -struct atdma_sg sg[]; + struct atdma_sg sg[] __counted_by(sglen); };/*-- Channels --------------------------------------------------------*/
Re: [PATCH 02/21] dmaengine: at_hdmac: Annotate struct at_desc with __counted_by
In reply to Kees CookQuoted 8 lines · Kees Cook
Prepare for the coming implementation by GCC and Clang of the
__counted_byattribute. Flexible array members annotated with__counted_bycan have their accesses bounds-checked at run-time checking viaCONFIG_UBSAN_BOUNDS(for array indexing) andCONFIG_FORTIFY_SOURCE(for strcpy/memcpy-family functions).As found with Coccinelle[1], add
__counted_byfor structat_desc.
Quoted 8 lines
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
Cc Vinod Koul <[email protected]>Cc Ludovic Desroches <[email protected]>Cc Tudor Ambarus <[email protected]>Signed-off-by Kees Cook <[email protected]>
Quoted 17 lines
--- drivers/dma/at_hdmac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/dma/at_hdmac.c +1
-1@@ -239,7 +239,7 @@ struct at_desc {bool memset_buffer;dma_addr_t memset_paddr;int *memset_vaddr; -struct atdma_sg sg[]; + struct atdma_sg sg[] __counted_by(sglen); };/*-- Channels --------------------------------------------------------*/
PATCH 3/21 dmaengine: axi-dmac: Annotate struct axi_dmac_desc with __counted_by
In reply to Kees CookPrepare 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 axi_dmac_desc. 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
--- drivers/dma/dma-axi-dmac.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/dma/dma-axi-dmac.c +2 -3
@@ -117,7 +117,7 @@ struct axi_dmac_desc {unsigned int num_submitted;unsigned int num_completed;unsigned int num_sgs; -struct axi_dmac_sg sg[]; + struct axi_dmac_sg sg[] __counted_by(num_sgs); };struct axi_dmac_chan {
@@ -484,12 +484,11 @@ static struct axi_dmac_desc *axi_dmac_alloc_desc(unsigned int num_sgs) desc =kzalloc (struct_size (desc, sg, num_sgs),GFP_NOWAIT );if (!desc)return NULL ; + desc->num_sgs = num_sgs;for (i =0 ; i < num_sgs; i++) desc->sg[i].id =AXI_DMAC_SG_UNUSED ; - desc->num_sgs = num_sgs; -return desc; }
Signature · 1 line
2.34.1
Re: [PATCH 03/21] dmaengine: axi-dmac: Annotate struct axi_dmac_desc with __counted_by
Quoted 10 lines · Kees Cook
Prepare for the coming implementation by GCC and Clang of the
__counted_byattribute. Flexible array members annotated with__counted_bycan have their accesses bounds-checked at run-time checking viaCONFIG_UBSAN_BOUNDS(for array indexing) andCONFIG_FORTIFY_SOURCE(for strcpy/memcpy-family functions).As found with Coccinelle[1], add
__counted_byfor structaxi_dmac_desc. Additionally, since the element count member must be set before accessing the annotated flexible array member, move its initialization earlier.
Quoted 6 lines
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
Cc Vinod Koul <[email protected]>Cc Lars-Peter Clausen <[email protected]>Signed-off-by Kees Cook <[email protected]>
Thanks
--
Gustavo
Quoted 31 lines
--- drivers/dma/dma-axi-dmac.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/dma/dma-axi-dmac.c +2
-3@@ -117,7 +117,7 @@ struct axi_dmac_desc {unsigned int num_submitted;unsigned int num_completed;unsigned int num_sgs; -struct axi_dmac_sg sg[]; + struct axi_dmac_sg sg[] __counted_by(num_sgs); };struct axi_dmac_chan {@@ -484,12 +484,11 @@ static struct axi_dmac_desc *axi_dmac_alloc_desc(unsigned int num_sgs) desc =kzalloc (struct_size (desc, sg, num_sgs),GFP_NOWAIT );if (!desc)return NULL ; + desc->num_sgs = num_sgs;for (i =0 ; i < num_sgs; i++) desc->sg[i].id =AXI_DMAC_SG_UNUSED ; - desc->num_sgs = num_sgs; -return desc; }
PATCH 4/21 dmaengine: fsl-edma: Annotate struct fsl_edma_desc with __counted_by
In reply to Kees CookPrepare 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 fsl_edma_desc.
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
--- drivers/dma/fsl-edma-common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/fsl-edma-common.h +1 -1
@@ -135,7 +135,7 @@ struct fsl_edma_desc {bool iscyclic;enum dma_transfer_direction dirn;unsigned int n_tcds; -struct fsl_edma_sw_tcd tcd[]; + struct fsl_edma_sw_tcd tcd[] __counted_by(n_tcds); };enum edma_version {
Signature · 1 line
2.34.1
Re: [PATCH 04/21] dmaengine: fsl-edma: Annotate struct fsl_edma_desc with __counted_by
Quoted 6 lines · Kees Cook
Prepare for the coming implementation by GCC and Clang of the
__counted_byattribute. Flexible array members annotated with__counted_bycan have their accesses bounds-checked at run-time checking viaCONFIG_UBSAN_BOUNDS(for array indexing) andCONFIG_FORTIFY_SOURCE(for strcpy/memcpy-family functions).
Quoted 7 lines
As found with Coccinelle[1], add
__counted_byfor structfsl_edma_desc.[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
Thanks
--
Gustavo
Quoted 17 lines
--- drivers/dma/fsl-edma-common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/dma/fsl-edma-common.h +1
-1@@ -135,7 +135,7 @@ struct fsl_edma_desc {bool iscyclic;enum dma_transfer_direction dirn;unsigned int n_tcds; -struct fsl_edma_sw_tcd tcd[]; + struct fsl_edma_sw_tcd tcd[] __counted_by(n_tcds); };enum edma_version {
PATCH 5/21 dmaengine: hisilicon: Annotate struct hisi_dma_dev with __counted_by
In reply to Kees CookPrepare 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 hisi_dma_dev.
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
--- drivers/dma/hisi_dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/hisi_dma.c +1 -1
@@ -163,7 +163,7 @@ struct hisi_dma_dev {u32 chan_depth;enum hisi_dma_reg_layout reg_layout;void __iomem *queue_base;/* queue region start of register */ -struct hisi_dma_chan chan[]; + struct hisi_dma_chan chan[] __counted_by(chan_num); };#ifdef CONFIG_DEBUG_FS
Signature · 1 line
2.34.1
Re: [PATCH 05/21] dmaengine: hisilicon: Annotate struct hisi_dma_dev with __counted_by
Quoted 8 lines · Kees Cook
Prepare for the coming implementation by GCC and Clang of the
__counted_byattribute. Flexible array members annotated with__counted_bycan have their accesses bounds-checked at run-time checking viaCONFIG_UBSAN_BOUNDS(for array indexing) andCONFIG_FORTIFY_SOURCE(for strcpy/memcpy-family functions).As found with Coccinelle[1], add
__counted_byfor structhisi_dma_dev.
Quoted 7 lines
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
Cc Vinod Koul <[email protected]>Cc Zhou Wang <[email protected]>Cc Jie Hai <[email protected]>Signed-off-by Kees Cook <[email protected]>
Thanks
--
Gustavo
Quoted 17 lines
--- drivers/dma/hisi_dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/dma/hisi_dma.c +1
-1@@ -163,7 +163,7 @@ struct hisi_dma_dev {u32 chan_depth;enum hisi_dma_reg_layout reg_layout;void __iomem *queue_base;/* queue region start of register */ -struct hisi_dma_chan chan[]; + struct hisi_dma_chan chan[] __counted_by(chan_num); };#ifdef CONFIG_DEBUG_FS
PATCH 6/21 dmaengine: moxart-dma: Annotate struct moxart_desc with __counted_by
In reply to Kees CookPrepare 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 moxart_desc. 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
--- drivers/dma/moxart-dma.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/dma/moxart-dma.c +2 -3
@@ -124,7 +124,7 @@ struct moxart_desc {unsigned int dma_cycles;struct virt_dma_desc vd;uint8_t es; -struct moxart_sg sg[]; + struct moxart_sg sg[] __counted_by(sglen); };struct moxart_chan {
@@ -309,6 +309,7 @@ static struct dma_async_tx_descriptor *moxart_prep_slave_sg( d =kzalloc (struct_size (d, sg, sg_len),GFP_ATOMIC );if (!d)return NULL ; + d->sglen = sg_len; d->dma_dir = dir; d->dev_addr = dev_addr;
@@ -319,8 +320,6 @@ static struct dma_async_tx_descriptor *moxart_prep_slave_sg( d->sg[i].len =sg_dma_len (sgent); } - d->sglen = sg_len; - ch->error =0 ;return vchan_tx_prep (&ch->vc, &d->vd, tx_flags);
Signature · 1 line
2.34.1
Re: [PATCH 06/21] dmaengine: moxart-dma: Annotate struct moxart_desc with __counted_by
Quoted 10 lines · Kees Cook
Prepare for the coming implementation by GCC and Clang of the
__counted_byattribute. Flexible array members annotated with__counted_bycan have their accesses bounds-checked at run-time checking viaCONFIG_UBSAN_BOUNDS(for array indexing) andCONFIG_FORTIFY_SOURCE(for strcpy/memcpy-family functions).As found with Coccinelle[1], add
__counted_byfor structmoxart_desc. Additionally, since the element count member must be set before accessing the annotated flexible array member, move its initialization earlier.
Quoted 5 lines
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
Thanks
--
Gustavo
Quoted 34 lines
--- drivers/dma/moxart-dma.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/dma/moxart-dma.c +2
-3@@ -124,7 +124,7 @@ struct moxart_desc {unsigned int dma_cycles;struct virt_dma_desc vd;uint8_t es; -struct moxart_sg sg[]; + struct moxart_sg sg[] __counted_by(sglen); };struct moxart_chan {@@ -309,6 +309,7 @@ static struct dma_async_tx_descriptor *moxart_prep_slave_sg( d =kzalloc (struct_size (d, sg, sg_len),GFP_ATOMIC );if (!d)return NULL ; + d->sglen = sg_len; d->dma_dir = dir; d->dev_addr = dev_addr;@@ -319,8 +320,6 @@ static struct dma_async_tx_descriptor *moxart_prep_slave_sg( d->sg[i].len =sg_dma_len (sgent); } - d->sglen = sg_len; - ch->error =0 ;return vchan_tx_prep (&ch->vc, &d->vd, tx_flags);
PATCH 7/21 dmaengine: qcom: bam_dma: Annotate struct bam_async_desc with __counted_by
In reply to Kees CookPrepare 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 bam_async_desc.
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
--- drivers/dma/qcom/bam_dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/qcom/bam_dma.c +1 -1
@@ -74,7 +74,7 @@ struct bam_async_desc {struct list_head desc_node;enum dma_transfer_direction dir;size_t length; -struct bam_desc_hw desc[]; + struct bam_desc_hw desc[] __counted_by(num_desc); };enum bam_reg {
Signature · 1 line
2.34.1
Re: [PATCH 07/21] dmaengine: qcom: bam_dma: Annotate struct bam_async_desc with __counted_by
Quoted 10 lines · Kees Cook
Prepare for the coming implementation by GCC and Clang of the
__counted_byattribute. Flexible array members annotated with__counted_bycan have their accesses bounds-checked at run-time checking viaCONFIG_UBSAN_BOUNDS(for array indexing) andCONFIG_FORTIFY_SOURCE(for strcpy/memcpy-family functions).As found with Coccinelle[1], add
__counted_byfor structbam_async_desc.[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
Quoted 7 lines
Cc Vinod Koul <[email protected]>Cc Andy Gross <[email protected]>Cc Bjorn Andersson <[email protected]>Cc Konrad Dybcio <[email protected]>Signed-off-by Kees Cook <[email protected]>
Thanks
--
Gustavo
Quoted 17 lines
--- drivers/dma/qcom/bam_dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/dma/qcom/bam_dma.c +1
-1@@ -74,7 +74,7 @@ struct bam_async_desc {struct list_head desc_node;enum dma_transfer_direction dir;size_t length; -struct bam_desc_hw desc[]; + struct bam_desc_hw desc[] __counted_by(num_desc); };enum bam_reg {
PATCH 8/21 dmaengine: sa11x0: Annotate struct sa11x0_dma_desc with __counted_by
In reply to Kees CookPrepare 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 sa11x0_dma_desc. 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
--- drivers/dma/sa11x0-dma.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/dma/sa11x0-dma.c +3 -3
@@ -78,7 +78,7 @@ struct sa11x0_dma_desc {bool cyclic;unsigned sglen; -struct sa11x0_dma_sg sg[]; + struct sa11x0_dma_sg sg[] __counted_by(sglen); };struct sa11x0_dma_phy ;
@@ -558,6 +558,7 @@ static struct dma_async_tx_descriptor *sa11x0_dma_prep_slave_sg(dev_dbg (chan->device->dev,"vchan %p: kzalloc failed\n" , &c->vc);return NULL ; } + txd->sglen = j; j =0 ;for_each_sg (sg, sgent, sglen, i) {
@@ -593,7 +594,6 @@ static struct dma_async_tx_descriptor *sa11x0_dma_prep_slave_sg( txd->ddar = c->ddar; txd->size = size; - txd->sglen = j;dev_dbg (chan->device->dev,"vchan %p: txd %p: size %zu nr %u\n" , &c->vc, &txd->vd, txd->size, txd->sglen);
@@ -628,6 +628,7 @@ static struct dma_async_tx_descriptor *sa11x0_dma_prep_dma_cyclic(dev_dbg (chan->device->dev,"vchan %p: kzalloc failed\n" , &c->vc);return NULL ; } + txd->sglen = sglen;for (i = k =0 ; i < size / period; i++) {size_t tlen, len = period;
@@ -653,7 +654,6 @@ static struct dma_async_tx_descriptor *sa11x0_dma_prep_dma_cyclic( txd->ddar = c->ddar; txd->size = size; - txd->sglen = sglen; txd->cyclic =1 ; txd->period = sgperiod;
Signature · 1 line
2.34.1
Re: [PATCH 08/21] dmaengine: sa11x0: Annotate struct sa11x0_dma_desc with __counted_by
Quoted 10 lines · Kees Cook
Prepare for the coming implementation by GCC and Clang of the
__counted_byattribute. Flexible array members annotated with__counted_bycan have their accesses bounds-checked at run-time checking viaCONFIG_UBSAN_BOUNDS(for array indexing) andCONFIG_FORTIFY_SOURCE(for strcpy/memcpy-family functions).As found with Coccinelle[1], add
__counted_byfor structsa11x0_dma_desc. Additionally, since the element count member must be set before accessing the annotated flexible array member, move its initialization earlier.
Quoted 5 lines
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
Thanks
--
Gustavo
Quoted 49 lines
--- drivers/dma/sa11x0-dma.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/dma/sa11x0-dma.c +3
-3@@ -78,7 +78,7 @@ struct sa11x0_dma_desc {bool cyclic;unsigned sglen; -struct sa11x0_dma_sg sg[]; + struct sa11x0_dma_sg sg[] __counted_by(sglen); };struct sa11x0_dma_phy ;@@ -558,6 +558,7 @@ static struct dma_async_tx_descriptor *sa11x0_dma_prep_slave_sg(dev_dbg (chan->device->dev,"vchan %p: kzalloc failed\n" , &c->vc);return NULL ; } + txd->sglen = j; j =0 ;for_each_sg (sg, sgent, sglen, i) {@@ -593,7 +594,6 @@ static struct dma_async_tx_descriptor *sa11x0_dma_prep_slave_sg( txd->ddar = c->ddar; txd->size = size; - txd->sglen = j;dev_dbg (chan->device->dev,"vchan %p: txd %p: size %zu nr %u\n" , &c->vc, &txd->vd, txd->size, txd->sglen);@@ -628,6 +628,7 @@ static struct dma_async_tx_descriptor *sa11x0_dma_prep_dma_cyclic(dev_dbg (chan->device->dev,"vchan %p: kzalloc failed\n" , &c->vc);return NULL ; } + txd->sglen = sglen;for (i = k =0 ; i < size / period; i++) {size_t tlen, len = period;@@ -653,7 +654,6 @@ static struct dma_async_tx_descriptor *sa11x0_dma_prep_dma_cyclic( txd->ddar = c->ddar; txd->size = size; - txd->sglen = sglen; txd->cyclic =1 ; txd->period = sgperiod;
PATCH 9/21 dmaengine: sf-pdma: Annotate struct sf_pdma with __counted_by
In reply to Kees CookPrepare 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 sf_pdma.
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
--- drivers/dma/sf-pdma/sf-pdma.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/sf-pdma/sf-pdma.h +1 -1
@@ -113,7 +113,7 @@ struct sf_pdma {void __iomem *membase;void __iomem *mappedbase;u32 n_chans; - struct sf_pdma_chan chans[]; + struct sf_pdma_chan chans[] __counted_by(n_chans); };#endif /* _SF_PDMA_H */
Signature · 1 line
2.34.1
Re: [PATCH 09/21] dmaengine: sf-pdma: Annotate struct sf_pdma with __counted_by
Quoted 6 lines · Kees Cook
Prepare for the coming implementation by GCC and Clang of the
__counted_byattribute. Flexible array members annotated with__counted_bycan have their accesses bounds-checked at run-time checking viaCONFIG_UBSAN_BOUNDS(for array indexing) andCONFIG_FORTIFY_SOURCE(for strcpy/memcpy-family functions).
Quoted 8 lines
As found with Coccinelle[1], add
__counted_byfor structsf_pdma.[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
Cc Vinod Koul <[email protected]>Cc Green Wan <[email protected]>Signed-off-by Kees Cook <[email protected]>
Thanks
--
Gustavo
Quoted 17 lines
--- drivers/dma/sf-pdma/sf-pdma.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/dma/sf-pdma/sf-pdma.h +1
-1@@ -113,7 +113,7 @@ struct sf_pdma {void __iomem *membase;void __iomem *mappedbase;u32 n_chans; - struct sf_pdma_chan chans[]; + struct sf_pdma_chan chans[] __counted_by(n_chans); };#endif /* _SF_PDMA_H */
PATCH 10/21 dmaengine: sprd: Annotate struct sprd_dma_dev with __counted_by
In reply to Kees CookPrepare 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 sprd_dma_dev.
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
--- drivers/dma/sprd-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/sprd-dma.c +1 -1
@@ -212,7 +212,7 @@ struct sprd_dma_dev {struct clk *ashb_clk;int irq;u32 total_chns; -struct sprd_dma_chn channels[]; + struct sprd_dma_chn channels[] __counted_by(total_chns); };static void sprd_dma_free_desc (struct virt_dma_desc *vd);
Signature · 1 line
2.34.1
Re: [PATCH 10/21] dmaengine: sprd: Annotate struct sprd_dma_dev with __counted_by
Quoted 8 lines · Kees Cook
Prepare for the coming implementation by GCC and Clang of the
__counted_byattribute. Flexible array members annotated with__counted_bycan have their accesses bounds-checked at run-time checking viaCONFIG_UBSAN_BOUNDS(for array indexing) andCONFIG_FORTIFY_SOURCE(for strcpy/memcpy-family functions).As found with Coccinelle[1], add
__counted_byfor structsprd_dma_dev.
Quoted 8 lines
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
Cc Vinod Koul <[email protected]>Cc Orson Zhai <[email protected]>Cc Baolin Wang <[email protected]>Cc Chunyan Zhang <[email protected]>Signed-off-by Kees Cook <[email protected]>
Thanks
--
Gustavo
Quoted 17 lines
--- drivers/dma/sprd-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/dma/sprd-dma.c +1
-1@@ -212,7 +212,7 @@ struct sprd_dma_dev {struct clk *ashb_clk;int irq;u32 total_chns; -struct sprd_dma_chn channels[]; + struct sprd_dma_chn channels[] __counted_by(total_chns); };static void sprd_dma_free_desc (struct virt_dma_desc *vd);
Re: [PATCH 10/21] dmaengine: sprd: Annotate struct sprd_dma_dev with __counted_by
In reply to Kees CookQuoted 9 lines · Kees Cook
Prepare for the coming implementation by GCC and Clang of the
__counted_byattribute. Flexible array members annotated with__counted_bycan have their accesses bounds-checked at run-time checking viaCONFIG_UBSAN_BOUNDS(for array indexing) andCONFIG_FORTIFY_SOURCE(for strcpy/memcpy-family functions).As found with Coccinelle[1], add
__counted_byfor structsprd_dma_dev.
Quoted 8 lines
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
Cc Vinod Koul <[email protected]>Cc Orson Zhai <[email protected]>Cc Baolin Wang <[email protected]>Cc Chunyan Zhang <[email protected]>Signed-off-by Kees Cook <[email protected]>
Thanks,
Chunyan
Quoted 20 lines
--- drivers/dma/sprd-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/dma/sprd-dma.c +1
-2@@ -212,7 +212,7 @@ struct sprd_dma_dev {struct clk *ashb_clk;int irq;u32 total_chns; -struct sprd_dma_chn channels[]; + struct sprd_dma_chn channels[] __counted_by(total_chns); };static void sprd_dma_free_desc (struct virt_dma_desc *vd); --2.34.1
PATCH 11/21 dmaengine: st_fdma: Annotate struct st_fdma_desc with __counted_by
In reply to Kees CookPrepare 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
--- drivers/dma/st_fdma.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/st_fdma.h +1 -1
@@ -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 {
Signature · 1 line
2.34.1
Re: [PATCH 11/21] dmaengine: st_fdma: Annotate struct st_fdma_desc with __counted_by
Quoted 8 lines · Kees Cook
Prepare for the coming implementation by GCC and Clang of the
__counted_byattribute. Flexible array members annotated with__counted_bycan have their accesses bounds-checked at run-time checking viaCONFIG_UBSAN_BOUNDS(for array indexing) andCONFIG_FORTIFY_SOURCE(for strcpy/memcpy-family functions).As found with Coccinelle[1], add
__counted_byfor structst_fdma_desc.
Quoted 7 lines
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
Cc Vinod Koul <[email protected]>Cc Patrice Chotard <[email protected]>Signed-off-by Kees Cook <[email protected]>
Thanks
--
Gustavo
Quoted 9 lines
--- drivers/dma/st_fdma.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/dma/st_fdma.h +0
-0
drivers/dma/st_fdma.h struct st_fdma_desc { · line 103
Quoted 8 lines
drivers/dma/st_fdma.h +1
-1@@ -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 {
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 12/21 dmaengine: stm32-dma: Annotate struct stm32_dma_desc with __counted_by
In reply to Kees CookPrepare 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_dma_desc. 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
--- drivers/dma/stm32-dma.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/dma/stm32-dma.c +4 -7
@@ -191,7 +191,7 @@ struct stm32_dma_desc {struct virt_dma_desc vdesc;bool cyclic;u32 num_sgs; -struct stm32_dma_sg_req sg_req[]; + struct stm32_dma_sg_req sg_req[] __counted_by(num_sgs); };/**
@@ -1105,6 +1105,7 @@ static struct dma_async_tx_descriptor *stm32_dma_prep_slave_sg( desc =kzalloc (struct_size (desc, sg_req, sg_len),GFP_NOWAIT );if (!desc)return NULL ; + desc->num_sgs = sg_len;/* Set peripheral flow controller */ if (chan->dma_sconfig.device_fc)
@@ -1141,8 +1142,6 @@ static struct dma_async_tx_descriptor *stm32_dma_prep_slave_sg( desc->sg_req[i].chan_reg.dma_sm1ar +=sg_dma_len (sg); desc->sg_req[i].chan_reg.dma_sndtr = nb_data_items; } - - desc->num_sgs = sg_len; desc->cyclic = false;return vchan_tx_prep (&chan->vchan, &desc->vdesc, flags);
@@ -1216,6 +1215,7 @@ static struct dma_async_tx_descriptor *stm32_dma_prep_dma_cyclic( desc =kzalloc (struct_size (desc, sg_req, num_periods),GFP_NOWAIT );if (!desc)return NULL ; + desc->num_sgs = num_periods;for (i =0 ; i < num_periods; i++) { desc->sg_req[i].len = period_len;
@@ -1232,8 +1232,6 @@ static struct dma_async_tx_descriptor *stm32_dma_prep_dma_cyclic(if (!chan->trig_mdma) buf_addr += period_len; } - - desc->num_sgs = num_periods; desc->cyclic = true;return vchan_tx_prep (&chan->vchan, &desc->vdesc, flags);
@@ -1254,6 +1252,7 @@ static struct dma_async_tx_descriptor *stm32_dma_prep_dma_memcpy( desc =kzalloc (struct_size (desc, sg_req, num_sgs),GFP_NOWAIT );if (!desc)return NULL ; + desc->num_sgs = num_sgs; threshold = chan->threshold;
@@ -1283,8 +1282,6 @@ static struct dma_async_tx_descriptor *stm32_dma_prep_dma_memcpy( desc->sg_req[i].chan_reg.dma_sndtr = xfer_count; desc->sg_req[i].len = xfer_count; } - - desc->num_sgs = num_sgs; desc->cyclic = false;return vchan_tx_prep (&chan->vchan, &desc->vdesc, flags);
Signature · 1 line
2.34.1
Re: [PATCH 12/21] dmaengine: stm32-dma: Annotate struct stm32_dma_desc with __counted_by
Quoted 12 lines · Kees Cook
Prepare for the coming implementation by GCC and Clang of the
__counted_byattribute. Flexible array members annotated with__counted_bycan have their accesses bounds-checked at run-time checking viaCONFIG_UBSAN_BOUNDS(for array indexing) andCONFIG_FORTIFY_SOURCE(for strcpy/memcpy-family functions).As found with Coccinelle[1], add
__counted_byfor structstm32_dma_desc. 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
Quoted 7 lines
Cc Vinod Koul <[email protected]>Cc Maxime Coquelin <[email protected]>Cc Alexandre Torgue <[email protected]>Signed-off-by Kees Cook <[email protected]>
Thanks
--
Gustavo
Quoted 68 lines
--- drivers/dma/stm32-dma.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)drivers/dma/stm32-dma.c +4
-7@@ -191,7 +191,7 @@ struct stm32_dma_desc {struct virt_dma_desc vdesc;bool cyclic;u32 num_sgs; -struct stm32_dma_sg_req sg_req[]; + struct stm32_dma_sg_req sg_req[] __counted_by(num_sgs); };/** @@ -1105,6 +1105,7 @@ static struct dma_async_tx_descriptor *stm32_dma_prep_slave_sg( desc =kzalloc (struct_size (desc, sg_req, sg_len),GFP_NOWAIT );if (!desc)return NULL ; + desc->num_sgs = sg_len;/* Set peripheral flow controller */ if (chan->dma_sconfig.device_fc)@@ -1141,8 +1142,6 @@ static struct dma_async_tx_descriptor *stm32_dma_prep_slave_sg( desc->sg_req[i].chan_reg.dma_sm1ar +=sg_dma_len (sg); desc->sg_req[i].chan_reg.dma_sndtr = nb_data_items; } - - desc->num_sgs = sg_len; desc->cyclic = false;return vchan_tx_prep (&chan->vchan, &desc->vdesc, flags);@@ -1216,6 +1215,7 @@ static struct dma_async_tx_descriptor *stm32_dma_prep_dma_cyclic( desc =kzalloc (struct_size (desc, sg_req, num_periods),GFP_NOWAIT );if (!desc)return NULL ; + desc->num_sgs = num_periods;for (i =0 ; i < num_periods; i++) { desc->sg_req[i].len = period_len;@@ -1232,8 +1232,6 @@ static struct dma_async_tx_descriptor *stm32_dma_prep_dma_cyclic(if (!chan->trig_mdma) buf_addr += period_len; } - - desc->num_sgs = num_periods; desc->cyclic = true;return vchan_tx_prep (&chan->vchan, &desc->vdesc, flags);@@ -1254,6 +1252,7 @@ static struct dma_async_tx_descriptor *stm32_dma_prep_dma_memcpy( desc =kzalloc (struct_size (desc, sg_req, num_sgs),GFP_NOWAIT );if (!desc)return NULL ; + desc->num_sgs = num_sgs; threshold = chan->threshold;@@ -1283,8 +1282,6 @@ static struct dma_async_tx_descriptor *stm32_dma_prep_dma_memcpy( desc->sg_req[i].chan_reg.dma_sndtr = xfer_count; desc->sg_req[i].len = xfer_count; } - - desc->num_sgs = num_sgs; desc->cyclic = false;return vchan_tx_prep (&chan->vchan, &desc->vdesc, flags);
PATCH 13/21 dmaengine: stm32-mdma: Annotate struct stm32_mdma_desc with __counted_by
In reply to Kees CookPrepare 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_desc. 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
--- drivers/dma/stm32-mdma.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/dma/stm32-mdma.c +2 -3
@@ -224,7 +224,7 @@ struct stm32_mdma_desc {u32 ccr;bool cyclic;u32 count; -struct stm32_mdma_desc_node node[]; + struct stm32_mdma_desc_node node[] __counted_by(count); };struct stm32_mdma_dma_config {
@@ -321,6 +321,7 @@ static struct stm32_mdma_desc *stm32_mdma_alloc_desc( desc =kzalloc (struct_size (desc, node, count),GFP_NOWAIT );if (!desc)return NULL ; + desc->count = count;for (i =0 ; i < count; i++) { desc->node[i].hwdesc =
@@ -330,8 +331,6 @@ static struct stm32_mdma_desc *stm32_mdma_alloc_desc( goto err; } - desc->count = count; -return desc; err:
Signature · 1 line
2.34.1
Re: [PATCH 13/21] dmaengine: stm32-mdma: Annotate struct stm32_mdma_desc with __counted_by
Quoted 12 lines · Kees Cook
Prepare for the coming implementation by GCC and Clang of the
__counted_byattribute. Flexible array members annotated with__counted_bycan have their accesses bounds-checked at run-time checking viaCONFIG_UBSAN_BOUNDS(for array indexing) andCONFIG_FORTIFY_SOURCE(for strcpy/memcpy-family functions).As found with Coccinelle[1], add
__counted_byfor structstm32_mdma_desc. 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
Quoted 7 lines
Cc Vinod Koul <[email protected]>Cc Maxime Coquelin <[email protected]>Cc Alexandre Torgue <[email protected]>Signed-off-by Kees Cook <[email protected]>
Thanks
--
Gustavo
Quoted 34 lines
--- drivers/dma/stm32-mdma.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/dma/stm32-mdma.c +2
-3@@ -224,7 +224,7 @@ struct stm32_mdma_desc {u32 ccr;bool cyclic;u32 count; -struct stm32_mdma_desc_node node[]; + struct stm32_mdma_desc_node node[] __counted_by(count); };struct stm32_mdma_dma_config {@@ -321,6 +321,7 @@ static struct stm32_mdma_desc *stm32_mdma_alloc_desc( desc =kzalloc (struct_size (desc, node, count),GFP_NOWAIT );if (!desc)return NULL ; + desc->count = count;for (i =0 ; i < count; i++) { desc->node[i].hwdesc =@@ -330,8 +331,6 @@ static struct stm32_mdma_desc *stm32_mdma_alloc_desc( goto err; } - desc->count = count; -return desc; err:
PATCH 14/21 dmaengine: stm32-mdma: Annotate struct stm32_mdma_device with __counted_by
In reply to Kees CookPrepare 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
--- drivers/dma/stm32-mdma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/dma/stm32-mdma.c +2 -2
@@ -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))
Signature · 1 line
2.34.1
Re: [PATCH 14/21] dmaengine: stm32-mdma: Annotate struct stm32_mdma_device with __counted_by
Quoted 12 lines · Kees Cook
Prepare for the coming implementation by GCC and Clang of the
__counted_byattribute. Flexible array members annotated with__counted_bycan have their accesses bounds-checked at run-time checking viaCONFIG_UBSAN_BOUNDS(for array indexing) andCONFIG_FORTIFY_SOURCE(for strcpy/memcpy-family functions).As found with Coccinelle[1], add
__counted_byfor structstm32_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
Quoted 7 lines
Cc Vinod Koul <[email protected]>Cc Maxime Coquelin <[email protected]>Cc Alexandre Torgue <[email protected]>Signed-off-by Kees Cook <[email protected]>
Thanks
--
Gustavo
Quoted 32 lines
--- drivers/dma/stm32-mdma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/dma/stm32-mdma.c +2
-2@@ -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))
PATCH 15/21 dmaengine: tegra: Annotate struct tegra_dma_desc with __counted_by
In reply to Kees CookPrepare 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 tegra_dma_desc.
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
--- drivers/dma/tegra186-gpc-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/tegra186-gpc-dma.c +1 -1
@@ -221,7 +221,7 @@ struct tegra_dma_desc {unsigned int sg_count;struct virt_dma_desc vd;struct tegra_dma_channel *tdc; -struct tegra_dma_sg_req sg_req[]; + struct tegra_dma_sg_req sg_req[] __counted_by(sg_count); };/*
Signature · 1 line
2.34.1
Re: [PATCH 15/21] dmaengine: tegra: Annotate struct tegra_dma_desc with __counted_by
Quoted 10 lines · Kees Cook
Prepare for the coming implementation by GCC and Clang of the
__counted_byattribute. Flexible array members annotated with__counted_bycan have their accesses bounds-checked at run-time checking viaCONFIG_UBSAN_BOUNDS(for array indexing) andCONFIG_FORTIFY_SOURCE(for strcpy/memcpy-family functions).As found with Coccinelle[1], add
__counted_byfor structtegra_dma_desc.[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
Quoted 7 lines
Cc Vinod Koul <[email protected]>Cc Laxman Dewangan <[email protected]>Cc Jon Hunter <[email protected]>Cc Thierry Reding <[email protected]>Signed-off-by Kees Cook <[email protected]>
Thanks
--
Gustavo
Quoted 17 lines
--- drivers/dma/tegra186-gpc-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/dma/tegra186-gpc-dma.c +1
-1@@ -221,7 +221,7 @@ struct tegra_dma_desc {unsigned int sg_count;struct virt_dma_desc vd;struct tegra_dma_channel *tdc; -struct tegra_dma_sg_req sg_req[]; + struct tegra_dma_sg_req sg_req[] __counted_by(sg_count); };/*
PATCH 16/21 dmaengine: tegra210-adma: Annotate struct tegra_adma with __counted_by
In reply to Kees CookPrepare 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 tegra_adma.
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
--- drivers/dma/tegra210-adma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/tegra210-adma.c +1 -1
@@ -162,7 +162,7 @@ struct tegra_adma {const struct tegra_adma_chip_data *cdata;/* Last member of the structure */ -struct tegra_adma_chan channels[]; + struct tegra_adma_chan channels[] __counted_by(nr_channels); };static inline void tdma_write (struct tegra_adma *tdma,u32 reg,u32 val)
Signature · 1 line
2.34.1
Re: [PATCH 16/21] dmaengine: tegra210-adma: Annotate struct tegra_adma with __counted_by
Quoted 10 lines · Kees Cook
Prepare for the coming implementation by GCC and Clang of the
__counted_byattribute. Flexible array members annotated with__counted_bycan have their accesses bounds-checked at run-time checking viaCONFIG_UBSAN_BOUNDS(for array indexing) andCONFIG_FORTIFY_SOURCE(for strcpy/memcpy-family functions).As found with Coccinelle[1], add
__counted_byfor structtegra_adma.[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
Quoted 7 lines
Cc Vinod Koul <[email protected]>Cc Laxman Dewangan <[email protected]>Cc Jon Hunter <[email protected]>Cc Thierry Reding <[email protected]>Signed-off-by Kees Cook <[email protected]>
Thanks
--
Gustavo
Quoted 17 lines
--- drivers/dma/tegra210-adma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/dma/tegra210-adma.c +1
-1@@ -162,7 +162,7 @@ struct tegra_adma {const struct tegra_adma_chip_data *cdata;/* Last member of the structure */ -struct tegra_adma_chan channels[]; + struct tegra_adma_chan channels[] __counted_by(nr_channels); };static inline void tdma_write (struct tegra_adma *tdma,u32 reg,u32 val)
PATCH 17/21 dmaengine: ti: edma: Annotate struct edma_desc with __counted_by
In reply to Kees CookPrepare 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 edma_desc.
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
--- drivers/dma/ti/edma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/ti/edma.c +1 -1
@@ -202,7 +202,7 @@ struct edma_desc {u32 residue;u32 residue_stat; -struct edma_pset pset[]; + struct edma_pset pset[] __counted_by(pset_nr); };struct edma_cc ;
Signature · 1 line
2.34.1
Re: [PATCH 17/21] dmaengine: ti: edma: Annotate struct edma_desc with __counted_by
Quoted 6 lines · Kees Cook
Prepare for the coming implementation by GCC and Clang of the
__counted_byattribute. Flexible array members annotated with__counted_bycan have their accesses bounds-checked at run-time checking viaCONFIG_UBSAN_BOUNDS(for array indexing) andCONFIG_FORTIFY_SOURCE(for strcpy/memcpy-family functions).
Quoted 8 lines
As found with Coccinelle[1], add
__counted_byfor structedma_desc.[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
Cc Vinod Koul <[email protected]>Cc Peter Ujfalusi <[email protected]>Signed-off-by Kees Cook <[email protected]>
Thanks
--
Gustavo
Quoted 17 lines
--- drivers/dma/ti/edma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/dma/ti/edma.c +1
-1@@ -202,7 +202,7 @@ struct edma_desc {u32 residue;u32 residue_stat; -struct edma_pset pset[]; + struct edma_pset pset[] __counted_by(pset_nr); };struct edma_cc ;
PATCH 18/21 dmaengine: ti: omap-dma: Annotate struct omap_desc with __counted_by
In reply to Kees CookPrepare 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 omap_desc. 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
--- drivers/dma/ti/omap-dma.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/dma/ti/omap-dma.c +2 -3
@@ -124,7 +124,7 @@ struct omap_desc {uint32_t csdp;/* CSDP value */ unsigned sglen; -struct omap_sg sg[]; + struct omap_sg sg[] __counted_by(sglen); };enum {
@@ -1005,6 +1005,7 @@ static struct dma_async_tx_descriptor *omap_dma_prep_slave_sg( d =kzalloc (struct_size (d, sg, sglen),GFP_ATOMIC );if (!d)return NULL ; + d->sglen = sglen; d->dir = dir; d->dev_addr = dev_addr;
@@ -1120,8 +1121,6 @@ static struct dma_async_tx_descriptor *omap_dma_prep_slave_sg( } } - d->sglen = sglen; -/* Release the dma_pool entries if one allocation failed */ if (ll_failed) {for (i =0 ; i < d->sglen; i++) {
Signature · 1 line
2.34.1
Re: [PATCH 18/21] dmaengine: ti: omap-dma: Annotate struct omap_desc with __counted_by
Quoted 10 lines · Kees Cook
Prepare for the coming implementation by GCC and Clang of the
__counted_byattribute. Flexible array members annotated with__counted_bycan have their accesses bounds-checked at run-time checking viaCONFIG_UBSAN_BOUNDS(for array indexing) andCONFIG_FORTIFY_SOURCE(for strcpy/memcpy-family functions).As found with Coccinelle[1], add
__counted_byfor structomap_desc. Additionally, since the element count member must be set before accessing the annotated flexible array member, move its initialization earlier.
Quoted 6 lines
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
Cc Vinod Koul <[email protected]>Cc Peter Ujfalusi <[email protected]>Signed-off-by Kees Cook <[email protected]>
Thanks
--
Gustavo
Quoted 34 lines
--- drivers/dma/ti/omap-dma.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/dma/ti/omap-dma.c +2
-3@@ -124,7 +124,7 @@ struct omap_desc {uint32_t csdp;/* CSDP value */ unsigned sglen; -struct omap_sg sg[]; + struct omap_sg sg[] __counted_by(sglen); };enum {@@ -1005,6 +1005,7 @@ static struct dma_async_tx_descriptor *omap_dma_prep_slave_sg( d =kzalloc (struct_size (d, sg, sglen),GFP_ATOMIC );if (!d)return NULL ; + d->sglen = sglen; d->dir = dir; d->dev_addr = dev_addr;@@ -1120,8 +1121,6 @@ static struct dma_async_tx_descriptor *omap_dma_prep_slave_sg( } } - d->sglen = sglen; -/* Release the dma_pool entries if one allocation failed */ if (ll_failed) {for (i =0 ; i < d->sglen; i++) {
PATCH 19/21 dmaengine: uniphier-xdmac: Annotate struct uniphier_xdmac_desc with __counted_by
In reply to Kees CookPrepare 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 uniphier_xdmac_desc. 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
--- drivers/dma/uniphier-xdmac.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/dma/uniphier-xdmac.c +3 -3
@@ -80,7 +80,7 @@ struct uniphier_xdmac_desc {unsigned int nr_node;unsigned int cur_node;enum dma_transfer_direction dir; -struct uniphier_xdmac_desc_node nodes[]; + struct uniphier_xdmac_desc_node nodes[] __counted_by(nr_node); };struct uniphier_xdmac_chan {
@@ -295,6 +295,7 @@ uniphier_xdmac_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dst, xd =kzalloc (struct_size (xd, nodes, nr),GFP_NOWAIT );if (!xd)return NULL ; + xd->nr_node = nr;for (i =0 ; i < nr; i++) { burst_size =min_t (size_t, len,XDMAC_MAX_WORD_SIZE );
@@ -309,7 +310,6 @@ uniphier_xdmac_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dst, } xd->dir =DMA_MEM_TO_MEM ; - xd->nr_node = nr; xd->cur_node =0 ;return vchan_tx_prep (vc, &xd->vd, flags);
@@ -351,6 +351,7 @@ uniphier_xdmac_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, xd =kzalloc (struct_size (xd, nodes, sg_len),GFP_NOWAIT );if (!xd)return NULL ; + xd->nr_node = sg_len;for_each_sg (sgl, sg, sg_len, i) { xd->nodes[i].src = (direction ==DMA_DEV_TO_MEM )
@@ -385,7 +386,6 @@ uniphier_xdmac_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, } xd->dir = direction; - xd->nr_node = sg_len; xd->cur_node =0 ;return vchan_tx_prep (vc, &xd->vd, flags);
Signature · 1 line
2.34.1
Re: [PATCH 19/21] dmaengine: uniphier-xdmac: Annotate struct uniphier_xdmac_desc with __counted_by
Quoted 10 lines · Kees Cook
Prepare for the coming implementation by GCC and Clang of the
__counted_byattribute. Flexible array members annotated with__counted_bycan have their accesses bounds-checked at run-time checking viaCONFIG_UBSAN_BOUNDS(for array indexing) andCONFIG_FORTIFY_SOURCE(for strcpy/memcpy-family functions).As found with Coccinelle[1], add
__counted_byfor structuniphier_xdmac_desc. Additionally, since the element count member must be set before accessing the annotated flexible array member, move its initialization earlier.
Quoted 8 lines
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
Cc Vinod Koul <[email protected]>Cc Kunihiko Hayashi <[email protected]>Cc Masami Hiramatsu <[email protected]>Signed-off-by Kees Cook <[email protected]>
Thanks
--
Gustavo
Quoted 49 lines
--- drivers/dma/uniphier-xdmac.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/dma/uniphier-xdmac.c +3
-3@@ -80,7 +80,7 @@ struct uniphier_xdmac_desc {unsigned int nr_node;unsigned int cur_node;enum dma_transfer_direction dir; -struct uniphier_xdmac_desc_node nodes[]; + struct uniphier_xdmac_desc_node nodes[] __counted_by(nr_node); };struct uniphier_xdmac_chan {@@ -295,6 +295,7 @@ uniphier_xdmac_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dst, xd =kzalloc (struct_size (xd, nodes, nr),GFP_NOWAIT );if (!xd)return NULL ; + xd->nr_node = nr;for (i =0 ; i < nr; i++) { burst_size =min_t (size_t, len,XDMAC_MAX_WORD_SIZE );@@ -309,7 +310,6 @@ uniphier_xdmac_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dst, } xd->dir =DMA_MEM_TO_MEM ; - xd->nr_node = nr; xd->cur_node =0 ;return vchan_tx_prep (vc, &xd->vd, flags);@@ -351,6 +351,7 @@ uniphier_xdmac_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, xd =kzalloc (struct_size (xd, nodes, sg_len),GFP_NOWAIT );if (!xd)return NULL ; + xd->nr_node = sg_len;for_each_sg (sgl, sg, sg_len, i) { xd->nodes[i].src = (direction ==DMA_DEV_TO_MEM )@@ -385,7 +386,6 @@ uniphier_xdmac_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl, } xd->dir = direction; - xd->nr_node = sg_len; xd->cur_node =0 ;return vchan_tx_prep (vc, &xd->vd, flags);
PATCH 20/21 dmaengine: uniphier-xdmac: Annotate struct uniphier_xdmac_device with __counted_by
In reply to Kees CookPrepare 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 uniphier_xdmac_device.
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
--- drivers/dma/uniphier-xdmac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/uniphier-xdmac.c +1 -1
@@ -97,7 +97,7 @@ struct uniphier_xdmac_device {struct dma_device ddev;void __iomem *reg_base;int nr_chans; -struct uniphier_xdmac_chan channels[]; + struct uniphier_xdmac_chan channels[] __counted_by(nr_chans); }; static struct uniphier_xdmac_chan *
Signature · 1 line
2.34.1
Re: [PATCH 20/21] dmaengine: uniphier-xdmac: Annotate struct uniphier_xdmac_device with __counted_by
Quoted 8 lines · Kees Cook
Prepare for the coming implementation by GCC and Clang of the
__counted_byattribute. Flexible array members annotated with__counted_bycan have their accesses bounds-checked at run-time checking viaCONFIG_UBSAN_BOUNDS(for array indexing) andCONFIG_FORTIFY_SOURCE(for strcpy/memcpy-family functions).As found with Coccinelle[1], add
__counted_byfor structuniphier_xdmac_device.
Quoted 8 lines
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
Cc Vinod Koul <[email protected]>Cc Kunihiko Hayashi <[email protected]>Cc Masami Hiramatsu <[email protected]>Signed-off-by Kees Cook <[email protected]>
Thanks
--
Gustavo
Quoted 17 lines
--- drivers/dma/uniphier-xdmac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/dma/uniphier-xdmac.c +1
-1@@ -97,7 +97,7 @@ struct uniphier_xdmac_device {struct dma_device ddev;void __iomem *reg_base;int nr_chans; -struct uniphier_xdmac_chan channels[]; + struct uniphier_xdmac_chan channels[] __counted_by(nr_chans); }; static struct uniphier_xdmac_chan *
PATCH 21/21 dmaengine: usb-dmac: Annotate struct usb_dmac_desc with __counted_by
In reply to Kees CookPrepare 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 usb_dmac_desc.
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
--- drivers/dma/sh/usb-dmac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/sh/usb-dmac.c +1 -1
@@ -57,7 +57,7 @@ struct usb_dmac_desc {u32 residue;struct list_head node;dma_cookie_t done_cookie; -struct usb_dmac_sg sg[]; + struct usb_dmac_sg sg[] __counted_by(sg_allocated_len); };#define to_usb_dmac_desc (vd) container_of(vd, struct usb_dmac_desc, vd)
Signature · 1 line
2.34.1
Re: [PATCH 21/21] dmaengine: usb-dmac: Annotate struct usb_dmac_desc with __counted_by
Quoted 10 lines · Kees Cook
Prepare for the coming implementation by GCC and Clang of the
__counted_byattribute. Flexible array members annotated with__counted_bycan have their accesses bounds-checked at run-time checking viaCONFIG_UBSAN_BOUNDS(for array indexing) andCONFIG_FORTIFY_SOURCE(for strcpy/memcpy-family functions).As found with Coccinelle[1], add
__counted_byfor structusb_dmac_desc.[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
Quoted 8 lines
Cc Vinod Koul <[email protected]>Cc Yu Kuai <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Jordy Zomer <[email protected]>Cc Jernej Skrabec <[email protected]>Cc Tudor Ambarus <[email protected]>Signed-off-by Kees Cook <[email protected]>
Thanks
--
Gustavo
Quoted 17 lines
--- drivers/dma/sh/usb-dmac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/dma/sh/usb-dmac.c +1
-1@@ -57,7 +57,7 @@ struct usb_dmac_desc {u32 residue;struct list_head node;dma_cookie_t done_cookie; -struct usb_dmac_sg sg[]; + struct usb_dmac_sg sg[] __counted_by(sg_allocated_len); };#define to_usb_dmac_desc (vd) container_of(vd, struct usb_dmac_desc, vd)
Hi,
Just a ping on the series... how do these look to you, Vinod?
If you want I can carry them in my tree. Please let me know.
Thanks!
-Kees
Quoted 62 lines · Kees Cook
Hi,
This annotates several structures with the coming
__counted_byattribute for bounds checking of flexible arrays at run-time. For more details, see commitdd06e72e68bc("Compiler Attributes: Add__counted_bymacro").Thanks!
-Kees
Kees Cook (21):
dmaengine: apple-admac: Annotate structadmac_datawith__counted_by
dmaengine:at_hdmac: Annotate structat_descwith__counted_by
dmaengine: axi-dmac: Annotate structaxi_dmac_descwith__counted_by
dmaengine: fsl-edma: Annotate structfsl_edma_descwith__counted_by
dmaengine: hisilicon: Annotate structhisi_dma_devwith__counted_by
dmaengine: moxart-dma: Annotate structmoxart_descwith__counted_by
dmaengine: qcom:bam_dma: Annotate structbam_async_descwith
__counted_by
dmaengine: sa11x0: Annotate structsa11x0_dma_descwith__counted_by
dmaengine: sf-pdma: Annotate structsf_pdmawith__counted_by
dmaengine: sprd: Annotate structsprd_dma_devwith__counted_by
dmaengine:st_fdma: Annotate structst_fdma_descwith__counted_by
dmaengine: stm32-dma: Annotate structstm32_dma_descwith__counted_by
dmaengine: stm32-mdma: Annotate structstm32_mdma_descwith
__counted_by
dmaengine: stm32-mdma: Annotate structstm32_mdma_devicewith
__counted_by
dmaengine: tegra: Annotate structtegra_dma_descwith__counted_by
dmaengine: tegra210-adma: Annotate structtegra_admawith__counted_by
dmaengine: ti: edma: Annotate structedma_descwith__counted_by
dmaengine: ti: omap-dma: Annotate structomap_descwith__counted_by
dmaengine: uniphier-xdmac: Annotate structuniphier_xdmac_descwith
__counted_by
dmaengine: uniphier-xdmac: Annotate structuniphier_xdmac_devicewith
__counted_by
dmaengine: usb-dmac: Annotate structusb_dmac_descwith__counted_bydrivers/dma/apple-admac.c | 2 +- drivers/dma/at_hdmac.c | 2 +- drivers/dma/dma-axi-dmac.c | 5 ++--- drivers/dma/fsl-edma-common.h | 2 +- drivers/dma/hisi_dma.c | 2 +- drivers/dma/moxart-dma.c | 5 ++--- drivers/dma/qcom/bam_dma.c | 2 +- drivers/dma/sa11x0-dma.c | 6 +++--- drivers/dma/sf-pdma/sf-pdma.h | 2 +- drivers/dma/sh/usb-dmac.c | 2 +- drivers/dma/sprd-dma.c | 2 +- drivers/dma/st_fdma.h | 2 +- drivers/dma/stm32-dma.c | 11 ++++------- drivers/dma/stm32-mdma.c | 9 ++++----- drivers/dma/tegra186-gpc-dma.c | 2 +- drivers/dma/tegra210-adma.c | 2 +- drivers/dma/ti/edma.c | 2 +- drivers/dma/ti/omap-dma.c | 5 ++--- drivers/dma/uniphier-xdmac.c | 8 ++++---- 19 files changed, 33 insertions(+), 40 deletions(-)Signature · 1 line
2.34.1
Signature · 1 line
Kees Cook
Quoted 3 lines · Kees Cook
Just a ping on the series... how do these look to you, Vinod?
If you want I can carry them in my tree. Please let me know.
I'm now carrying this in my for-next/hardening tree. Let me know if you'd prefer I drop it.
Thanks!
-Kees
Signature · 1 line
Kees Cook
Vinod Koul
maintainerQuoted 7 lines · Kees Cook
Quoted 3 lines · Kees Cook
Just a ping on the series... how do these look to you, Vinod?
If you want I can carry them in my tree. Please let me know.
I'm now carrying this in my for-next/hardening tree. Let me know if you'd prefer I drop it.
Sorry was busy in travel etc, it should be in dmaengine/next tomorrow. You can drop it
Thanks
Signature · 1 line
~Vinod
Quoted 9 lines · Kees Cook
This annotates several structures with the coming
__counted_byattribute for bounds checking of flexible arrays at run-time. For more details, see commitdd06e72e68bc("Compiler Attributes: Add__counted_bymacro").Thanks!
-Kees
[...]
Applied, thanks!
[01/21] dmaengine: apple-admac: Annotate struct admac_data with __counted_by
commit: 83c5d35bf9112577da097c1b4fbfedef93b951e6
[02/21] dmaengine: at_hdmac: Annotate struct at_desc with __counted_by
commit: 81cd3cb3b3dd37df1fc45c5b6443a07bc2a7fee4
[03/21] dmaengine: axi-dmac: Annotate struct axi_dmac_desc with __counted_by
commit: f1bc0d01cb349da43d55548b57c915ef8fe024c7
[04/21] dmaengine: fsl-edma: Annotate struct fsl_edma_desc with __counted_by
(no commit info)
[05/21] dmaengine: hisilicon: Annotate struct hisi_dma_dev with __counted_by
commit: 7d4b82185521538eab8b0532b9bd7b8c8ca3e63b
[06/21] dmaengine: moxart-dma: Annotate struct moxart_desc with __counted_by
commit: fd1cb31a037bf8894a710392c2354281c5276d09
[07/21] dmaengine: qcom: bam_dma: Annotate struct bam_async_desc with __counted_by
commit: b9fe0bd5903140cc3e1ae4e542ae7ff38c90d011
[08/21] dmaengine: sa11x0: Annotate struct sa11x0_dma_desc with __counted_by
commit: 04b5433b8c0e1b014f081f4bf79767bbc207a7b0
[09/21] dmaengine: sf-pdma: Annotate struct sf_pdma with __counted_by
commit: 1539a22e144106eefc0ef05e7b91f68ad20a71ad
[10/21] dmaengine: sprd: Annotate struct sprd_dma_dev with __counted_by
commit: 8360c11aef5775745fc10438e24db95ab2329b1d
[11/21] dmaengine: st_fdma: Annotate struct st_fdma_desc with __counted_by
commit: 8279f0b476f37c51de2ed8bd70d770b2893dd2fa
[12/21] dmaengine: stm32-dma: Annotate struct stm32_dma_desc with __counted_by
commit: 195e46df2d996ff4bbf624891b1d3ae8ea9f315d
[13/21] dmaengine: stm32-mdma: Annotate struct stm32_mdma_desc with __counted_by
commit: 035472170a2a21fc62d8258883a9f566943058b7
[14/21] dmaengine: stm32-mdma: Annotate struct stm32_mdma_device with __counted_by
commit: 7ba0035dc02ce0c877004dc4052c6d5f873539db
[15/21] dmaengine: tegra: Annotate struct tegra_dma_desc with __counted_by
commit: 32b5e2d7cd14c80de1fa1cdffcc6ec211b615d82
[16/21] dmaengine: tegra210-adma: Annotate struct tegra_adma with __counted_by
commit: 15f2c636dde8c4370db87ceabce5cc8325460d77
[17/21] dmaengine: ti: edma: Annotate struct edma_desc with __counted_by
commit: 5f240e0cdbcb0cc60d6a75ea7d492ce93b7fd52e
[18/21] dmaengine: ti: omap-dma: Annotate struct omap_desc with __counted_by
commit: b85178611c1156deb3c09e7f8d8cdd662b8df99c
[19/21] dmaengine: uniphier-xdmac: Annotate struct uniphier_xdmac_desc with __counted_by
commit: 5a67a8f93f02027e4ac8583715d2f4bd2de20e10
[20/21] dmaengine: uniphier-xdmac: Annotate struct uniphier_xdmac_device with __counted_by
commit: 7935de861aed45f97a4262d9b215d9feb172516b
[21/21] dmaengine: usb-dmac: Annotate struct usb_dmac_desc with __counted_by
commit: a04bbeaa37d8789de5592506fa776256e784b69cBest regards,
Signature · 1 line
~Vinod
Quoted 6 lines · Vinod Koul
Quoted 4 lines · Kees Cook
This annotates several structures with the coming
__counted_byattribute for bounds checking of flexible arrays at run-time. For more details, see commitdd06e72e68bc("Compiler Attributes: Add__counted_bymacro").
Quoted 7 lines
Quoted 5 lines
Thanks!
-Kees
[...]
Applied, thanks!
Thanks! I've dropped them from my tree. :)
Also, I found 1 more, which I'll send separately.
-Kees
Signature · 1 line
Kees Cook