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: <20220211231421.erqojnturtnmtfvo@skbuf>
Date:   Fri, 11 Feb 2022 23:14:22 +0000
From:   Vladimir Oltean <vladimir.oltean@....com>
To:     Jakub Kicinski <kuba@...nel.org>
CC:     "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "David S. Miller" <davem@...emloft.net>,
        Andrew Lunn <andrew@...n.ch>,
        Vivien Didelot <vivien.didelot@...il.com>,
        Florian Fainelli <f.fainelli@...il.com>,
        Ansuel Smith <ansuelsmth@...il.com>,
        Tobias Waldekranz <tobias@...dekranz.com>,
        DENG Qingfang <dqfext@...il.com>,
        Claudiu Manoil <claudiu.manoil@....com>,
        Alexandre Belloni <alexandre.belloni@...tlin.com>,
        "UNGLinuxDriver@...rochip.com" <UNGLinuxDriver@...rochip.com>,
        Jiri Pirko <jiri@...nulli.us>, Ivan Vecera <ivecera@...hat.com>
Subject: Re: [PATCH v2 net-next 11/12] net: dsa: support FDB events on
 offloaded LAG interfaces

On Fri, Feb 11, 2022 at 03:03:52PM -0800, Jakub Kicinski wrote:
> On Thu, 10 Feb 2022 14:52:00 +0200 Vladimir Oltean wrote:
> > +static int
> > +dsa_lag_fdb_event(struct net_device *lag_dev, struct net_device *orig_dev,
> > +		  unsigned long event, const void *ctx,
> > +		  const struct switchdev_notifier_fdb_info *fdb_info)
> > +{
> > +	struct dsa_switchdev_event_work *switchdev_work;
> > +	bool host_addr = fdb_info->is_local;
> > +	struct net_device *slave;
> > +	struct dsa_switch *ds;
> > +	struct dsa_port *dp;
> > +
> > +	/* Skip dynamic FDB entries, since the physical ports beneath the LAG
> > +	 * should have learned it too.
> > +	 */
> > +	if (netif_is_lag_master(orig_dev) &&
> > +	    switchdev_fdb_is_dynamically_learned(fdb_info))
> > +		return 0;
> > +
> > +	/* FDB entries learned by the software bridge should be installed as
> > +	 * host addresses only if the driver requests assisted learning.
> > +	 */
> > +	if (switchdev_fdb_is_dynamically_learned(fdb_info) &&
> > +	    !ds->assisted_learning_on_cpu_port)
> > +		return 0;
> > +
> > +	/* Get a handle to any DSA interface beneath the LAG */
> > +	slave = switchdev_lower_dev_find(lag_dev, dsa_slave_dev_check,
> > +					 dsa_foreign_dev_check);
> > +	dp = dsa_slave_to_port(slave);
> > +	ds = dp->ds;
> 
> clang says:
> 
> net/dsa/slave.c:2650:7: warning: variable 'ds' is uninitialized when used here [-Wuninitialized]
>            !ds->assisted_learning_on_cpu_port)
>             ^~
> 
> It also suggests:
> 
> net/dsa/slave.c:2636:23: note: initialize the variable 'ds' to silence this warning
>        struct dsa_switch *ds;
>                             ^
>                              = NULL
> 
> but that's perhaps for comedic purposes.

Yes, that's "how not to fix a bug".

In this case the second "if" condition needs to be moved past the "ds = ..."
assignment.

The reason why I didn't get a dereference of an invalid pointer during
my testing is that I didn't test bridging between a DSA-offloaded LAG
and a foreign (non-DSA) interface - that's the kind of dynamic FDB entry
that check is for.

I saw that the patches aren't active in patchwork anymore and I have
this already fixed, but I'd wait for some feedback until I resend.
Maybe I'll resend on Monday or so.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ