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]
Date:   Fri, 28 Oct 2022 09:20:47 -0700
From:   Jakub Kicinski <kuba@...nel.org>
To:     Andrew Lunn <andrew@...n.ch>
Cc:     davem@...emloft.net, netdev@...r.kernel.org, edumazet@...gle.com,
        pabeni@...hat.com, corbet@....net, michael.chan@...adcom.com,
        hkallweit1@...il.com, linux@...linux.org.uk,
        huangguangbin2@...wei.com, chenhao288@...ilicon.com,
        moshet@...dia.com, linux@...pel-privat.de,
        linux-doc@...r.kernel.org
Subject: Re: [PATCH net-next v2] ethtool: linkstate: add a statistic for PHY
 down events

On Fri, 28 Oct 2022 14:18:11 +0200 Andrew Lunn wrote:
> > @@ -67,6 +67,7 @@ static void phy_link_down(struct phy_device *phydev)
> >  {
> >  	phydev->phy_link_change(phydev, false);
> >  	phy_led_trigger_change_speed(phydev);
> > +	WRITE_ONCE(phydev->link_down_events, phydev->link_down_events + 1);  
> 
> I'm not sure the WRITE_ONCE adds much value. Many systems using PHYLIB
> are 32 bit, and i don't think WRITE_ONCE will make that 64 bit write
> atomic on 32 bit systems. And as Florian pointed out, you have bigger
> problems if you manged to overflow a u32 into a u64.
> 
> > @@ -723,6 +724,8 @@ struct phy_device {
> >  
> >  	int pma_extable;
> >  
> > +	unsigned int link_down_events;  
> 
> And here is unsigned int, not u64? Or u32? It would be good to be
> consistent.

I made it 32b on the phylib side so that WRITE_ONCE() was sufficient 
to ensure atomic writes.

Do you have a preference for it being 64b vs 32b at the uAPI level?
I was leaning slightly towards making both 32b in v3..

> > --- a/include/uapi/linux/ethtool_netlink.h
> > +++ b/include/uapi/linux/ethtool_netlink.h
> > @@ -262,6 +262,8 @@ enum {
> >  	ETHTOOL_A_LINKSTATE_SQI_MAX,		/* u32 */
> >  	ETHTOOL_A_LINKSTATE_EXT_STATE,		/* u8 */
> >  	ETHTOOL_A_LINKSTATE_EXT_SUBSTATE,	/* u8 */
> > +	ETHTOOL_A_LINKSTATE_PAD,
> > +	ETHTOOL_A_LINKSTATE_EXT_DOWN_CNT,	/* u64 */  
> 
> What is the PAD for?

64b values have to be padded in netlink to ensure alignment.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ