Netdev List
 help / color / mirror / Atom feed
* [PATCH net 0/2] net: Keep MDIO resources until netdev removal completes
@ 2026-11-17 14:42 Guangshuo Li
  2026-11-17 14:43 ` [PATCH net 1/2] net: altera: Fix potential use-after-free on removal Guangshuo Li
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Guangshuo Li @ 2026-11-17 14:42 UTC (permalink / raw)
  To: Boon Khai Ng, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Michal Simek
  Cc: netdev, linux-kernel, linux-arm-kernel

Unregister the Altera and Emaclite network devices while the MDIO bus
is still available to detach the PHY.

Guangshuo Li (2):
  net: altera: Fix potential use-after-free on removal
  net: emaclite: Fix potential use-after-free during removal

 drivers/net/ethernet/altera/altera_tse_main.c | 2 +-
 drivers/net/ethernet/xilinx/xilinx_emaclite.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
-- 
2.43.0


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

* [PATCH net 1/2] net: altera: Fix potential use-after-free on removal
  2026-11-17 14:42 [PATCH net 0/2] net: Keep MDIO resources until netdev removal completes Guangshuo Li
@ 2026-11-17 14:43 ` Guangshuo Li
  2026-11-17 14:45 ` [PATCH net 2/2] net: emaclite: Fix potential use-after-free during removal Guangshuo Li
  2026-11-17 14:47 ` [PATCH net 0/2] net: Keep MDIO resources until netdev removal completes netdev-bot+sinfo
  2 siblings, 0 replies; 4+ messages in thread
From: Guangshuo Li @ 2026-11-17 14:43 UTC (permalink / raw)
  To: Boon Khai Ng, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Michal Simek
  Cc: netdev, linux-kernel, linux-arm-kernel

Destroying the MDIO bus before unregistering a running network device
leaves its PHY attached to a freed bus. The subsequent shutdown path
calls phylink_disconnect_phy(), which can access that bus.

Unregister the network device before destroying the MDIO bus.

This issue was found by our static analysis tool under development.

Fixes: bbd2190ce96d ("Altera TSE: Add main and header file for Altera Ethernet Driver")
Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
---
 drivers/net/ethernet/altera/altera_tse_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c
index 9eed0be4411e..e203f9fcb5d7 100644
--- a/drivers/net/ethernet/altera/altera_tse_main.c
+++ b/drivers/net/ethernet/altera/altera_tse_main.c
@@ -1461,8 +1461,8 @@ static void altera_tse_remove(struct platform_device *pdev)
 	struct altera_tse_private *priv = netdev_priv(ndev);
 
 	platform_set_drvdata(pdev, NULL);
-	altera_tse_mdio_destroy(ndev);
 	unregister_netdev(ndev);
+	altera_tse_mdio_destroy(ndev);
 	phylink_destroy(priv->phylink);
 	lynx_pcs_destroy(priv->pcs);
 
-- 
2.43.0


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

* [PATCH net 2/2] net: emaclite: Fix potential use-after-free during removal
  2026-11-17 14:42 [PATCH net 0/2] net: Keep MDIO resources until netdev removal completes Guangshuo Li
  2026-11-17 14:43 ` [PATCH net 1/2] net: altera: Fix potential use-after-free on removal Guangshuo Li
@ 2026-11-17 14:45 ` Guangshuo Li
  2026-11-17 14:47 ` [PATCH net 0/2] net: Keep MDIO resources until netdev removal completes netdev-bot+sinfo
  2 siblings, 0 replies; 4+ messages in thread
From: Guangshuo Li @ 2026-11-17 14:45 UTC (permalink / raw)
  To: Boon Khai Ng, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Michal Simek
  Cc: netdev, linux-kernel, linux-arm-kernel, stable

xemaclite_of_remove() frees the MDIO bus before unregistering the
network device. If the interface is up, unregister_netdev() calls
xemaclite_close(), whose phy_disconnect() still accesses that bus.
This can cause a use-after-free during PHY detachment.

Unregister the network device first so that PHY detachment finishes
before the MDIO bus is unregistered and freed.

This issue was found by our static analysis tool under development.

Fixes: 27cad0084066 ("net: emaclite: Fix MDIO bus unregister bug")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
---
 drivers/net/ethernet/xilinx/xilinx_emaclite.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
index 4719d40a63ba..008e3d1e2981 100644
--- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c
+++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
@@ -1189,6 +1189,8 @@ static void xemaclite_of_remove(struct platform_device *of_dev)
 
 	struct net_local *lp = netdev_priv(ndev);
 
+	unregister_netdev(ndev);
+
 	/* Un-register the mii_bus, if configured */
 	if (lp->mii_bus) {
 		mdiobus_unregister(lp->mii_bus);
@@ -1196,8 +1198,6 @@ static void xemaclite_of_remove(struct platform_device *of_dev)
 		lp->mii_bus = NULL;
 	}
 
-	unregister_netdev(ndev);
-
 	of_node_put(lp->phy_node);
 	lp->phy_node = NULL;
 }
-- 
2.43.0


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

* Re: [PATCH net 0/2] net: Keep MDIO resources until netdev removal completes
  2026-11-17 14:42 [PATCH net 0/2] net: Keep MDIO resources until netdev removal completes Guangshuo Li
  2026-11-17 14:43 ` [PATCH net 1/2] net: altera: Fix potential use-after-free on removal Guangshuo Li
  2026-11-17 14:45 ` [PATCH net 2/2] net: emaclite: Fix potential use-after-free during removal Guangshuo Li
@ 2026-11-17 14:47 ` netdev-bot+sinfo
  2 siblings, 0 replies; 4+ messages in thread
From: netdev-bot+sinfo @ 2026-11-17 14:47 UTC (permalink / raw)
  To: Guangshuo Li
  Cc: Boon Khai Ng, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Michal Simek, netdev, linux-kernel,
	linux-arm-kernel

Hi!

This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:

 - What hardware the change was tested on. For driver fixes please
   mention the device (and if relevant firmware version) used for
   testing, or say that the change was not tested on real hardware.

Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.

*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
-- 
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.

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

end of thread, other threads:[~2026-11-17 14:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-17 14:42 [PATCH net 0/2] net: Keep MDIO resources until netdev removal completes Guangshuo Li
2026-11-17 14:43 ` [PATCH net 1/2] net: altera: Fix potential use-after-free on removal Guangshuo Li
2026-11-17 14:45 ` [PATCH net 2/2] net: emaclite: Fix potential use-after-free during removal Guangshuo Li
2026-11-17 14:47 ` [PATCH net 0/2] net: Keep MDIO resources until netdev removal completes netdev-bot+sinfo

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