mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net] net: korina: fix use-after-free in media check timer
@ 2026-09-10  2:05 Fan Wu
  2026-09-16  0:53 ` Jakub Kicinski
  0 siblings, 1 reply; 2+ messages in thread
From: Fan Wu @ 2026-09-10  2:05 UTC (permalink / raw)
  To: netdev
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Florian Fainelli, linux-kernel, stable, Fan Wu,
	Song Li

korina_poll_media() rearms the media check timer by calling mod_timer()
unconditionally before returning. korina_close() stops it with
timer_delete(), which does not wait for a callback already running on
another CPU.

Such a callback can continue to access the netdev private data and can
rearm the timer. Once korina_remove() returns, devres releases the
netdev and its private data, so either the running callback or a later
timer expiry can dereference freed memory through lp->dev, lp->mii_if,
or lp->eth_regs.

The only timer armers are the callback itself and korina_open(). RTNL
serializes open against close, and timer_delete_sync() waits for a
running callback and removes the timer it rearmed. It is therefore
sufficient here while preserving the close/open cycle.

This issue was found by an in-house static analysis tool.

Fixes: 4d5ef9f0f588 ("korina: periodically poll the media")
Cc: stable@vger.kernel.org
Assisted-by: Codex:gpt-5.6
Co-developed-by: Song Li <songl@zju.edu.cn>
Signed-off-by: Song Li <songl@zju.edu.cn>
Signed-off-by: Fan Wu <fanwu01@zju.edu.cn>
---
 drivers/net/ethernet/korina.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/korina.c b/drivers/net/ethernet/korina.c
index 891a94d89f4b..b7de2238f4b3 100644
--- a/drivers/net/ethernet/korina.c
+++ b/drivers/net/ethernet/korina.c
@@ -1240,7 +1240,7 @@ static int korina_close(struct net_device *dev)
 	struct korina_private *lp = netdev_priv(dev);
 	u32 tmp;
 
-	timer_delete(&lp->media_check_timer);
+	timer_delete_sync(&lp->media_check_timer);
 
 	/* Disable interrupts */
 	disable_irq(lp->rx_irq);


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH net] net: korina: fix use-after-free in media check timer
  2026-09-10  2:05 [PATCH net] net: korina: fix use-after-free in media check timer Fan Wu
@ 2026-09-16  0:53 ` Jakub Kicinski
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2026-09-16  0:53 UTC (permalink / raw)
  To: Fan Wu
  Cc: netdev, Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni,
	Florian Fainelli, linux-kernel, stable, Song Li

On Thu, 10 Sep 2026 02:05:33 +0000 Fan Wu wrote:
> Subject: [PATCH net] net: korina: fix use-after-free in media check timer

Leave this driver be, it's ancient.
-- 
pw-bot: reject

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-16  0:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-10  2:05 [PATCH net] net: korina: fix use-after-free in media check timer Fan Wu
2026-09-16  0:53 ` Jakub Kicinski

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®