BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "James Hilliard" <james.hilliard1@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net v3 10/10] net: stmmac: retain DMA resources across MTU changes
Date: Fri, 25 Sep 2026 18:11:09 +0000	[thread overview]
Message-ID: <20260925181110.249841F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260924-submit-stmmac-reset-fixes-v1-v3-10-c031e3f3a282@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] net: stmmac: Use-After-Free of TX hrtimers during MTU reconfiguration
- [High] net: stmmac: Shared interrupt line disruption via disable_irq()
--

commit 3f4df67ed0eaa758c59a612b2b520f3af55b5627
Author: James Hilliard <james.hilliard1@gmail.com>

net: stmmac: retain DMA resources across MTU changes

Releasing the current datapath before reopening with a new MTU loses the
working configuration when hardware setup fails. Keep the old rings and
IRQ registrations until replacement hardware setup succeeds, so an
ordinary setup error can restore the old MTU without allocating new rings
or requesting interrupts again.

> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index d17c68f55caf6..1a552455a633d 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

[ ... ]

> @@ -4080,14 +4156,40 @@ static int stmmac_request_irq(struct net_device *dev)
>  	return ret;
>  }
>  
> +/* Balance disable_irq()/enable_irq() for every registered IRQ, including
> + * shared lines. Unlike freeing and requesting IRQs, this cannot fail.
> + */
> +static void stmmac_set_irq_state(struct stmmac_priv *priv, bool enable)
> +{
> +	void (*set_state)(unsigned int) = enable ? enable_irq : disable_irq;
> +	struct stmmac_msi *msi = priv->msi;
> +	int irq = priv->dev->irq;
> +	u32 i;
> +
> +	set_state(irq);

[Severity: High]
Since dev->irq, priv->wol_irq, and priv->sfty_irq can be registered as
shared interrupt lines (IRQF_SHARED) in single IRQ mode, does using
disable_irq() here risk completely disrupting other unrelated devices
sharing the same interrupt line?

Could this suppress the interrupt at the controller level and lead to
system-wide instability or timeouts for those other devices?

[ ... ]

> @@ -6234,6 +6338,113 @@ static void stmmac_set_rx_mode(struct net_device *dev)
>  	stmmac_set_filter(priv, priv->hw, dev);
>  }
>  
> +static int stmmac_reconfigure_mtu(struct net_device *dev, int mtu)
> +{

[ ... ]

> +	/* An IRQ can recover a TX error and restart a queue. Drain handlers
> +	 * before the final TX stop, and keep the registrations for rollback.
> +	 */
> +	stmmac_set_irq_state(priv, false);
> +	netif_tx_disable(dev);
> +	synchronize_net();
> +
> +	ret = stmmac_prepare_rx_buffers(priv);

[Severity: High]
If a TX error IRQ fires between the initial stmmac_quiesce() and the
stmmac_set_irq_state(priv, false) call here in stmmac_reconfigure_mtu(),
the queue can be restarted and stmmac_tx_timer_arm() will re-arm the TX
hrtimer.

However, this block appears to omit a final stmmac_stop_tx_queues(priv)
or hrtimer_cancel() call to disarm the TX hrtimers before freeing the
old configuration.

Does this mean the timer could remain queued when old_conf is freed,
potentially causing a use-after-free and a kernel panic?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260924-submit-stmmac-reset-fixes-v1-v3-0-c031e3f3a282@gmail.com?part=10

  reply	other threads:[~2026-09-25 18:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-24 17:44 [PATCH net v3 00/10] net: stmmac: preserve datapath state across MTU and resume failures James Hilliard
2026-09-24 17:44 ` [PATCH net v3 01/10] net: stmmac: unwind the WoL IRQ after a safety IRQ request failure James Hilliard
2026-09-24 17:44 ` [PATCH net v3 02/10] net: phylink: allow stopping a suspended instance James Hilliard
2026-09-24 17:44 ` [PATCH net v3 03/10] net: stmmac: keep datapath state coherent after reinitialization failure James Hilliard
2026-09-25 19:11   ` netdev-bot+sashiko
2026-09-24 17:44 ` [PATCH net v3 04/10] net: stmmac: leave the datapath running for normal-size MTU changes James Hilliard
2026-09-24 17:44 ` [PATCH net v3 05/10] net: stmmac: unwind partially allocated DMA configurations James Hilliard
2026-09-25 19:11   ` netdev-bot+sashiko
2026-09-24 17:44 ` [PATCH net v3 06/10] net: stmmac: keep DMA configurations at stable addresses James Hilliard
2026-09-25 19:12   ` netdev-bot+sashiko
2026-09-24 17:44 ` [PATCH net v3 07/10] net: stmmac: account for failed live XDP reopening James Hilliard
2026-09-25 19:12   ` netdev-bot+sashiko
2026-09-24 17:44 ` [PATCH net v3 08/10] net: stmmac: use the tracked datapath restart for XSK pool changes James Hilliard
2026-09-25 19:12   ` netdev-bot+sashiko
2026-09-24 17:44 ` [PATCH net v3 09/10] net: stmmac: retain PHY and PM ownership during ethtool reopening James Hilliard
2026-09-25 19:12   ` netdev-bot+sashiko
2026-09-24 17:44 ` [PATCH net v3 10/10] net: stmmac: retain DMA resources across MTU changes James Hilliard
2026-09-25 18:11   ` sashiko-bot [this message]
2026-09-25 19:12   ` 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=20260925181110.249841F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=james.hilliard1@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox