Netdev List
 help / color / mirror / Atom feed
From: Jakub Raczynski <j.raczynski@samsung.com>
To: Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, mcoquelin.stm32@gmail.com,
	alexandre.torgue@foss.st.com, k.domagalski@samsung.com,
	k.tegowski@samsung.com, Chang-Sub Lee <cs0617.lee@samsung.com>
Subject: Re: [PATCH net] net/stmmac: Fix free-after-use panic when interface goes does with XDP
Date: Fri, 15 May 2026 10:29:17 +0200	[thread overview]
Message-ID: <agbZXcsn9CAlofe4@AMDC4622.eu.corp.samsungelectronics.net> (raw)
In-Reply-To: <4ca19ae1-6606-433b-9860-0a8cce12f80f@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1533 bytes --]

On Thu, May 14, 2026 at 02:01:20PM +0200, Paolo Abeni wrote:
> > 
> > Fix this by following:
> > - Set STMMAC_DOWN flag before stopping DMA to signal XDP to stop
> > - Call synchronize_rcu() after stopping DMA but before freeing resources to
> >   ensure all ongoing NAPI operations complete
> > - Add STMMAC_DOWN flag checks in XDP code paths (XDP_TX and XDP_REDIRECT) to
> >   drop packets when interface is going down. This has already been done for
> >   stmmac_xdp_xmit() so make it consistent
> > - Clear STMMAC_DOWN flag in __stmmac_open() to restore normal operation.
> >   This was only done for stmmac_reset_subtask() during abnormal operation,
> >   which is not enough. This does not affect normal operation as this flag is
> >   used only for XDP apps
> 
> The above looks racy. I think instead you should just use
> napi_synchronize() in __stmmac_release.
> 
You put this after whole section, but I assume you are talking about
synchronize_rcu()? Because currently there are 0 checks and it is pure race
condition. synchronize_rcu() does secure it in some way, but you are correct,
proper ensuring that napi has finished is napi_synchronize().
Will fix in v2.
> 
> > @@ -5267,6 +5279,9 @@ static int stmmac_xdp_xmit_back(struct stmmac_priv *priv,
> >  	if (unlikely(!xdpf))
> >  		return STMMAC_XDP_CONSUMED;
> >  
> > +	if (unlikely(test_bit(STMMAC_DOWN, &priv->state)))
> > +		return -ENETDOWN;
> 
> Sashiko noted here you should return STMMAC_XDP_CONSUMED
> 
> /P
Seems good, will fix in v2.

Thanks
Jakub Raczynski

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



  reply	other threads:[~2026-05-15  8:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20260511165107eucas1p1882391435991ffc19670a60a43bbde01@eucas1p1.samsung.com>
2026-05-11 16:50 ` [PATCH net] net/stmmac: Fix free-after-use panic when interface goes does with XDP Jakub Raczynski
2026-05-14 12:01   ` Paolo Abeni
2026-05-15  8:29     ` Jakub Raczynski [this message]
2026-05-15  9:24       ` Paolo Abeni
2026-05-15 11:16         ` Jakub Raczynski

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=agbZXcsn9CAlofe4@AMDC4622.eu.corp.samsungelectronics.net \
    --to=j.raczynski@samsung.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=cs0617.lee@samsung.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=k.domagalski@samsung.com \
    --cc=k.tegowski@samsung.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /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