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] [day] [month] [year] [list]
Message-ID: <20250109170222.GM7706@kernel.org>
Date: Thu, 9 Jan 2025 17:02:22 +0000
From: Simon Horman <horms@...nel.org>
To: "Russell King (Oracle)" <rmk+kernel@...linux.org.uk>
Cc: Andrew Lunn <andrew@...n.ch>, Heiner Kallweit <hkallweit1@...il.com>,
	Alexander Couzens <lynxis@...0.eu>,
	Alexander Duyck <alexanderduyck@...com>,
	Andrew Lunn <andrew+netdev@...n.ch>,
	AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>,
	Arınç ÜNAL <arinc.unal@...nc9.com>,
	Claudiu Beznea <claudiu.beznea@...on.dev>,
	Daniel Golle <daniel@...rotopia.org>,
	Daniel Machon <daniel.machon@...rochip.com>,
	"David S. Miller" <davem@...emloft.net>,
	DENG Qingfang <dqfext@...il.com>,
	Eric Dumazet <edumazet@...gle.com>,
	Florian Fainelli <florian.fainelli@...adcom.com>,
	Horatiu Vultur <horatiu.vultur@...rochip.com>,
	Ioana Ciornei <ioana.ciornei@....com>,
	Jakub Kicinski <kuba@...nel.org>,
	Jose Abreu <Jose.Abreu@...opsys.com>, kernel-team@...a.com,
	Lars Povlsen <lars.povlsen@...rochip.com>,
	linux-arm-kernel@...ts.infradead.org,
	linux-mediatek@...ts.infradead.org,
	Madalin Bucur <madalin.bucur@....com>,
	Marcin Wojtas <marcin.s.wojtas@...il.com>,
	Matthias Brugger <matthias.bgg@...il.com>,
	Michal Simek <michal.simek@....com>, netdev@...r.kernel.org,
	Nicolas Ferre <nicolas.ferre@...rochip.com>,
	Paolo Abeni <pabeni@...hat.com>,
	Radhey Shyam Pandey <radhey.shyam.pandey@....com>,
	Sean Anderson <sean.anderson@...o.com>,
	Sean Wang <sean.wang@...iatek.com>,
	Steen Hegelund <Steen.Hegelund@...rochip.com>,
	Taras Chornyi <taras.chornyi@...ision.eu>,
	UNGLinuxDriver@...rochip.com, Vladimir Oltean <olteanv@...il.com>,
	Eric Woudstra <ericwouds@...il.com>
Subject: Re: [PATCH net-next 1/5] net: phylink: use pcs_neg_mode in
 phylink_mac_pcs_get_state()

On Thu, Jan 09, 2025 at 03:15:17PM +0000, Russell King (Oracle) wrote:
> As in-band AN no longer just depends on MLO_AN_INBAND + Autoneg bit,
> we need to take account of the pcs_neg_mode when deciding how to
> initialise the speed, duplex and pause state members before calling
> into the .pcs_neg_mode() method. Add this.
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@...linux.org.uk>
> ---
>  drivers/net/phy/phylink.c | 22 ++++++++++++++++------
>  1 file changed, 16 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
> index 31754d5fd659..d08cdbbbbc1e 100644
> --- a/drivers/net/phy/phylink.c
> +++ b/drivers/net/phy/phylink.c
> @@ -1492,12 +1492,24 @@ static int phylink_change_inband_advert(struct phylink *pl)
>  static void phylink_mac_pcs_get_state(struct phylink *pl,
>  				      struct phylink_link_state *state)
>  {
> +	struct phylink_pcs *pcs;
> +	bool autoneg;
> +
>  	linkmode_copy(state->advertising, pl->link_config.advertising);
>  	linkmode_zero(state->lp_advertising);
>  	state->interface = pl->link_config.interface;
>  	state->rate_matching = pl->link_config.rate_matching;
> -	if (linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
> -			      state->advertising)) {
> +	state->an_complete = 0;
> +	state->link = 1;
> +
> +	pcs = pl->pcs;
> +	if (pcs->neg_mode)
> +		autoneg = pl->pcs_neg_mode == PHYLINK_PCS_NEG_INBAND_ENABLED;
> +	else
> +		autoneg = linkmode_test_bit(ETHTOOL_LINK_MODE_Autoneg_BIT,
> +					    state->advertising);
> +
> +	if (autoneg) {
>  		state->speed = SPEED_UNKNOWN;
>  		state->duplex = DUPLEX_UNKNOWN;
>  		state->pause = MLO_PAUSE_NONE;
> @@ -1506,11 +1518,9 @@ static void phylink_mac_pcs_get_state(struct phylink *pl,
>  		state->duplex = pl->link_config.duplex;
>  		state->pause = pl->link_config.pause;
>  	}
> -	state->an_complete = 0;
> -	state->link = 1;
>  
> -	if (pl->pcs)
> -		pl->pcs->ops->pcs_get_state(pl->pcs, state);
> +	if (pcs)
> +		pcs->ops->pcs_get_state(pcs, state);
>  	else
>  		state->link = 0;

Hi Russell,

Here it is assumed that pcs may be NULL.
But it is dereferenced unconditionally immediately
after it is assigned above.

This seems inconsistent.

Flagged by Smatch.

>  }
> -- 
> 2.30.2
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ