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: <ZC5w31Kqh8KxHm5h@corigine.com>
Date:   Thu, 6 Apr 2023 09:12:31 +0200
From:   Simon Horman <simon.horman@...igine.com>
To:     Vladimir Oltean <vladimir.oltean@....com>
Cc:     netdev@...r.kernel.org, Jakub Kicinski <kuba@...nel.org>,
        "David S. Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Paolo Abeni <pabeni@...hat.com>, Andrew Lunn <andrew@...n.ch>,
        Florian Fainelli <f.fainelli@...il.com>
Subject: Re: [RFC PATCH net-next] net: dsa: replace
 NETDEV_PRE_CHANGE_HWTSTAMP notifier with a stub

On Wed, Apr 05, 2023 at 11:31:07PM +0300, Vladimir Oltean wrote:
> On Wed, Apr 05, 2023 at 10:05:15PM +0200, Simon Horman wrote:
> > > +static inline int dsa_master_hwtstamp_validate(struct net_device *dev,
> > > +					       const struct kernel_hwtstamp_config *config,
> > > +					       struct netlink_ext_ack *extack)
> > > +{
> > > +	int err;
> > > +
> > > +	if (!netdev_uses_dsa(dev))
> > > +		return 0;
> > > +
> > > +	mutex_lock(&dsa_stubs_lock);
> > > +
> > > +	if (dsa_stubs)
> > > +		err = dsa_stubs->master_hwtstamp_validate(dev, config, extack);
> > > +
> > > +	mutex_unlock(&dsa_stubs_lock);
> > 
> > nit: clang-16 tells me that err is uninitialised here if dsa_stubs is false.
> 
> In fact, clang-16 is saying something much smarter than that, because I
> did test this code path and it did work reliably (not like an uninitialized
> return value would).
> 
> It's saying that when netdev_uses_dsa() returns true, the DSA module has
> surely been loaded, so the stubs have surely been registered, so the
> mutex_lock() and the check for the NULL quality of dsa_stubs are
> completely redundant and can be removed.

For the record, what it had to say, when used with W=1, was:

In file included from net/dsa/dsa.c:20:
./include/net/dsa_stubs.h:33:6: error: variable 'err' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
        if (dsa_stubs)
            ^~~~~~~~~
./include/net/dsa_stubs.h:38:9: note: uninitialized use occurs here
        return err;
               ^~~
./include/net/dsa_stubs.h:33:2: note: remove the 'if' if its condition is always true
        if (dsa_stubs)
        ^~~~~~~~~~~~~~
./include/net/dsa_stubs.h:26:9: note: initialize the variable 'err' to silence this warning
        int err;
               ^
                = 0
1 error generated.

--

In file included from net/dsa/stubs.c:7:
./include/net/dsa_stubs.h:33:6: error: variable 'err' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
        if (dsa_stubs)
            ^~~~~~~~~
./include/net/dsa_stubs.h:38:9: note: uninitialized use occurs here
        return err;
               ^~~
./include/net/dsa_stubs.h:33:2: note: remove the 'if' if its condition is always true
        if (dsa_stubs)
        ^~~~~~~~~~~~~~
./include/net/dsa_stubs.h:26:9: note: initialize the variable 'err' to silence this warning
        int err;
               ^
                = 0
1 error generated.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ