All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Kurt Kanzenbach" <kurt@linutronix.de>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net v3 2/2] net: stmmac: Stop Tx queue when (en|dis)abling XSK pools
Date: Wed, 14 Oct 2026 08:57:46 +0000	[thread overview]
Message-ID: <sashiko-outbox-171051@kernel.org> (raw)
In-Reply-To: <20261013-stmmac_xsk_crashes-v3-2-50fca7790af2@linutronix.de>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] net: stmmac: hardware UAF due to unconditional flush on stopped queue
--

commit ef870c171b8f7f53a01cef2bdd086a9bc0f02d35
Author: Kurt Kanzenbach <kurt@linutronix.de>

net: stmmac: Stop Tx queue when (en|dis)abling XSK pools

When enabling or disabling XSK pools in parallel to Tx traffic, kernel
crashes occur. This patch adds stopping of the Tx queue during the enabling
and disabling of XSK pools to prevent accessing freed Tx DMA descriptors.

> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index 2aa5a26954731..0e8ab2bd8f3e8 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -5216,6 +5216,10 @@ static int stmmac_xdp_xmit_xdpf(struct stmmac_priv *priv, int queue,
>  	dma_addr_t dma_addr;
>  	bool set_ic;
>  
> +	/* Ring may be torn down for an XSK pool switch */
> +	if (netif_tx_queue_stopped(netdev_get_tx_queue(priv->dev, queue)))
> +		return STMMAC_XDP_CONSUMED;
> +

[Severity: High]
Could this unconditional flush cause a hardware use-after-free regression?

While this protects stmmac_xdp_xmit_xdpf() from accessing descriptors when the
queue is stopped, stmmac_xdp_xmit() calls it in a loop and then unconditionally
flushes if XDP_XMIT_FLUSH is set:

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:stmmac_xdp_xmit() {
    ...
	for (i = 0; i < num_frames; i++) {
		...
		res = stmmac_xdp_xmit_xdpf(priv, queue, frames[i], true);
		if (res == STMMAC_XDP_CONSUMED)
			break;
		nxmit++;
	}

	if (flags & XDP_XMIT_FLUSH) {
		stmmac_flush_tx_descriptors(priv, queue);
		stmmac_tx_timer_arm(priv, queue);
	}
    ...
}

If stmmac_xdp_xmit() is called with XDP_XMIT_FLUSH during an AF_XDP pool switch,
it will break out of the loop but still call stmmac_flush_tx_descriptors().

Since stmmac_flush_tx_descriptors() calls stmmac_set_queue_tx_tail_ptr(), could
this write a stale physical address to the hardware DMA tail pointer while
stmmac_enable_tx_queue() is allocating new descriptors, causing the DMA engine
to fetch from freed memory?

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261013-stmmac_xsk_crashes-v3-0-50fca7790af2@linutronix.de?part=2

  parent reply	other threads:[~2026-10-14  8:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13  8:57 [PATCH net v3 0/2] net: stmmac: Fix XSK crashes on stm32mp2 Kurt Kanzenbach
2026-10-13  8:57 ` [PATCH net v3 1/2] net: stmmac: Disable NAPI before stopping Tx queues in stmmac_xdp_release() Kurt Kanzenbach
2026-10-14  9:15   ` netdev-bot+sashiko
2026-10-13  8:57 ` [PATCH net v3 2/2] net: stmmac: Stop Tx queue when (en|dis)abling XSK pools Kurt Kanzenbach
2026-10-13 12:06   ` Nicolai Buchwitz
2026-10-14  8:57   ` sashiko-bot [this message]
2026-10-14  9:15   ` netdev-bot+sashiko

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-171051@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=kurt@linutronix.de \
    --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.