🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #15160

Re: [PATCH net] net: stmmac: dwmac-sun8i: Fix use-after-free in the MDIO mux error path

#15160
From: Andrew Lunn
Date: Thu, 12 Nov 2026 13:13
34 lines
10126 bytes
On Thu, Nov 12, 2026 at 05:28:05AM +0000, Arun Iyengar via B4 Relay wrote:
> From: Arun Iyengar <aiyengar1990@gmail.com>
> 
> mdio_mux_init() registers the child MDIO buses one after the other.
> Scanning the internal bus makes mdio_mux_syscon_switch_fn() select the
> internal PHY and power it, which sets gmac->internal_phy_powered. If
> mdio_mux_init() then fails without switching away from the internal
> bus, for example because registering the external bus returns
> -EPROBE_DEFER before any access to it, or because an allocation for it
> fails, sun8i_dwmac_probe() jumps to dwmac_mux with the PHY still
> powered.
> 
> That error path releases gmac->rst_ephy and gmac->ephy_clk and only
> then calls stmmac_pltfr_remove(), which ends in sun8i_dwmac_exit().
> Since the PHY is still marked as powered, sun8i_dwmac_exit() calls
> sun8i_dwmac_unpower_internal_phy(), which passes the clock and the
> reset control that were just freed to clk_disable_unprepare() and
> reset_control_assert().
> 
> Unpower the internal PHY before releasing its clock and reset control,
> as sun8i_dwmac_remove() does. The later call from sun8i_dwmac_exit()
> then does nothing because internal_phy_powered is already cleared.
> 
> Fixes: 529254216773 ("net: stmmac: dwmac-sun8i: Balance internal PHY resource references")
> Cc: stable@vger.kernel.org

Does this bother anybody? Seems more like this should be for net-next.


    Andrew

---
pw-bot: cr
Technical Details
Message-ID: <e526541c-f91a-484b-a677-4c55e4a96a7b@lunn.ch>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361849-linux-kernel-netdev=dewy.ru
References: <20261112-sun8i-emac-mux-uaf-v1-1-308ae7e6fcf2@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!newsfeed.bofh.team!nntp.comgw.net!eternal-september.org!feeder.eternal-september.org!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361849-linux-kernel-netdev=dewy.ru
From: andrew@lunn.ch (Andrew Lunn)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] net: stmmac: dwmac-sun8i: Fix use-after-free in the
 MDIO mux error path
Date: Thu, 12 Nov 2026 14:13:59 +0100
Organization: Usenet Network
Message-ID: <e526541c-f91a-484b-a677-4c55e4a96a7b@lunn.ch>
References: <20261112-sun8i-emac-mux-uaf-v1-1-308ae7e6fcf2@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
	logging-data="1093086"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Dne3QZebnShHT8gR4weahfIexE8= sha256:Y46OWDgHUMDxQCeokx01BpR4B7vzCE65kAvWFUwvqH0=
	sha1:c0nnGgw+i8i96BieBiDueEl968w= sha256:0GpDz6l/XMrr/daPXxcwqQO5lPZ5YUCMJTnWTidmJIw=
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 1F6FE114252; Thu, 12 Nov 2026 16:25:51 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.051
X-Spam-Status: No, score=-3.051 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.249,
	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 (1024-bit key)
	header.d=lunn.ch
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 QixWjvLnAkZK;
	Thu, 12 Nov 2026 16:25:48 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-361849-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=lunn.ch
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 36160114217; Thu, 12 Nov 2026 16:25:39 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 7A00BC3822; Thu, 12 Nov 2026 13:15:15 +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=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1794489264;
	b=ZFrzBWSjoMBf0NGkr1Hvg/mf40S7UYysn6LkI0sa1vD8Y8uab5TPQYetzd9AWnldev9v
	 Xqp/+kNeXnoSWRc5dCcprzZ18/QztbVrFPvJbBXWVRFL451EWCknGn2JDMl9lknUpB0mm
	 6cHTBK7VjGTOrU8YisMEfTHayJhm8zaxbRpd853m5bCJ8m/Tf93H4QYCzbC2kO70LQtcB
	 czy1lURpMlCGuJ5bh1lSBJXbDAIuHAh86oFUEoDRyMxQ6rKHItQtQliPQa3AxIKEsogve
	 uZ9uoTyDgOUP/zrPJ5ypMPRwq+KI2jFYFBWRjnxeu8NTR0O/TQw+e0qXIQZFwVhkBag==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794489264;
	h=X-Original-To:Received:DMARC-Filter:DKIM-Signature: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;
	bh=JsseaZWlHALkJDroqnvRsrsIA8/F+g3l2qrb9axVxOs=;
	b=h0qL22S47itgp7gXa0nnRV7T1esFyUIUGI/lVHupviOu4zpy+/KXLG85nn1ciVfKrrz0
	 f5lQOm2KLz99lsm/7ei7Aa0zVu+it4h6IecwFKCoRWmic4Xjw5HLRP5ILzEDlwjHflVub
	 y2em4muqQbdTdwSoldjonJEuVH5GpDIz29nJpxMQlzksgLJB6DBzIxJGKMy4QFOhPVKhv
	 YFclq9tt6rnYpAwQ8c2nRAcdAs8Xt5FskpRQy8jfuyosWYsPYGJWp5VtuhRoFnoHy1YTI
	 ll2q+cHWkNcyII/IbcFOFElIWeqrHwL73wZsM4XKeEtfROBudCrZB1qGZK/HK/YSzJQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=lunn.ch header.i=@lunn.ch header.a=rsa-sha256 header.s=20171124 header.b="WIJl/qw7";
	dmarc=pass header.from=lunn.ch;
	spf=pass smtp.mailfrom=lunn.ch;
	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 4720960A261C;
	Thu, 12 Nov 2026 13:14:24 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.a=rsa-sha256 header.s=20171124 header.b=WIJl/qw7
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=156.67.10.101
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794489263;
	b=rtNl4tq2bx5nkmXWuIuY0yXhZ9g4gNVUe0+YmxK5CH3IVvYqxOAgaHtOH1NpBiTzyKVR
	 CqGkapFhAr9QU8PwjAVT1qVHTJcXzJNHgnWV0n6DRM4SsP5bvK5Q+7fc1BdX7CAjqAdyt
	 pUnf8cnX3qz7Vo0FrDn6xSqRkJnezlbTDM09t+JTS9zk6s2lfo+mXHTOa0WgQWHDzLRFM
	 pl8l8q7blSH2OAsSUXXfw2JfBLwG/E2cM1DBzmVydEaMmsNTGgfii5vUpu2CwZI4NBmee
	 lLxDsYCH/drFmWuw3hM+qqfG3+fgpbvvRFFOkYu659RxAvK6InuRsdAS56zP9sXIqaA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794489263;
	h=DMARC-Filter:DKIM-Signature:Received:Date:From:To:Cc:Subject:
	 Message-ID:References:MIME-Version:Content-Type:Content-Disposition:
	 In-Reply-To;
	bh=JsseaZWlHALkJDroqnvRsrsIA8/F+g3l2qrb9axVxOs=;
	b=ffIarSW7wIPXgimfMTeY2yisTURqBVIU+1QmY0zoACgTnvR/vYzLiVArttl1hxw9tVa6
	 IyUM/M0jdLfUGpDaNen5WibvPM48AVFt0FZ6oiexqp6qHsslppScQrS3Dee1Rq78IC3cV
	 rF/yFUh0AunrmQUcjR7KnP6nwdLddvRMWsztPYH0AsgHVnlvJbdAKEbSF7XnE2Fv6XDXf
	 Ny5JPxafA40w/pPq7akVYESy7OQErKxiujSQ/jlVld1tBKhqtDBfkwaG37ZIpiCzIwIO/
	 XSBg3XqlU8CW/VtcDx4JT1sh0hr7Z+W7XffboTwtaB7jmnATtrZXEZFGuB7h1ndYE7w==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=lunn.ch;
	spf=pass smtp.mailfrom=lunn.ch;
	dkim=pass header.d=lunn.ch header.i=@lunn.ch header.a=rsa-sha256 header.s=20171124 header.b="WIJl/qw7";
	arc=none smtp.remote-ip=156.67.10.101
X-Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C430606A330;
	Thu, 12 Nov 2026 13:14:22 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9C430606A330
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lunn.ch
X-DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch;
	s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version:
	References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject:
	Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding:
	Content-ID:Content-Description:Content-Disposition:In-Reply-To:References;
	bh=JsseaZWlHALkJDroqnvRsrsIA8/F+g3l2qrb9axVxOs=; b=WIJl/qw7H0BAcm1v01iuIz8K0n
	/zMRv/4PU6hmW6MyyaRlRwjgpLKzdkb+rhiJrtiGtdp5c0BlWUd8nxgs3pMCg9asI6XeZ8oVc5gRr
	/A8XijRY6spjDYf2F9uh2CuhqOe8LqdJeU7ovZBP65Q0Jo/pXQSCGpH3Y2H0fEHpU0Ww=;
X-Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2)
	(envelope-from <andrew@lunn.ch>)
	id 1xRUcp-00G1SL-1Y; Thu, 12 Nov 2026 14:13:59 +0100
X-Cc: Maxime Chevallier <maxime.chevallier@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>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Alexandre Torgue <alexandre.torgue@foss.st.com>,
	Chen-Yu Tsai <wens@kernel.org>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Samuel Holland <samuel@sholland.org>,
	Philipp Zabel <p.zabel@pengutronix.de>, netdev@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev,
	linux-stm32@st-md-mailman.stormreply.com,
	linux-kernel@vger.kernel.org, stable@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: <20261112-sun8i-emac-mux-uaf-v1-1-308ae7e6fcf2@gmail.com>