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: <A612847CFE53224C91B23E3A5B48BAC7534E8D76AD@xmail3.se.axis.com>
Date:	Tue, 21 Aug 2012 10:41:53 +0200
From:	Johan Gunnarsson <johan.gunnarsson@...s.com>
To:	Ben Hutchings <bhutchings@...arflare.com>
CC:	"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
	Mikael Starvik <starvik@...s.com>
Subject: RE: [PATCH] ethtool: don't overwrite useful bits in advertising
 bitfield



> -----Original Message-----
> From: netdev-owner@...r.kernel.org [mailto:netdev-
> owner@...r.kernel.org] On Behalf Of Ben Hutchings
> Sent: den 20 augusti 2012 17:23
> To: Johan Gunnarsson
> Cc: netdev@...r.kernel.org; Mikael Starvik
> Subject: Re: [PATCH] ethtool: don't overwrite useful bits in
> advertising bitfield
> 
> On Tue, 2012-08-14 at 16:15 +0200, Johan Gunnarsson wrote:
> > There are bits in this bitfield that we want to leave untouched
> (PAUSE
> > and ASYM_PAUSE bits) when changing other bits (speed and duplex
> bits.)
> > Previously, these were always overwritten to zero when running
> commands
> > like "ethtool -s eth0 speed 10 duplex full autoneg off".
> 
> This is right in principle, but the implementation isn't quite right.
> 
> > Signed-off-by: Johan Gunnarsson <johangu@...s.com>
> > ---
> >  ethtool.c |   45 +++++++++++++++++++++++++++++++--------------
> >  1 file changed, 31 insertions(+), 14 deletions(-)
> >
> > diff --git a/ethtool.c b/ethtool.c
> > index e573357..efa12c7 100644
> > --- a/ethtool.c
> > +++ b/ethtool.c
> > @@ -46,6 +46,18 @@
> >  #define MAX_ADDR_LEN	32
> >  #endif
> >
> > +#define ALL_ADVERTISED_MODES \
> > +	(ADVERTISED_10baseT_Half | \
> > +	 ADVERTISED_10baseT_Full | \
> > +	 ADVERTISED_100baseT_Half | \
> > +	 ADVERTISED_100baseT_Full | \
> > +	 ADVERTISED_1000baseT_Half | \
> > +	 ADVERTISED_1000baseT_Full | \
> > +	 ADVERTISED_2500baseX_Full | \
> > +	 ADVERTISED_10000baseT_Full | \
> > +	 ADVERTISED_20000baseMLD2_Full | \
> > +	 ADVERTISED_20000baseKR2_Full)
> 
> This is missing the new 40G modes (not a regression, I realise).

I'll add the 40G modes. There is also a bunch of 10G modes missing. Shall I add these too?

> 
> [...]
> > @@ -2405,19 +2421,20 @@ static int do_sset(struct cmd_context *ctx)
> >  			}
> >  			if (autoneg_wanted == AUTONEG_ENABLE &&
> >  			    advertising_wanted == 0) {
> > -				ecmd.advertising = ecmd.supported &
> > -					(ADVERTISED_10baseT_Half |
> > -					 ADVERTISED_10baseT_Full |
> > -					 ADVERTISED_100baseT_Half |
> > -					 ADVERTISED_100baseT_Full |
> > -					 ADVERTISED_1000baseT_Half |
> > -					 ADVERTISED_1000baseT_Full |
> > -					 ADVERTISED_2500baseX_Full |
> > -					 ADVERTISED_10000baseT_Full |
> > -					 ADVERTISED_20000baseMLD2_Full |
> > -					 ADVERTISED_20000baseKR2_Full);
> > +				/* Auto negotation enabled, but with
> > +				 * unspecified speed and duplex: enable all
> > +				 * supported speeds and duplexes.
> > +				 */
> > +				ecmd.advertising = (ecmd.advertising &
> > +					~ALL_ADVERTISED_MODES) |
> > +					(ALL_ADVERTISED_MODES & ecmd.supported);
> 
> Perhaps we should also warn if there's a 'supported' flag we don't
> recognise, because we don't know whether it's a link mode and we might
> be failing to enable/disable it as requested.

You mean if ecmd.supported has bits enabled that ALL_ADVERTISED_MODES hasn't? I don't think that's a good idea, because that happens very often (for example PAUSE bits in my case.)

> 
> >  			} else if (advertising_wanted > 0) {
> > -				ecmd.advertising = advertising_wanted;
> > +				/* Enable all requested modes */
> > +				ecmd.advertising = (ecmd.advertising &
> > +					~ALL_ADVERTISED_MODES) |
> > +					(advertising_wanted & ecmd.supported);
> 
> I don't think the '& ecmd.supported' here is right.  If an autoneg
> device supports some new link mode L that is not in
> ALL_ADVERTISED_MODES, but not link mode M which the user requested,
> then
> this can silently fail because the resulting advertising mask will
> include L but not M.
> 
> We should either use advertising_wanted unmasked and let the driver
> validate it, or report an error if it's not present in the supported
> mask.  I think we should be consistent with the following case, i.e.
> let
> the driver validate it.

How about remove "& ecmd.supported", but also warn if trying to add an unsupported mode? Similar to the previous case.

> 
> Ben.
> 
> > +			} else if (full_advertising_wanted > 0) {
> > +				ecmd.advertising = full_advertising_wanted;
> >  			}
> >
> >  			/* Try to perform the update. */
> 
> --
> Ben Hutchings, Staff Engineer, Solarflare
> Not speaking for my employer; that's the marketing department's job.
> They asked us to note that Solarflare product names are trademarked.
> 
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@...r.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ