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: <20250320164623.4007e7bc@kmaincent-XPS-13-7390>
Date: Thu, 20 Mar 2025 16:46:23 +0100
From: Kory Maincent <kory.maincent@...tlin.com>
To: Oleksij Rempel <o.rempel@...gutronix.de>
Cc: Andrew Lunn <andrew@...n.ch>, "David S. Miller" <davem@...emloft.net>,
 Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Paolo
 Abeni <pabeni@...hat.com>, Jonathan Corbet <corbet@....net>, Donald Hunter
 <donald.hunter@...il.com>, Rob Herring <robh@...nel.org>, Andrew Lunn
 <andrew+netdev@...n.ch>, Simon Horman <horms@...nel.org>, Heiner Kallweit
 <hkallweit1@...il.com>, Russell King <linux@...linux.org.uk>, Krzysztof
 Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>, Liam
 Girdwood <lgirdwood@...il.com>, Mark Brown <broonie@...nel.org>, Thomas
 Petazzoni <thomas.petazzoni@...tlin.com>, netdev@...r.kernel.org,
 linux-doc@...r.kernel.org, Kyle Swenson <kyle.swenson@....tech>, Dent
 Project <dentproject@...uxfoundation.org>, kernel@...gutronix.de, Maxime
 Chevallier <maxime.chevallier@...tlin.com>, devicetree@...r.kernel.org,
 linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next v6 04/12] net: pse-pd: Add support for PSE
 power domains

On Mon, 17 Mar 2025 10:59:02 +0100
Oleksij Rempel <o.rempel@...gutronix.de> wrote:

> On Tue, Mar 04, 2025 at 11:18:53AM +0100, Kory Maincent wrote:

> > +static int pse_register_pw_ds(struct pse_controller_dev *pcdev)
> > +{
> > +	int i;
> > +
> > +	for (i = 0; i < pcdev->nr_lines; i++) {
> > +		struct regulator_dev *rdev = pcdev->pi[i].rdev;
> > +		struct pse_power_domain *pw_d;
> > +		struct regulator *supply;
> > +		bool present = false;
> > +		unsigned long index;
> > +
> > +		/* No regulator or regulator parent supply registered.
> > +		 * We need a regulator parent to register a PSE power
> > domain
> > +		 */
> > +		if (!rdev || !rdev->supply)
> > +			continue;
> > +  
> 
> Should we use xa_lock() before iteration over the map?

I am scratching my head to find out the case where it may be needed.
The only case I think of is two PSE controller with PSE PI using the same power
supply. Which is not a good idea for well distributing power.
In this case we could have two pse_register_pw_ds running concurrently and we
could have issues. Not only the iteration over the map should be protected but
also the content of the pw_d entry. Also when we unbind one of the PSE
controller it will remove all the PSE power domains event if they are used
by another PSE. :/
I need to add refcount and lock on the PSE power domains to fix this case! 

> > +		xa_for_each(&pse_pw_d_map, index, pw_d) {
> > +			/* Power supply already registered as a PSE power
> > +			 * domain.
> > +			 */
> > +			if (regulator_is_equal(pw_d->supply,
> > rdev->supply)) {
> > +				present = true;
> > +				pcdev->pi[i].pw_d = pw_d;
> > +				break;
> > +			}
> > +		}
> > +		if (present)
> > +			continue;
> > +
> > +		pw_d = devm_pse_alloc_pw_d(pcdev->dev);
> > +		if (IS_ERR_OR_NULL(pw_d))
> > +			return PTR_ERR(pw_d);  
> 
> It is better to break the loop and roll back previous allocations.

This will be done by pse_flush_pw_ds called by devm_pse_controller_release as
the pse_controller_register failed.

Regards,
-- 
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ