* [PATCH net] phylib: fix potential use-after-free
@ 2022-01-19 16:27 Marek Behún
2022-01-20 0:27 ` Andrew Lunn
2022-01-21 6:00 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Marek Behún @ 2022-01-19 16:27 UTC (permalink / raw)
To: netdev
Cc: Russell King, Andrew Lunn, Sergei Shtylyov, David S . Miller,
Marek Behún
Commit bafbdd527d56 ("phylib: Add device reset GPIO support") added call
to phy_device_reset(phydev) after the put_device() call in phy_detach().
The comment before the put_device() call says that the phydev might go
away with put_device().
Fix potential use-after-free by calling phy_device_reset() before
put_device().
Fixes: bafbdd527d56 ("phylib: Add device reset GPIO support")
Signed-off-by: Marek Behún <kabel@kernel.org>
---
drivers/net/phy/phy_device.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 74d8e1dc125f..ce0bb5951b81 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1746,6 +1746,9 @@ void phy_detach(struct phy_device *phydev)
phy_driver_is_genphy_10g(phydev))
device_release_driver(&phydev->mdio.dev);
+ /* Assert the reset signal */
+ phy_device_reset(phydev, 1);
+
/*
* The phydev might go away on the put_device() below, so avoid
* a use-after-free bug by reading the underlying bus first.
@@ -1757,9 +1760,6 @@ void phy_detach(struct phy_device *phydev)
ndev_owner = dev->dev.parent->driver->owner;
if (ndev_owner != bus->owner)
module_put(bus->owner);
-
- /* Assert the reset signal */
- phy_device_reset(phydev, 1);
}
EXPORT_SYMBOL(phy_detach);
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] phylib: fix potential use-after-free
2022-01-19 16:27 [PATCH net] phylib: fix potential use-after-free Marek Behún
@ 2022-01-20 0:27 ` Andrew Lunn
2022-01-21 6:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2022-01-20 0:27 UTC (permalink / raw)
To: Marek Behún; +Cc: netdev, Russell King, Sergei Shtylyov, David S . Miller
On Wed, Jan 19, 2022 at 05:27:48PM +0100, Marek Behún wrote:
> Commit bafbdd527d56 ("phylib: Add device reset GPIO support") added call
> to phy_device_reset(phydev) after the put_device() call in phy_detach().
>
> The comment before the put_device() call says that the phydev might go
> away with put_device().
>
> Fix potential use-after-free by calling phy_device_reset() before
> put_device().
>
> Fixes: bafbdd527d56 ("phylib: Add device reset GPIO support")
> Signed-off-by: Marek Behún <kabel@kernel.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] phylib: fix potential use-after-free
2022-01-19 16:27 [PATCH net] phylib: fix potential use-after-free Marek Behún
2022-01-20 0:27 ` Andrew Lunn
@ 2022-01-21 6:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-01-21 6:00 UTC (permalink / raw)
To: =?utf-8?q?Marek_Beh=C3=BAn_=3Ckabel=40kernel=2Eorg=3E?=
Cc: netdev, rmk+kernel, andrew, sergei.shtylyov, davem
Hello:
This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:
On Wed, 19 Jan 2022 17:27:48 +0100 you wrote:
> Commit bafbdd527d56 ("phylib: Add device reset GPIO support") added call
> to phy_device_reset(phydev) after the put_device() call in phy_detach().
>
> The comment before the put_device() call says that the phydev might go
> away with put_device().
>
> Fix potential use-after-free by calling phy_device_reset() before
> put_device().
>
> [...]
Here is the summary with links:
- [net] phylib: fix potential use-after-free
https://git.kernel.org/netdev/net/c/cbda1b166875
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-01-21 6:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-19 16:27 [PATCH net] phylib: fix potential use-after-free Marek Behún
2022-01-20 0:27 ` Andrew Lunn
2022-01-21 6:00 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).