Re:Re: Re: [PATCH net] net: phy: micrel: Fix potential shared PHC use-after-free

From: 李广硕

Date: Thu Nov 19 2026 - 07:39:59 EST




Hi Andrew,

Thanks for the review.

From: Andrew Lunn <andrew@xxxxxxx>
Date: 2026-11-09 21:24:33
To: "李广硕" <liguangshuo@xxxxxxxxxxxxxxx>
Cc: Heiner Kallweit <hkallweit1@xxxxxxxxx>,Russell King <linux@xxxxxxxxxxxxxxx>,"David S. Miller" <davem@xxxxxxxxxxxxx>,Eric Dumazet <edumazet@xxxxxxxxxx>,Jakub Kicinski <kuba@xxxxxxxxxx>,Paolo Abeni <pabeni@xxxxxxxxxx>,netdev@xxxxxxxxxxxxxxx,linux-kernel@xxxxxxxxxxxxxxx
Subject: Re: Re: [PATCH net] net: phy: micrel: Fix potential shared PHC use-after-free>> >.probe() and .remove() should be opposites of each other. What happens
>> >if you do that?
>> >
>> > Andrew
>> >
>> >---
>> >pw-bot: cr
>> >
>>
>> On LAN8814, one PHY registers the shared PHC and owns its pin array.
>> If that PHY unregisters the clock in .remove(), the clock goes away
>> before the pins are freed. If another port is still bound, it loses
>> access to the PHC. I added the handoff in v1 to keep the clock
>> available in that case.
>>
>> I'll rework this around the PHY that registered the clock. I'll check
>> how the remaining ports report the PHC after that PHY unbinds, and
>> what happens if it binds again while another port is still up.
>
>That is not what i asked for:
>
>.probe() and .remove() should be opposites of each other.
>
>Take the probe function and reverse the order of the lines.
>
>Then reverse what each function does.
>
> Andrew
>

Probe registers the PHC after allocating its pins, then sets up
timestamping on the port. Reading that backwards, I'd tear down port
timestamping first, then unregister the clock while its pins are still
valid.

On LAN8814, if the registering PHY unbinds first, the other ports would
lose access to the PHC. Is that the behaviour you'd expect? If so, I'll
send a v2 that pairs registration and removal on the same PHY.

Thanks,
Guangshuo