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: <20200301122211.GA32253@localhost>
Date:   Sun, 1 Mar 2020 04:22:11 -0800
From:   Richard Cochran <richardcochran@...il.com>
To:     Michael Walle <michael@...le.cc>
Cc:     netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
        Andrew Lunn <andrew@...n.ch>,
        Florian Fainelli <f.fainelli@...il.com>,
        Heiner Kallweit <hkallweit1@...il.com>,
        Russell King <linux@...linux.org.uk>,
        "David S . Miller" <davem@...emloft.net>
Subject: Re: [RFC PATCH v2 2/2] net: phy: at803x: add PTP support for AR8031

On Fri, Feb 28, 2020 at 07:02:26PM +0100, Michael Walle wrote:

> +static int at8031_rtc_adjust(struct phy_device *phydev, s64 delta)
> +{
> +	struct timespec64 ts = ns_to_timespec64(delta);
> +	int ret;

Here the 'ts' is written in multiple steps,

> +	ret = phy_write_mmd(phydev, MDIO_MMD_PCS,
> +			    AT8031_MMD3_RTC_OFFSET_SEC_2,
> +			    (ts.tv_sec >> 32) & 0xffff);
> +	if (ret)
> +		return ret;
> +
> +	ret = phy_write_mmd(phydev, MDIO_MMD_PCS,
> +			    AT8031_MMD3_RTC_OFFSET_SEC_1,
> +			    (ts.tv_sec >> 16) & 0xffff);
> +	if (ret)
> +		return ret;
> +
> +	ret = phy_write_mmd(phydev, MDIO_MMD_PCS,
> +			    AT8031_MMD3_RTC_OFFSET_SEC_0,
> +			    ts.tv_sec & 0xffff);
> +	if (ret)
> +		return ret;
> +
> +	ret = phy_write_mmd(phydev, MDIO_MMD_PCS,
> +			    AT8031_MMD3_RTC_OFFSET_NSEC_1,
> +			    (ts.tv_nsec >> 16) & 0xffff);
> +	if (ret)
> +		return ret;
> +
> +	ret = phy_write_mmd(phydev, MDIO_MMD_PCS,
> +			    AT8031_MMD3_RTC_OFFSET_NSEC_0,
> +			    ts.tv_nsec & 0xffff);
> +	if (ret)
> +		return ret;
> +
> +	return phy_write_mmd(phydev, MDIO_MMD_PCS, AT8031_MMD3_RTC_ADJUST,
> +			     AT8031_RTC_ADJUST);
> +}

...

> +static int at8031_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
> +{
> +	struct at803x_priv *priv =
> +		container_of(ptp, struct at803x_priv, ptp_info);
> +	struct phy_device *phydev = priv->phydev;
> +
> +	return at8031_rtc_adjust(phydev, delta);
> +}

... and here there is no locking.  You would need a mutex here and
elsewhere to prevent multiple readers/writers from accessing the
device registers asynchronously.

(I know this is a just a RFC and that there are bigger problems with
the HW, but just saying.)

Thanks,
Richard


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ