🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #6318

Re: [PATCH net v2 10/14] net: pse-pd: keep the PI data until the PI regulators are gone

#6318
From: Oleksij Rempel
Date: Thu, 22 Oct 2026 07:34
77 lines
14749 bytes
On Tue, Oct 20, 2026 at 07:12:45PM +0200, Carlo Szelinsky wrote:
> pse_controller_unregister() frees the PI array, but the PI regulators
> are only unregistered after it, by devres. Until then their ops still
> run, for example on a read of the regulator's sysfs "state" or when a
> consumer enables or disables the PI, and they read the freed array.
> 
> Free the PI array from a devm action that is added before the PI
> regulators, so devres frees it after them. This also frees it when
> registration fails, where it was leaked before.
> 
> While the controller goes away, the PSE core must not power a PI.
> pse_controller_unregister() now first sets pcdev->unregistering under
> pcdev->lock. After that, enabling a PI fails with -ENODEV, and so does
> _pse_pi_delivery_power_sw_pw_ctrl(), which pse_isr(), a priority change
> and the retry after a disable use to power a PI. Disabling a PI still
> switches it off and frees its budget.
> 
> pse_flush_pw_ds() also switches off each PI that holds budget and gives
> the budget back before it drops the power domain. Nothing controls such
> a PI once its controller is gone, and before, its budget stayed
> reserved on the supply. If a PI cannot be switched off, its budget
> stays reserved, as the PI may still draw it.
> 
> Triggered in QEMU (arm64, KASAN) with a test-only PSE controller:
> reading the PI regulators' sysfs "state" while the controller unbinds
> gives
> 
>   BUG: KASAN: slab-use-after-free in pse_pi_is_enabled+0x294/0x2d4
> 
> and unbinding it with budget reserved leaves that budget on the
> supply. With this patch both are gone, the PIs are off after the
> unbind, and a priority change during the unbind no longer powers a PI.
> pse_isr() is not covered by the test, as the test controller has no
> IRQ.
> 
> Fixes: d83e13761d5b ("net: pse-pd: Use regulator framework within PSE framework")
> Fixes: ffef61d6d273 ("net: pse-pd: Add support for budget evaluation strategies")
> Signed-off-by: Carlo Szelinsky <github@szelinsky.de>

Freeing the PI array from devres after the PI regulators, and refusing
to power a PI once unregistering has started, look good to me.

Please drop pse_pi_power_off() from this patch, and the text about it
in the commit message and the cover letter.

The PI regulators follow the regulator model. A regulator that goes
away does not switch its output off; the consumer has to disable it
before it calls regulator_put(). For a PI the consumer is the PSE core
itself, on pcdev->dev. So on unbind every enabled PI should go off
through the normal disable path, before pse_flush_pw_ds() clears
pi->pw_d. The disable path also gives the budget back.

pse_pi_power_off() switches off only the PIs that hold budget. That is
not enough: a PI under hardware control, or under software control
without pi_get_pw_req(), can deliver power with no budget allocated.

Switching the PIs off on unbind belongs to the fix for a pse_control
outliving its controller, not to this patch. Patch 11 calls
pse_pi_power_off() from pse_pi_take_pw_d(), so patch 11 needs to drop
that call, and the comment above it, too.

Here "off" means what IEEE 802.3 calls mr_pse_enable = disable: no
power and no detection, as if there was no PSE. pi_disable() does not
do this on every driver today. tps23881 turns detection and
classification back on after power off, and the core relies on
detection staying on, since it also uses pi_disable() to power off a
PI that stays admin enabled. Fixing tps23881 is not part of this
series.

pw-bot: cr

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
Technical Details
Message-ID: <atm8c3oJomYY3RH6@pengutronix.de>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-350409-linux-kernel-netdev=dewy.ru
References: <20261020171249.853085-1-github@szelinsky.de> <20261020171249.853085-11-github@szelinsky.de>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-350409-linux-kernel-netdev=dewy.ru
From: o.rempel@pengutronix.de (Oleksij Rempel)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v2 10/14] net: pse-pd: keep the PI data until the PI
 regulators are gone
Date: Thu, 22 Oct 2026 09:34:11 +0200
Organization: Usenet Network
Message-ID: <atm8c3oJomYY3RH6@pengutronix.de>
References: <20261020171249.853085-1-github@szelinsky.de>
 <20261020171249.853085-11-github@szelinsky.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Injection-Info: usenet.network;
	logging-data="155984"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:OULN5Y//xYjIaB0lj6R9CIdtfyg= sha256:hPsy63pfdb2+v2pr/m7z4hsS/qoLA2eJmSMA2iBTJHs=
	sha1:9OCRNaS8jLhbxlrCmPalMY58eS0= sha256:nFIOzqKmIQU+otyUCNumEC9AO3+SCbt+oqyldNrHVZ8=
Content-Disposition: inline
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 751E01111D0; Thu, 22 Oct 2026 10:35:59 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.05
X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=pengutronix.de
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id gaaC4K8ECvFh;
	Thu, 22 Oct 2026 10:35:56 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-350409-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=pengutronix.de
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id C13FB1111CB; Thu, 22 Oct 2026 10:35:44 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 57A58366F8; Thu, 22 Oct 2026 07:34:17 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1792654457;
	b=B7mASsVAOONyiaI2HC0WPiDi3zDiHD8xgL6M0WHRa71WhNRTBv/Hpbn2jp92RU/vHwqp
	 vprwHEP/wbG0UNqnc1VZXmlKqdK6UImAYUKilQMxEIiBxpljTvfI6/v2DYKywVI/CNaFj
	 uaQ0jvs7NUi0urLLmef+8+JxE1Phwu1YZjasmnoYQv/K5RaqSnsolBSo4wYjMKvUo81jl
	 acsbi5sdTeDc3ZlQTB6ooRRdoPzqwdbuY8ph9yGTWeERA9sPblShubhxgtQKVINr6H32y
	 Otume6CZsoff/zVSgmBdt3dNQszBZpHZJ7UmtBzw14ldH/oIrYcqK49LHQNy+r7tjoA==
X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792654457;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:Received:
	 Received:Date:From:To:Cc:Subject:Message-ID:References:X-Mailing-List:
	 List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
	 List-Owner:Precedence:MIME-Version:Content-Type:Content-Disposition:
	 In-Reply-To:X-Sent-From:X-URL:X-Accept-Language:
	 X-Accept-Content-Type;
	bh=xROOygMrC7yI0A+nFF4ZYUpCmGBkajWRjJ/AHQXTEQ4=;
	b=io752z+LS0WOJZdx0k/TikhdjrmtzFlF0gain/pm+IaSZkosFeOGgXuATAzQg0/EqDcW
	 vtoN9HTg2zidO9gOXMIs/gEYzeRW4QJuMz54I2tRABkRCn8+jh3Cscrb6VhpDHZd5O/0P
	 UP/yK8RxhQQ+8KrQHWC7isxWQLUvM1ucAsdjewknN7EhXO9DPkp2aPUDDmUGGJNBanypb
	 sZJXL+FI9xlZnB4CBt5CE+dQ77yuiHh0nS5EHCGlSGucXg5Nar//rkEjrFTk0NrQ5TLlJ
	 4Xf5lH/o/vSUgW0/ntiG3iS29BtGkVh8H2YW6Z4mehfPc0sScEu2W6yrGRjiQBVnzvg==
X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; 
	dkim=pass header.d=pengutronix.de header.i=@pengutronix.de header.a=rsa-sha256 header.s=20260414 header.b=Gdj024Nn;
	dmarc=none header.from=pengutronix.de;
	spf=pass smtp.mailfrom=pengutronix.de;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 2EC1B606A324;
	Thu, 22 Oct 2026 07:34:17 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=pengutronix.de header.i=@pengutronix.de header.a=rsa-sha256 header.s=20260414 header.b=Gdj024Nn
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=185.203.200.13
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1792654456;
	b=AOGNCXvHV75+8wtRbgxDhKfQwS6l6yncXhEbXClzfJ33OtxdyP7ZKuqkUvAVGb+KYfQx
	 GmxjU6spfovqFkUYS8jOapfUxc/eFS1fiapbdi7vaNup5q1mIFaoFrE69tq3/OwJeUPGA
	 FIIz6TD7TOxllqvA3rXP3JYlegtjyBqkEP++wP+KN9il+RR1aWWPLxzTGsC4FJS26gwOU
	 2MWuoac0sKBKDw7SklOxdAsnz/N27UOmAJDxqqEKCda3VviguXnPbZ4Sm5t0N92+hiIHl
	 nriS/mjgEZyqpnll0x+A+UEAioEyLxjvdLJKjOjbBOfli3Pe5gSEPBNR9gpwuxjNhDA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792654456;
	h=DMARC-Filter:Received:DKIM-Signature:Received:Received:Date:From:To:
	 Cc:Subject:Message-ID:References:MIME-Version:Content-Type:
	 Content-Disposition:In-Reply-To:X-Sent-From:X-URL:X-Accept-Language:
	 X-Accept-Content-Type;
	bh=xROOygMrC7yI0A+nFF4ZYUpCmGBkajWRjJ/AHQXTEQ4=;
	b=JwsB/wP4dcpE9Hmfwoplp2PZq5HO083qFxR+GDleth7CZfB5D5lacybO773CbyK6Gy6l
	 exBx1JUK9yne2BN1s/zZ9jQkDHPLbs70pJDdUlT38I+wV8v0JNHxIvr3Yc1F23RB0/pUr
	 10Zg9JXO368PUqs0wNcXH8r8SxKEDtjzXMShILnnxSGpJ1v0lPfwsa65J0uy34BXgJDri
	 v3asMOEEebpRgnWnJCUUdawzDNm8MNzWecSSxTNb5zfKP7YwlxedZ/jtSkVYHFidqcl/F
	 5zgxM5TpoK/+10WpjgPbFLzwZIm8h9NHOnxt1+Gs3RkAEaxdKFrTqlER6u8MqFEVIBA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dmarc=none header.from=pengutronix.de;
	spf=pass smtp.mailfrom=pengutronix.de;
	dkim=pass header.d=pengutronix.de header.i=@pengutronix.de header.a=rsa-sha256 header.s=20260414 header.b=Gdj024Nn;
	arc=pass header.oldest-pass=0 smtp.remote-ip=185.203.200.13
X-Received: from mx1.white.stw.pengutronix.de (mx1.white.stw.pengutronix.de [185.203.200.13])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E3FB606A319;
	Thu, 22 Oct 2026 07:34:13 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1E3FB606A319
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de
X-Received: from drehscheibe.grey.stw.pengutronix.de (drehscheibe.grey.stw.pengutronix.de [IPv6:2a0a:edc0:0:c01:1d::a2])
	(Authenticated sender: relay-from-drehscheibe.grey.stw.pengutronix.de)
	by mx1.white.stw.pengutronix.de (Postfix) with ESMTPSA id E1A60200208;
	Thu, 22 Oct 2026 09:34:11 +0200 (CEST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pengutronix.de;
	s=20260414; t=1792654451;
	h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
	 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
	 in-reply-to:in-reply-to:references:references;
	bh=xROOygMrC7yI0A+nFF4ZYUpCmGBkajWRjJ/AHQXTEQ4=;
	b=Gdj024NnjPJEMCrSkozLYT9/WBzs9FO1ppOoT49t0QpZLCA0xTLzxP1EEZLbcOYavI/BMV
	YR/dlWITmq6Hjzp0AUBN6laD4H41EDyDFzkYWR1r87C6FyU8vKJcvhhNcXtVIQ89g6CVj4
	kpB8RgcOsiU82kgg71M1fAlmHZ+DqCGglsvf+Dj4kacIc81bkOOy2v5+dzcDFh23L6TM1b
	K8nTJ9xPTsHHq2hcTxiylI/5v1FDelwuRKfS2c3jeDRGsox486yu+AiMykmTcUOzbJ8q4A
	4m13khCmaUgfi1sn9G/o92UxQX7On5YVHjXndBwhnH5SLoI1cT8Mou5cgUZL8g==
X-ARC-Seal: i=1; s=20260414; d=pengutronix.de; t=1792654451; a=rsa-sha256;
	cv=none;
	b=K6tDTmGVqttjIvUA0277WHeDrW3c+DgDD27uydGhNehJBcJ8Gxv0S3C7d6OwD/qofX91Vn
	u8vVR53KchcdYnKixAgG9wHVSymtWBQSm2WcFw81eilE6g/MvSlu26bWJNv4Uxf7o6vnJ8
	skxSl5hmyaLt3ViGImyI6+M158H5948PNRZB+Twfl2ZF1AQcZPdaqBmWR11CtuRoTveLab
	hF3zX26qmlJGP6h2ny+ofR9lZblP1J4ggYdkGtGOMm2Pp7SmCAWFVhHis4BgQECOYWJ+VA
	OHCRpTKC8ZZE1IwV/qTv3NrzwkBWJ+kDNURLt6c05N0PwzrBS278tFFcYUGpsg==
X-ARC-Authentication-Results: i=1;
	ORIGINATING;
	auth=pass smtp.auth=relay-from-drehscheibe.grey.stw.pengutronix.de smtp.mailfrom=ore@pengutronix.de
X-ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=pengutronix.de;
	s=20260414; t=1792654451;
	h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
	 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
	 in-reply-to:in-reply-to:references:references;
	bh=xROOygMrC7yI0A+nFF4ZYUpCmGBkajWRjJ/AHQXTEQ4=;
	b=MfEaOCMl7VqKc0pwv8/hpBfooUhVlnIPhn5l0aiCUHmHZ7kSWZ0A6PWlWzni8oB1wa98PE
	RnGd4kqB0nNCK0vwXdVwcoNi55TDTv/FdeS6DNfrw0OX0oL8RW1H4xzf5Z2P2dHH2iPzCN
	K1M2r13Ru1bl7pLr7MQxyRuZje1Fr8CndEHvPLMjAJbhYxqQ+/3uOCrIsXTD9bsB3TyMw4
	3N8OHflOeO22sAdmawTbjsw++AI0vlxnNxzYguzHJ6JZZ1AziGUiPViLoE4+373lSrLseT
	WEhjUqwXU8qm2Q4ARRAF/Q3NJWYnH2lu+TrowA945riRiNigqQ6Yk9RkWx0Vxg==
X-Received: from pty.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::c5])
	by drehscheibe.grey.stw.pengutronix.de with esmtps  (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
	(Exim 4.96)
	(envelope-from <ore@pengutronix.de>)
	id 1xJnJT-000fgG-2h;
	Thu, 22 Oct 2026 09:34:11 +0200
X-Received: from ore by pty.whiteo.stw.pengutronix.de with local (Exim 4.98.2)
	(envelope-from <ore@pengutronix.de>)
	id 1xJnJT-00000009QzU-2zGy;
	Thu, 22 Oct 2026 09:34:11 +0200
X-Cc: Kory Maincent <kory.maincent@bootlin.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	Kyle Swenson <kyle.swenson@est.tech>, Ross Cawston <ross@r-sc.ca>,
	netdev-bot+sashiko@kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <20261020171249.853085-11-github@szelinsky.de>
X-Sent-From: Pengutronix Hildesheim
X-URL: http://www.pengutronix.de/
X-Accept-Language: de,en
X-Accept-Content-Type: text/plain