Repository navigation
generic: pse-pd: replace notifier PSE patch to fix rtnl deadlock - #24945
Conversation
1ed0e7b to
d24f906
Compare
|
@abajk - I changed it again to support the module builds... My first version was buggy. If you mind testing again - I would highly appreciate it :) |
4165769 to
ae19f98
Compare
|
Please fix these small issues raised by the AI. If it fixes the issue for lantiq, I think we can merge it as pending. Then you can take the review here upstream and once it's merged there, the pending patches can be replaced. |
|
Thx for getting back to me! I am still waiting for @abajk next tests, because the latest version has too many changes... |
Will do a test. However, I can only verify that there is no deadlock during system boot. Unfortunately, I shorted some PHY pins, and the PHY on my board isn't fully functional. So there won't be a traffic test at this moment. |
v5 works fine :) |
thx for your help! |
|
I forgot to mention that you should rebase these changes and resolve conflicts |
ae19f98 to
19a5218
Compare
19a5218 to
ccae34b
Compare
|
ping @jonasjelonek :) |
…eadlock The notifier patch attached phydev->psec under rtnl_lock() inside phy_device_register(). Drivers that register their MDIO bus from ndo_init() (like the lantiq etop) already hold rtnl at that point, so the attach tried to take rtnl a second time and deadlocked on probe. Aleksander hit this on lantiq arx100. Rework 896-03 to use a dedicated mutex instead of rtnl for the psec attach, the notifier walks and the ethtool PSE paths, so there is no rtnl recursion any more. The mutex lives in pse_core.c rather than in phylib: net/ethtool is always built into vmlinux while PHYLIB is tristate, so net/ethtool/pse-pd.c must not call a phylib export or CONFIG_PHYLIB=m fails to link. PSE_CONTROLLER is bool, so pse_core is either in vmlinux or absent and every config can reach pse_phy_lock()/pse_phy_unlock(); !PSE_CONTROLLER gets no-op stubs in pse.h. phy_device_register_locked() is gone with it. It only existed because the attach took rtnl, and was identical to phy_device_register() apart from an ASSERT_RTNL(), so sfp.c calls phy_device_register() again and include/linux/phy.h stays untouched. Also refresh 897-01 and 897-02, whose hunks shift. Tested-by: Aleksander Jan Bajkowski <[email protected]> Signed-off-by: Carlo Szelinsky <[email protected]> Link: openwrt#24945 Signed-off-by: Jonas Jelonek <[email protected]>
ccae34b to
e87bdaf
Compare
|
Thanks! Rebased on top of main and merged! |
…eadlock The notifier patch attached phydev->psec under rtnl_lock() inside phy_device_register(). Drivers that register their MDIO bus from ndo_init() (like the lantiq etop) already hold rtnl at that point, so the attach tried to take rtnl a second time and deadlocked on probe. Aleksander hit this on lantiq arx100. Rework 896-03 to use a dedicated mutex instead of rtnl for the psec attach, the notifier walks and the ethtool PSE paths, so there is no rtnl recursion any more. The mutex lives in pse_core.c rather than in phylib: net/ethtool is always built into vmlinux while PHYLIB is tristate, so net/ethtool/pse-pd.c must not call a phylib export or CONFIG_PHYLIB=m fails to link. PSE_CONTROLLER is bool, so pse_core is either in vmlinux or absent and every config can reach pse_phy_lock()/pse_phy_unlock(); !PSE_CONTROLLER gets no-op stubs in pse.h. phy_device_register_locked() is gone with it. It only existed because the attach took rtnl, and was identical to phy_device_register() apart from an ASSERT_RTNL(), so sfp.c calls phy_device_register() again and include/linux/phy.h stays untouched. Also refresh 897-01 and 897-02, whose hunks shift. Tested-by: Aleksander Jan Bajkowski <[email protected]> Signed-off-by: Carlo Szelinsky <[email protected]> Link: openwrt#24945 Signed-off-by: Jonas Jelonek <[email protected]>
…eadlock The notifier patch attached phydev->psec under rtnl_lock() inside phy_device_register(). Drivers that register their MDIO bus from ndo_init() (like the lantiq etop) already hold rtnl at that point, so the attach tried to take rtnl a second time and deadlocked on probe. Aleksander hit this on lantiq arx100. Rework 896-03 to use a dedicated mutex instead of rtnl for the psec attach, the notifier walks and the ethtool PSE paths, so there is no rtnl recursion any more. The mutex lives in pse_core.c rather than in phylib: net/ethtool is always built into vmlinux while PHYLIB is tristate, so net/ethtool/pse-pd.c must not call a phylib export or CONFIG_PHYLIB=m fails to link. PSE_CONTROLLER is bool, so pse_core is either in vmlinux or absent and every config can reach pse_phy_lock()/pse_phy_unlock(); !PSE_CONTROLLER gets no-op stubs in pse.h. phy_device_register_locked() is gone with it. It only existed because the attach took rtnl, and was identical to phy_device_register() apart from an ASSERT_RTNL(), so sfp.c calls phy_device_register() again and include/linux/phy.h stays untouched. Also refresh 897-01 and 897-02, whose hunks shift. Tested-by: Aleksander Jan Bajkowski <[email protected]> Signed-off-by: Carlo Szelinsky <[email protected]> Link: openwrt#24945 Signed-off-by: Jonas Jelonek <[email protected]>
…eadlock The notifier patch attached phydev->psec under rtnl_lock() inside phy_device_register(). Drivers that register their MDIO bus from ndo_init() (like the lantiq etop) already hold rtnl at that point, so the attach tried to take rtnl a second time and deadlocked on probe. Aleksander hit this on lantiq arx100. Rework 896-03 to use a dedicated mutex instead of rtnl for the psec attach, the notifier walks and the ethtool PSE paths, so there is no rtnl recursion any more. The mutex lives in pse_core.c rather than in phylib: net/ethtool is always built into vmlinux while PHYLIB is tristate, so net/ethtool/pse-pd.c must not call a phylib export or CONFIG_PHYLIB=m fails to link. PSE_CONTROLLER is bool, so pse_core is either in vmlinux or absent and every config can reach pse_phy_lock()/pse_phy_unlock(); !PSE_CONTROLLER gets no-op stubs in pse.h. phy_device_register_locked() is gone with it. It only existed because the attach took rtnl, and was identical to phy_device_register() apart from an ASSERT_RTNL(), so sfp.c calls phy_device_register() again and include/linux/phy.h stays untouched. Also refresh 897-01 and 897-02, whose hunks shift. Tested-by: Aleksander Jan Bajkowski <[email protected]> Signed-off-by: Carlo Szelinsky <[email protected]> Link: openwrt/openwrt#24945 Signed-off-by: Jonas Jelonek <[email protected]>
…eadlock The notifier patch attached phydev->psec under rtnl_lock() inside phy_device_register(). Drivers that register their MDIO bus from ndo_init() (like the lantiq etop) already hold rtnl at that point, so the attach tried to take rtnl a second time and deadlocked on probe. Aleksander hit this on lantiq arx100. Rework 896-03 to use a dedicated mutex instead of rtnl for the psec attach, the notifier walks and the ethtool PSE paths, so there is no rtnl recursion any more. The mutex lives in pse_core.c rather than in phylib: net/ethtool is always built into vmlinux while PHYLIB is tristate, so net/ethtool/pse-pd.c must not call a phylib export or CONFIG_PHYLIB=m fails to link. PSE_CONTROLLER is bool, so pse_core is either in vmlinux or absent and every config can reach pse_phy_lock()/pse_phy_unlock(); !PSE_CONTROLLER gets no-op stubs in pse.h. phy_device_register_locked() is gone with it. It only existed because the attach took rtnl, and was identical to phy_device_register() apart from an ASSERT_RTNL(), so sfp.c calls phy_device_register() again and include/linux/phy.h stays untouched. Also refresh 897-01 and 897-02, whose hunks shift. Tested-by: Aleksander Jan Bajkowski <[email protected]> Signed-off-by: Carlo Szelinsky <[email protected]> Link: openwrt#24945 Signed-off-by: Jonas Jelonek <[email protected]>
…eadlock The notifier patch attached phydev->psec under rtnl_lock() inside phy_device_register(). Drivers that register their MDIO bus from ndo_init() (like the lantiq etop) already hold rtnl at that point, so the attach tried to take rtnl a second time and deadlocked on probe. Aleksander hit this on lantiq arx100. Rework 896-03 to use a dedicated mutex instead of rtnl for the psec attach, the notifier walks and the ethtool PSE paths, so there is no rtnl recursion any more. The mutex lives in pse_core.c rather than in phylib: net/ethtool is always built into vmlinux while PHYLIB is tristate, so net/ethtool/pse-pd.c must not call a phylib export or CONFIG_PHYLIB=m fails to link. PSE_CONTROLLER is bool, so pse_core is either in vmlinux or absent and every config can reach pse_phy_lock()/pse_phy_unlock(); !PSE_CONTROLLER gets no-op stubs in pse.h. phy_device_register_locked() is gone with it. It only existed because the attach took rtnl, and was identical to phy_device_register() apart from an ASSERT_RTNL(), so sfp.c calls phy_device_register() again and include/linux/phy.h stays untouched. Also refresh 897-01 and 897-02, whose hunks shift. Tested-by: Aleksander Jan Bajkowski <[email protected]> Signed-off-by: Carlo Szelinsky <[email protected]> Link: openwrt#24945 Signed-off-by: Jonas Jelonek <[email protected]>
896-03-net-phy-own-phydev-psec-via-PSE-notifier-and-remove-.patch, added in 96ecf8d ("generic: pse-pd: add patches for module-based PSE drivers"), attachesphydev->psecunderrtnl_lock()insidephy_device_register().Drivers that register their MDIO bus from
ndo_init()already hold rtnl at that point, so the attach takes rtnl a second time and the board deadlocks during boot. The lantiq etop driver does exactly this (ltq_etop_init()->ltq_etop_mdio_init()->mdiobus_register()), which is why it hangs there and not on the targets the patch was developed on.Reported by @abajk in #24650 on an AVM FRITZ!Box 7320 (xway); bisected to 96ecf8d, and dropping 896-03 made the board boot.
This replaces 896-03 with v5 of the upstream series, which uses a dedicated mutex instead of rtnl for the psec attach, the notifier walks and the ethtool PSE paths. No rtnl recursion, so the deadlock is gone. The ethtool paths take the same lock, so the use-after-free that rtnl was also guarding against does not come back. The approach was discussed with kernel maintainers but has not been fully approved.
Upstream report: https://lore.kernel.org/netdev/[email protected]/
Upstream v5: https://lore.kernel.org/all/[email protected]/
Tested by @abajk on lantiq arx100.
@jonasjelonek should we wait for further feedback from the maintainers or do we merge this already to unblock @abajk ...?