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: <DA7N0K4FSI14.QARGA1ALU2XV@bootlin.com>
Date: Wed, 28 May 2025 10:06:23 +0200
From: Alexis Lothoré <alexis.lothore@...tlin.com>
To: "Maxime Chevallier" <maxime.chevallier@...tlin.com>
Cc: "Alexandre Torgue" <alexandre.torgue@...s.st.com>, "Jose Abreu"
 <joabreu@...opsys.com>, "Andrew Lunn" <andrew+netdev@...n.ch>, "David S.
 Miller" <davem@...emloft.net>, "Eric Dumazet" <edumazet@...gle.com>, "Jakub
 Kicinski" <kuba@...nel.org>, "Paolo Abeni" <pabeni@...hat.com>, "Maxime
 Coquelin" <mcoquelin.stm32@...il.com>, "Richard Cochran"
 <richardcochran@...il.com>, "Phil Reid" <preid@...ctromag.com.au>, "Thomas
 Petazzoni" <thomas.petazzoni@...tlin.com>, <netdev@...r.kernel.org>,
 <linux-stm32@...md-mailman.stormreply.com>,
 <linux-arm-kernel@...ts.infradead.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] net: stmmac: add explicit check and error on invalid
 PTP clock rate

Hey Maxime,

On Tue May 27, 2025 at 6:31 PM CEST, Maxime Chevallier wrote:
> Hi Alexis,
>
> On Tue, 27 May 2025 08:33:44 +0200
> Alexis Lothoré <alexis.lothore@...tlin.com> wrote:

[...]

>> +	if (!priv->plat->clk_ptp_rate) {
>> +		netdev_err(priv->dev, "Invalid PTP clock rate");
>> +		return -EINVAL;
>> +	}
>> +
>>  	stmmac_config_hw_tstamping(priv, priv->ptpaddr, systime_flags);
>>  	priv->systime_flags = systime_flags;
>
> This may be some nitpick that can be addressed at a later point, but we
> now have a guarantee that when stmmac_ptp_register() gets called,
> priv->ptp_clk_rate is non-zero, right ? If so, we can drop the test in
> said function :
>
> 	if (priv->plat->has_gmac4 && priv->plat->clk_ptp_rate)
> 		priv->plat->cdc_error_adj = (2 * NSEC_PER_SEC) / priv->plat->clk_ptp_rate;

You are right, my series makes this check a duplicate, I'll remove it.

> There is another spot in the code, like in the EST handling, where we
> divide by priv->plat->ptp_clk_rate :
>
> stmmac_adjust_time(...)
> 	stmmac_est_configure(priv, priv, priv->est,
> 			     priv->plat->clk_ptp_rate)
> 		.est_configure()
> 			ctrl |= ((NSEC_PER_SEC / ptp_rate) [...]
>
> Maybe we should fail EST configuration as well if ptp_clk_rate is 0
> (probably in stmmac_tc.c's tc_taprio_configure or in the
> .est_configure). That can be a step for later as well, as I don't know
> if the setup you found this bug on even supports taprio/EST, and setups
> that do didn't seem to encounter the bug yet.

I guess you are right as well, it may not make sense to try to configure
EST if we have a bogus clk_ptp_rate value. est_configure seems to be called
in both tc_taprio_configure and stmmac_adjust_time, so I'll add the check
in est_configure.

Thanks,

Alexis

-- 
Alexis Lothoré, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ