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: <aa66dc50-16b9-4489-ac77-3ef4013b6037@lunn.ch>
Date: Wed, 10 Jul 2024 01:23:36 +0200
From: Andrew Lunn <andrew@...n.ch>
To: Lorenzo Bianconi <lorenzo@...nel.org>
Cc: netdev@...r.kernel.org, nbd@....name, lorenzo.bianconi83@...il.com,
	davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
	pabeni@...hat.com, conor@...nel.org,
	linux-arm-kernel@...ts.infradead.org, robh+dt@...nel.org,
	krzysztof.kozlowski+dt@...aro.org, conor+dt@...nel.org,
	devicetree@...r.kernel.org, catalin.marinas@....com,
	will@...nel.org, upstream@...oha.com,
	angelogioacchino.delregno@...labora.com,
	benjamin.larsson@...exis.eu, rkannoth@...vell.com,
	sgoutham@...vell.com, arnd@...db.de, horms@...nel.org
Subject: Re: [PATCH v6 net-next 2/2] net: airoha: Introduce ethernet support
 for EN7581 SoC

> > > +static int airoha_alloc_gdm_port(struct airoha_eth *eth, struct device_node *np)
> > > +{
> > 
> > > +	port = netdev_priv(dev);
> > > +	mutex_init(&port->stats.mutex);
> > > +	port->dev = dev;
> > > +	port->eth = eth;
> > > +	port->id = id;
> > > +
> > > +	err = register_netdev(dev);
> > > +	if (err)
> > > +		return err;
> > > +
> > > +	eth->ports[index] = port;
> > 
> > eth->ports[index] appears to be used in
> > airoha_qdma_rx_process(). There is a small race condition here, since
> > the interface could be in use before register_netdev() returns,
> > e.g. NFS root. It would be better to do the assignment before
> > registering the interface.
> 
> actually I check eth->ports[] is not NULL before accessing it in
> airoha_qdma_rx_process():
> 
> 	p = airoha_qdma_get_gdm_port(eth, desc);
> 	if (p < 0 || !eth->ports[p]) {
> 		...
> 	}

Yes, you check it is not NULL, so you don't de-reference anything. But
i did not spend enough time to check if you leek something as a result
of it being NULL?

> Moreover, in airoha_alloc_gdm_port(), I set eth->ports[index] pointer just if
> register_netdev() is successful in order to avoid to call unregister_netdev()
> on an not-registered net_device in the airoha_probe() error path. I guess we can
> even check reg_state for this:
> 
> 	for (i = 0; i < ARRAY_SIZE(eth->ports); i++) {
> 		...
> 		if (dev->reg_state == NETREG_REGISTERED)
> 			unregister_netdev(dev);
> 	}

I prefer checking reg_state. Problems with this race condition are
hard to track down, so it is better to not have it in the first place.

     Andrew

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ