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: <CAMOZA0L7+ugo7e=VeiGUc49fyNTxr0HmU4cuM8jHfRO3OMYuXw@mail.gmail.com>
Date:   Thu, 23 Jan 2020 09:47:56 -0800
From:   Luigi Rizzo <lrizzo@...gle.com>
To:     Michal Kubecek <mkubecek@...e.cz>
Cc:     netdev@...r.kernel.org, Andrew Lunn <andrew@...n.ch>,
        "David S. Miller" <davem@...emloft.net>
Subject: Re: [PATCH] net-core: remove unnecessary ETHTOOL_GCHANNELS initialization

On Thu, Jan 23, 2020 at 12:40 AM Michal Kubecek <mkubecek@...e.cz> wrote:
>
> On Wed, Jan 22, 2020 at 04:18:56PM -0800, Luigi Rizzo wrote:
> > On Wed, Jan 22, 2020 at 3:47 PM Andrew Lunn <andrew@...n.ch> wrote:
> > >
> > > On Wed, Jan 22, 2020 at 02:33:26PM -0800, Luigi Rizzo wrote:
> > > > struct ethtool_channels does not need .cmd to be set when calling the
> > > > driver's ethtool methods. Just zero-initialize it.
> > > >
> > > > Tested: run ethtool -l and ethtool -L
> > >
> > > Hi Luigi
> > >
> > > This seems pretty risky. You are assuming ethtool is the only user of
> > > this API. What is actually wrong with putting a sane cmd value, rather
> > > than the undefined value 0.
> >
> > Hi Andrew, if I understand correctly your suggestion is that even if
> > the values are unused, it is better to stay compliant with the header
> > file include/uapi/linux/ethtool.h, which does suggest a value for .cmd
> > for the various structs
>
> Unless you check all in tree drivers, you cannot be sure there isn't one
> which would in fact rely on .cmd being set to expected value. And even
> then there could be some out of tree driver; we usually don't care too
> much about them but it's always matter of what you gain by the cleanup.
> AFAICS it might be just few CPU cycles in this case - if we are lucky.

The change was not about CPU savings, but trying to remove what I thought
were misleading or incorrect values.

Now I stand corrected, thank you for the feedback:
the header mentions that cmd should have a value
so let it be in, and as you say later, the first operation in
ethtool_set_channels()
is a get_channels so ETHTOOL_GCHANNELS is the correct value.

For the same reason though (comply with the header) we might perhaps
want to replace with cmd with ETHTOOL_SCHANNELS before actually
calling dev->ethtool_ops->set_channels()

(I realize this is not particularly important)

cheers
luigi
>
> > and only replace the value in ethtool_set_channels() with the correct
> > one ETHTOOL_SCHANNELS ?
>
> That would be incorrect. The initialization in ethtool_set_channels() is
> for curr variable which is passed to ->get_channels() (to get current
> values for checking new values against maximum). Therefore the correct
> command really is ETHTOOL_GCHANNELS.
>
> Michal

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ