mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: [PATCH net] net: stmmac: remove STMMAC_DOWN
       [not found] <20261201091256.3000677-1-zxyan0222@gmail.com>
@ 2026-12-02  9:13 ` sashiko-bot
  0 siblings, 0 replies; only message in thread
From: sashiko-bot @ 2026-12-02  9:13 UTC (permalink / raw)
  To: Zxyan Zhu; +Cc: linux-rt-devel, bpf, linux-kernel

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] net: stmmac: use-after-free in stmmac_xdp_xmit() [1]
--

commit b3472c0c67723fdc6361e7e9ee949e73296b5d41
Author: Zxyan Zhu <zxyan0222@gmail.com>

net: stmmac: remove STMMAC_DOWN

This commit removes the STMMAC_DOWN state flag so interrupt handlers can
continue clearing interrupt status during a reset, and replaces the
remaining checks in stmmac_xdp_xmit() and stmmac_xsk_wakeup() with
STMMAC_RESETING.

Link: https://lore.kernel.org/netdev/20240327110142.159851-1-cathy.cai@unisoc.com/

> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index a685ce4638f61..7f7be965604e0 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
[ ... ]
> @@ -7150,7 +7129,7 @@ static int stmmac_xdp_xmit(struct net_device *dev, int num_frames,
>  	int i, nxmit = 0;
>  	int queue;
>  
> -	if (unlikely(test_bit(STMMAC_DOWN, &priv->state)))
> +	if (unlikely(test_bit(STMMAC_RESETING, &priv->state)))
>  		return -ENETDOWN;
>  
>  	if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK))

[Severity: Critical]
This problem wasn't introduced by this patch, but can stmmac_xdp_xmit() and
stmmac_xdp_xmit_back() hit a use-after-free and NULL pointer dereference
[1] when racing with XSK pool setup?

CPU0                                  CPU1
stmmac_xdp_enable_pool()
  stmmac_disable_tx_queue()
    netif_tx_stop_queue(txq)
    __free_dma_tx_desc_resources()
      kfree(tx_q->tx_skbuff_dma)
      tx_q->dma_tx = NULL
                                      stmmac_xdp_xmit()
                                        __netif_tx_lock(nq, cpu)
                                        stmmac_xdp_xmit_xdpf()
                                          tx_q->tx_skbuff_dma[...]  <-- UAF
                                          stmmac_get_tx_desc()      <-- NULL

stmmac_disable_tx_queue() stops the netdev TX queue and frees the queue's
DMA descriptor ring and tx_skbuff_dma array without setting
STMMAC_RESETING.  Because stmmac_xdp_xmit() and stmmac_xdp_xmit_back() lock
the TX queue without checking netif_tx_queue_stopped(nq), a concurrent XDP
transmit proceeds into stmmac_xdp_xmit_xdpf() after the queue's descriptor
resources have been torn down.

[1] https://sashiko.dev/#/bug/linux-036a9552-9d2b-427c-9ba1-a4c73d79872e

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261201091256.3000677-1-zxyan0222@gmail.com?part=1

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-12-02  9:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20261201091256.3000677-1-zxyan0222@gmail.com>
2026-12-02  9:13 ` [PATCH net] net: stmmac: remove STMMAC_DOWN sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®