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: <20190121164036.GF8620@lunn.ch>
Date:   Mon, 21 Jan 2019 17:40:36 +0100
From:   Andrew Lunn <andrew@...n.ch>
To:     Heiner Kallweit <hkallweit1@...il.com>
Cc:     Florian Fainelli <f.fainelli@...il.com>,
        David Miller <davem@...emloft.net>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: Re: [PATCH net-next v2 2/4] net: phy: warn if phy_start is called
 from invalid state

On Sun, Jan 20, 2019 at 10:02:13AM +0100, Heiner Kallweit wrote:
> phy_start() should be called from states PHY_READY or PHY_HALTED only.
> Check for this to detect misbehaving drivers. Also the state machine
> should be started only when being called from one of the valid states.
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@...il.com>
> ---
>  drivers/net/phy/phy.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 3df6aadc5..fd928979b 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -861,9 +861,16 @@ void phy_start(struct phy_device *phydev)
>  
>  	mutex_lock(&phydev->lock);
>  
> +	if (phydev->state != PHY_READY && phydev->state != PHY_HALTED) {
> +		WARN(1, "called from state %s\n",
> +		     phy_state_to_str(phydev->state));
> +		goto out;
> +	}

Hi Heiner

Warning is good. But jumping to out i'm not so sure about. Drivers
which are 'broken' work well enough that users don't know they are
broken. But jumping to out is going to really break them. It seems
better to have the kernel only warn for one cycle so we find out about
such drivers and fix them, and later add the goto out.

     Andrew

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ