5.5medium
net: phy: allow MDIO bus PM ops to start/stop state machine for phylink-controlled PHY
- Severity
- 5.5medium CVSS:3.1 by NVD
- Exploit likelihood
- 0.27% (higher than 20% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- Linux
Description
In the Linux kernel, the following vulnerability has been resolved: net: phy: allow MDIO bus PM ops to start/stop state machine for phylink-controlled PHY DSA has 2 kinds of drivers: 1. Those who call dsa_switch_suspend() and dsa_switch_resume() from their device PM ops: qca8k-8xxx, bcm_sf2, microchip ksz 2. Those who don't: all others. The above methods should be optional. For type 1, dsa_switch_suspend() calls dsa_user_suspend() -> phylink_stop(), and dsa_switch_resume() calls dsa_user_resume() -> phylink_start(). These seem good candidates for setting mac_managed_pm = true because that is essentially its definition [1], but that does not seem to be the biggest problem for now, and is not what this change focuses on. Talking strictly about the 2nd category of DSA drivers here (which do not have MAC managed PM, meaning that for their attached PHYs, mdio_bus_phy_suspend() and mdio_bus_phy_resume() should run in full), I have noticed that the following warning from mdio_bus_phy_resume() is triggered: WARN_ON(phydev->state != PHY_HALTED && phydev->state != PHY_READY && phydev->state != PHY_UP); because the PHY state machine is running. It's running as a result of a previous dsa_user_open() -> ... -> phylink_start() -> phy_start() having been initiated by the user. The previous mdio_bus_phy_suspend() was supposed to have called phy_stop_machine(), but it didn't. So this is why the PHY is in state PHY_NOLINK by the time mdio_bus_phy_resume() runs. mdio_bus_phy_suspend() did not call phy_stop_machine() because for phylink, the phydev->adjust_link function pointer is NULL. This seems a technicality introduced by commit fddd91016d16 ("phylib: fix PAL state machine restart on resume"). That commit was written before phylink existed, and was intended to avoid crashing with consumer drivers which don't use the PHY state machine - phylink always does, when using a PHY. But phylink itself has historically not been developed with suspend/resume in mind, and apparently not tested too much in that scenario, allowing this bug to exist unnoticed for so long. Plus, prior to the WARN_ON(), it would have likely been invisible. This issue is not in fact restricted to type 2 DSA drivers (according to the above ad-hoc classification), but can be extrapolated to any MAC driver with phylink and MDIO-bus-managed PHY PM ops. DSA is just where the issue was reported. Assuming mac_managed_pm is set correctly, a quick search indicates the following other drivers might be affected: $ grep -Zlr PHYLINK_NETDEV drivers/ | xargs -0 grep -L mac_managed_pm drivers/net/ethernet/atheros/ag71xx.c drivers/net/ethernet/microchip/sparx5/sparx5_main.c drivers/net/ethernet/microchip/lan966x/lan966x_main.c drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c drivers/net/ethernet/freescale/dpaa/dpaa_eth.c drivers/net/ethernet/freescale/ucc_geth.c drivers/net/ethernet/freescale/enetc/enetc_pf_common.c drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c drivers/net/ethernet/marvell/mvneta.c drivers/net/ethernet/marvell/prestera/prestera_main.c drivers/net/ethernet/mediatek/mtk_eth_soc.c drivers/net/ethernet/altera/altera_tse_main.c drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c drivers/net/ethernet/meta/fbnic/fbnic_phylink.c drivers/net/ethernet/tehuti/tn40_phy.c drivers/net/ethernet/mscc/ocelot_net.c Make the existing conditions dependent on the PHY device having a phydev->phy_link_change() implementation equal to the default phy_link_change() provided by phylib. Otherwise, we implicitly know that the phydev has the phylink-provided phylink_phy_change() callback, and when phylink is used, the PHY state machine always needs to be stopped/ started on the suspend/resume path. The code is structured as such that if phydev->phy_link_change() is absent, it is a matter of time until the kernel will crash - no need to further complicate the test. Thus, for the situation where the PM is not managed b ---truncated---
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| Linux Linux | from 744d23c71af39c7dc77ac7c3cac87ae86a181a85 before 17eef1e44883845b9567afc893dc41e004c08d65, from 744d23c71af39c7dc77ac7c3cac87ae86a181a85 before 043aa41c43f8cb9cce75367ea07895ce68b5abb0, from 744d23c71af39c7dc77ac7c3cac87ae86a181a85 before a6ed6f8ec81b8ca7100dcd9e62bdbc0dff1b2259, from 744d23c71af39c7dc77ac7c3cac87ae86a181a85 before 54e5d00a8de6c13f6c01a94ed48025e882cd15f7, from 744d23c71af39c7dc77ac7c3cac87ae86a181a85 before bd4037d51d3f6667636a1383e78e48a5b7b60755, from 744d23c71af39c7dc77ac7c3cac87ae86a181a85 before fc75ea20ffb452652f0d4033f38fe88d7cfdae35, 47ac7b2f6a1ffef76e55a9ec146881a36673284b, 7dc0ed411de3450e75b2a9600b5742cbf0908167 and 3 more Not affected: before 6.0, from 6.1.168 up to 6.1.*, from 6.6.122 up to 6.6.*, from 6.12.24 up to 6.12.*, from 6.13.12 up to 6.13.*, from 6.14.3 up to 6.14.* | CVE List |
| linux linux_kernel | from 5.15.63 before 5.16, from 5.19.4 before 6.12.24, from 6.13 before 6.13.12, from 6.14 before 6.14.3, 6.15 | NVD |
Classification
SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.
What each source says
CVE List
In the Linux kernel, the following vulnerability has been resolved: net: phy: allow MDIO bus PM ops to start/stop state machine for phylink-controlled PHY DSA has 2 kinds of drivers: 1. Those who call dsa_switch_suspend() and dsa_switch_resume() from their device PM ops: qca8k-8xxx, bcm_sf2, microchip ksz 2. Those who don't: all others. The above methods should be optional. For type 1, dsa_switch_suspend() calls dsa_user_suspend() -> phylink_stop(), and dsa_switch_resume() calls dsa_user_resume() -> phylink_start(). These seem good candidates for setting mac_managed_pm = true because that is essentially its definition [1], but that does not seem to be the biggest problem for now, and is not what this change focuses on. Talking strictly about the 2nd category of DSA drivers here (which do not have MAC managed PM, meaning that for their attached PHYs, mdio_bus_phy_suspend() and mdio_bus_phy_resume() should run in full), I have noticed that the following warning from mdio_bus_phy_resume() is triggered: WARN_ON(phydev->state != PHY_HALTED && phydev->state != PHY_READY && phydev->state != PHY_UP); because the PHY state machine is running. It's running as a result of a previous dsa_user_open() -> ... -> phylink_start() -> phy_start() having been initiated by the user. The previous mdio_bus_phy_suspend() was supposed to have called phy_stop_machine(), but it didn't. So this is why the PHY is in state PHY_NOLINK by the time mdio_bus_phy_resume() runs. mdio_bus_phy_suspend() did not call phy_stop_machine() because for phylink, the phydev->adjust_link function pointer is NULL. This seems a technicality introduced by commit fddd91016d16 ("phylib: fix PAL state machine restart on resume"). That commit was written before phylink existed, and was intended to avoid crashing with consumer drivers which don't use the PHY state machine - phylink always does, when using a PHY. But phylink itself has historically not been developed with suspend/resume in mind, and apparently not tested too much in that scenario, allowing this bug to exist unnoticed for so long. Plus, prior to the WARN_ON(), it would have likely been invisible. This issue is not in fact restricted to type 2 DSA drivers (according to the above ad-hoc classification), but can be extrapolated to any MAC driver with phylink and MDIO-bus-managed PHY PM ops. DSA is just where the issue was reported. Assuming mac_managed_pm is set correctly, a quick search indicates the following other drivers might be affected: $ grep -Zlr PHYLINK_NETDEV drivers/ | xargs -0 grep -L mac_managed_pm drivers/net/ethernet/atheros/ag71xx.c drivers/net/ethernet/microchip/sparx5/sparx5_main.c drivers/net/ethernet/microchip/lan966x/lan966x_main.c drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c drivers/net/ethernet/freescale/dpaa/dpaa_eth.c drivers/net/ethernet/freescale/ucc_geth.c drivers/net/ethernet/freescale/enetc/enetc_pf_common.c drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c drivers/net/ethernet/marvell/mvneta.c drivers/net/ethernet/marvell/prestera/prestera_main.c drivers/net/ethernet/mediatek/mtk_eth_soc.c drivers/net/ethernet/altera/altera_tse_main.c drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c drivers/net/ethernet/meta/fbnic/fbnic_phylink.c drivers/net/ethernet/tehuti/tn40_phy.c drivers/net/ethernet/mscc/ocelot_net.c Make the existing conditions dependent on the PHY device having a phydev->phy_link_change() implementation equal to the default phy_link_change() provided by phylib. Otherwise, we implicitly know that the phydev has the phylink-provided phylink_phy_change() callback, and when phylink is used, the PHY state machine always needs to be stopped/ started on the suspend/resume path. The code is structured as such that if phydev->phy_link_change() is absent, it is a matter of time until the kernel will crash - no need to further complicate the test. Thus, for the situation where the PM is not managed b ---truncated---
NVD (es)
En el kernel de Linux, se ha resuelto la siguiente vulnerabilidad: net: phy: permite que las operaciones PM del bus MDIO inicien o detengan la máquina de estados para PHY controlada por phylink DSA tiene 2 tipos de controladores: 1. Los que llaman a dsa_switch_suspend() y dsa_switch_resume() desde las operaciones PM de su dispositivo: qca8k-8xxx, bcm_sf2, microchip ksz 2. Los que no lo hacen: todos los demás. Los métodos anteriores deberían ser opcionales. Para el tipo 1, dsa_switch_suspend() llama a dsa_user_suspend() -> phylink_stop() y dsa_switch_resume() llama a dsa_user_resume() -> phylink_start(). Estos parecen buenos candidatos para establecer mac_managed_pm = true porque esa es esencialmente su definición [1], pero ese no parece ser el mayor problema por ahora y no es en lo que se centra este cambio. Hablando estrictamente sobre la segunda categoría de controladores DSA (que no tienen PM administrado por MAC, lo que significa que para sus PHYs conectados, mdio_bus_phy_suspend() y mdio_bus_phy_resume() deben ejecutarse por completo), he notado que se activa la siguiente advertencia de mdio_bus_phy_resume(): WARN_ON(phydev->state != PHY_HALTED && phydev->state != PHY_READY && phydev->state != PHY_UP); porque la máquina de estados PHY está en ejecución. Se está ejecutando como resultado de un dsa_user_open() -> ... -> phylink_start() -> phy_start() previo iniciado por el usuario. El mdio_bus_phy_suspend() anterior debería haber llamado a phy_stop_machine(), pero no lo hizo. Por eso, el PHY está en estado PHY_NOLINK cuando se ejecuta mdio_bus_phy_resume(). mdio_bus_phy_suspend() no llamó a phy_stop_machine() porque, para phylink, el puntero a la función phydev->adjust_link es NULL. Esto parece ser un tecnicismo introducido por el commit fddd91016d16 ("phylib: corrección del reinicio de la máquina de estados PAL al reanudar"). Esta confirmación se escribió antes de que existiera phylink y su objetivo era evitar fallos con controladores de consumidor que no utilizan la máquina de estados PHY; phylink siempre lo hace al usar una PHY. Sin embargo, phylink no se ha desarrollado históricamente con la suspensión/reanudación en mente, y aparentemente no se ha probado demasiado en ese escenario, lo que ha permitido que este error pase desapercibido durante tanto tiempo. Además, antes de WARN_ON(), probablemente habría sido invisible. De hecho, este problema no se limita a los controladores DSA de tipo 2 (según la clasificación ad hoc anterior), sino que se puede extrapolar a cualquier controlador MAC con phylink y operaciones de PM PHY gestionadas por bus MDIO. DSA es justo donde se reportó el problema. Suponiendo que mac_managed_pm esté configurado correctamente, una búsqueda rápida indica que los siguientes controladores podrían estar afectados: $ grep -Zlr PHYLINK_NETDEV drivers/ | xargs -0 grep -L mac_managed_pm drivers/net/ethernet/atheros/ag71xx.c drivers/net/ethernet/microchip/sparx5/sparx5_main.c drivers/net/ethernet/microchip/lan966x/lan966x_main.c drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c drivers/net/ethernet/freescale/dpaa/dpaa_eth.c drivers/net/ethernet/freescale/ucc_geth.c drivers/net/ethernet/freescale/enetc/enetc_pf_common.c drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c drivers/net/ethernet/marvell/mvneta.c Haga que las condiciones existentes dependan de que el dispositivo PHY tenga una implementación de phydev->phy_link_change() igual al phy_link_change() predeterminado proporcionado por phylib. De lo contrario, sabemos implícitamente que phydev cuenta con la función de devolución de llamada phylink_phy_change() proporcionada por phylink, y cuando se usa phylink, la máquina de estados PHY siempre debe detenerse/iniciar en la ruta de suspensión/reinicio. El código está estructurado de tal manera que, si phydev->phy_link_change() no está presente, es cuestión de tiempo hasta que el kernel se bloquee; no es necesario complicar aún más la prueba. Por lo tanto, si el PM no se gestiona, se trunca.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2025-37945 changed 2026-11-10 | CVE Terms of Use |
| NVD | CVE-2025-37945 changed 2026-11-10 | Public domain |