From: sashiko-bot@kernel.org
To: Frank.Li@oss.nxp.com
Cc: dmaengine@vger.kernel.org, linux-sound@vger.kernel.org,
imx@lists.linux.dev, vkoul@kernel.org, Frank.Li@kernel.org
Subject: Re: [PATCH 2/3] net: xilinx: axienet: use dmaengine_prep_slave_sg_context()
Date: Sat, 07 Nov 2026 22:43:37 +0000 [thread overview]
Message-ID: <sashiko-outbox-203371@kernel.org> (raw)
In-Reply-To: <20261106-rio_sg-v1-2-bc54b4bd8c95@nxp.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] net: xilinx: axienet: unused dma_dev left in
axienet_start_xmit_dmaengine()
It also noticed 1 related pre-existing issue this patch does not
introduce:
- [Critical] net: axienet: use-after-free in axienet_stop() [1]
--
commit b4bb968eb4c8d380631e7d9eb4acd99d61288c16
Author: Frank Li <Frank.Li@nxp.com>
net: xilinx: axienet: use dmaengine_prep_slave_sg_context()
This commit replaces the direct call to dma_dev->device_prep_slave_sg() in
axienet_start_xmit_dmaengine() with dmaengine_prep_slave_sg_context().
> diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> index 8a50cad1c104f..fff3530d9359d 100644
> --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
> @@ -1006,9 +1006,10 @@ axienet_start_xmit_dmaengine(struct sk_buff *skb, struct net_device *ndev)
> app_metadata[0] |= 2; /* Tx Full Checksum Offload Enabled */
> }
>
> - dma_tx_desc = dma_dev->device_prep_slave_sg(lp->tx_chan, skbuf_dma->sgl,
> - sg_len, DMA_MEM_TO_DEV,
> - DMA_PREP_INTERRUPT, (void *)app_metadata);
> + dma_tx_desc = dmaengine_prep_slave_sg_context(lp->tx_chan, skbuf_dma->sgl,
> + sg_len, DMA_MEM_TO_DEV,
> + DMA_PREP_INTERRUPT,
> + (void *)app_metadata);
> if (!dma_tx_desc)
> goto xmit_error_unmap_sg;
[Severity: Low]
Does replacing dma_dev->device_prep_slave_sg() leave dma_dev unused in
axienet_start_xmit_dmaengine()?
Earlier in axienet_start_xmit_dmaengine(), dma_dev is still declared and
assigned from lp->tx_chan->device:
drivers/net/ethernet/xilinx/xilinx_axienet_main.c:axienet_start_xmit_dmaengine() {
...
struct dma_device *dma_dev;
...
dma_dev = lp->tx_chan->device;
...
}
With its only reader removed, this triggers a -Wunused-but-set-variable
compiler warning and keeps a direct reference to struct dma_device and
lp->tx_chan->device.
[Severity: Critical]
This problem wasn't introduced by this patch, but can axienet_stop() cause
a use-after-free on lp->tx_skb_ring [1] while
axienet_start_xmit_dmaengine() is running?
When lp->use_dmaengine is enabled, axienet_stop() frees lp->tx_skb_ring and
its entries without quiescing the transmit path:
drivers/net/ethernet/xilinx/xilinx_axienet_main.c:axienet_stop() {
...
if (!lp->use_dmaengine) {
WRITE_ONCE(lp->stopping, true);
flush_work(&lp->dma_err_task);
napi_disable(&lp->napi_tx);
napi_disable(&lp->napi_rx);
}
...
for (i = 0; i < TX_BD_NUM_MAX; i++) {
skbuf_dma = lp->tx_skb_ring[i];
...
kfree(skbuf_dma);
}
kfree(lp->tx_skb_ring);
...
}
CPU0 CPU1
axienet_stop()
axienet_start_xmit_dmaengine()
kfree(skbuf_dma)
kfree(lp->tx_skb_ring)
axienet_get_tx_desc()
<-- use-after-free
A concurrent transmit on CPU1 can fetch and use a descriptor from
lp->tx_skb_ring after CPU0 has freed it, corrupting memory or crashing the
kernel.
[1] https://sashiko.dev/#/bug/linux-6b22a4e9-355d-4ab5-829f-c56ef38ce667
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261106-rio_sg-v1-0-bc54b4bd8c95@nxp.com?part=2
next prev parent reply other threads:[~2026-11-07 22:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 22:43 [PATCH 0/3] dmaengine: generalize dmaengine_prep_rio_sg() as dmaengine_prep_slave_sg_context() Frank.Li
2026-11-06 22:43 ` [PATCH 1/3] dmaengine/rio: rename dmaengine_prep_rio_sg() to dmaengine_prep_slave_sg_context() Frank.Li
2026-11-06 22:43 ` [PATCH 2/3] net: xilinx: axienet: use dmaengine_prep_slave_sg_context() Frank.Li
2026-11-07 22:43 ` sashiko-bot [this message]
2026-11-09 7:33 ` Gupta, Suraj
2026-11-06 22:43 ` [PATCH 3/3] ASoC: sprd: use dmaengine_prep_slave_sg_context() instead of device_prep_slave_sg() Frank.Li
2026-11-07 10:59 ` Mark Brown
2026-11-07 22:43 ` sashiko-bot
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=sashiko-outbox-203371@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=Frank.Li@oss.nxp.com \
--cc=dmaengine@vger.kernel.org \
--cc=imx@lists.linux.dev \
--cc=linux-sound@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vkoul@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox