lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250901103624.hv3vnkhjxvp2ep7r@skbuf>
Date: Mon, 1 Sep 2025 13:36:24 +0300
From: Vladimir Oltean <vladimir.oltean@....com>
To: "Russell King (Oracle)" <linux@...linux.org.uk>
Cc: Andrew Lunn <andrew@...n.ch>, Heiner Kallweit <hkallweit1@...il.com>,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>, netdev@...r.kernel.org,
	Paolo Abeni <pabeni@...hat.com>
Subject: Re: [PATCH net] net: phy: fix phy_uses_state_machine()

On Mon, Sep 01, 2025 at 11:05:54AM +0100, Russell King (Oracle) wrote:
> Well, having spent considerable time writing and rewriting the damn
> commit message, this is what I'm now using, which I think covers the
> problem in sufficient detail.
> 
> >>>>>>
> net: phy: fix phy_uses_state_machine()
> 
> The blamed commit changed the conditions which phylib uses to stop
> and start the state machine in the suspend and resume paths, and
> while improving it, has caused two issues.
> 
> The original code used this test:
> 
>         phydev->attached_dev && phydev->adjust_link
> 
> and if true, the paths would handle the PHY state machine. This test
> evaluates true for normal drivers that are using phylib directly
> while the PHY is attached to the network device, but false in all
> other cases, which include the following cases:
> 
> - when the PHY has never been attached to a network device.
> - when the PHY has been detached from a network device (as phy_detach()
>    sets phydev->attached_dev to NULL, phy_disconnect() calls
>    phy_detach() and additionally sets phydev->adjust_link NULL.)
> - when phylink is using the driver (as phydev->adjust_link is NULL.)
> 
> Only the third case was incorrect, and the blamed commit attempted to
> fix this by changing this test to (simplified for brevity, see
> phy_uses_state_machine()):
> 
>         phydev->phy_link_change == phy_link_change ?
>                 phydev->attached_dev && phydev->adjust_link : true
> 
> However, this also incorrectly evaluates true in the first two cases.
> 
> Fix the first case by ensuring that phy_uses_state_machine() returns
> false when phydev->phy_link_change is NULL.
> 
> Fix the second case by ensuring that phydev->phy_link_change is set to
> NULL when phy_detach() is called.
> <<<<<<

The new explanation and the placement of the function pointer clearing
make sense, thanks. Maybe add one last sentence at the end: "This covers
both the phylink_bringup_phy() error path, as well as the normal
phylink_disconnect_phy() path."

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ