From: sashiko-bot@kernel.org
To: "Daniel Thompson" <daniel@riscstar.com>
Cc: bpf@vger.kernel.org, linux-sunxi@lists.linux.dev
Subject: Re: [PATCH net-next v3 2/2] net: stmmac: Avoid freeing and re-requesting IRQ during XDP set prog
Date: Fri, 16 Oct 2026 14:58:29 +0000 [thread overview]
Message-ID: <sashiko-outbox-174509@kernel.org> (raw)
In-Reply-To: <20261015-tc956x-stmmac-no_irq_teardown-v3-2-8189870be545@riscstar.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] net: stmmac: Use-After-Free in stmmac_tx_err() due to active ISR after DMA descriptors freed
--
commit 4c2320440039ed3235615c60f92cbcfdc0584d5a
Author: Daniel Thompson <daniel@riscstar.com>
net: stmmac: Avoid freeing and re-requesting IRQ during XDP set prog
This commit changes the XDP setup process to avoid completely freeing and
re-requesting IRQs, which disrupts TSN thread tuning. Instead of calling
stmmac_free_irq(), it masks the DMA interrupts and synchronizes them during
XDP release.
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 7b80fe66cf199..f1359637007e2 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
[ ... ]
> @@ -7141,8 +7186,9 @@ void stmmac_xdp_release(struct net_device *dev)
> for (chan = 0; chan < priv->plat->tx_queues_to_use; chan++)
> hrtimer_cancel(&priv->dma_conf.tx_queue[chan].txtimer);
>
> - /* Free the IRQ lines */
> - stmmac_free_irq(dev, REQ_IRQ_ERR_ALL, 0);
> + /* Silence DMA interrupts */
> + stmmac_disable_all_dma_irq(priv);
> + stmmac_synchronize_irq(dev);
>
> /* Stop TX/RX DMA channels */
> stmmac_stop_all_dma(priv);
[Severity: High]
Could this change introduce a use-after-free when setting up an XDP program?
Since the ISR stmmac_interrupt() remains registered after replacing
stmmac_free_irq(), the interrupt handler can still run if a shared IRQ or
unmasked MAC interrupt fires.
When stmmac_stop_all_dma() stops the TX DMA, it sets the TPS (Tx Process
Stopped) bit in the hardware DMA status register.
Immediately after this in stmmac_xdp_release(), free_dma_desc_resources()
is called, which frees the descriptor memory without assigning NULL.
If an interrupt fires at this point, stmmac_interrupt() reads the raw DMA
status and evaluates TPS regardless of whether DMA interrupts are masked:
drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c:dwmac4_dma_interrupt() {
...
if (unlikely(intr_status & DMA_CHAN_STATUS_TPS)) {
x->tx_process_stopped_irq++;
ret = tx_hard_error;
}
...
}
This unconditionally returns tx_hard_error, which then triggers
stmmac_tx_err() to execute.
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:stmmac_tx_err() {
...
dma_free_tx_skbufs(priv, &priv->dma_conf, chan);
stmmac_clear_tx_descriptors(priv, &priv->dma_conf, chan);
...
}
Will stmmac_tx_err() then try to clear and re-free the already freed
descriptors, resulting in a use-after-free?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261015-tc956x-stmmac-no_irq_teardown-v3-0-8189870be545@riscstar.com?part=2
prev parent reply other threads:[~2026-10-16 14:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 14:55 [PATCH net-next v3 0/2] net: stmmac: Avoid freeing and re-requesting IRQ during XDP set prog Daniel Thompson
2026-10-15 14:55 ` [PATCH net-next v3 1/2] net: stmmac: Introduce group arguments for enable/disable_dma_irq Daniel Thompson
2026-10-16 14:58 ` sashiko-bot
2026-10-15 14:55 ` [PATCH net-next v3 2/2] net: stmmac: Avoid freeing and re-requesting IRQ during XDP set prog Daniel Thompson
2026-10-16 14:58 ` sashiko-bot [this message]
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-174509@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@riscstar.com \
--cc=linux-sunxi@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
/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.