๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #24843

Re: [PATCH net-next v23 01/15] net: phylink: make PCS phylink instance access RCU protected

#24843
From: netdev-bot+sashiko
Date: Mon, 30 Nov 2026 23:47
88 lines
11434 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] phylink_destroy() in drivers/net/phy/phylink.c now writes through
  pl->pcs with `rcu_assign_pointer(pl->pcs->phylink, NULL)` (linesโ€ฆ

--

net: phylink: make PCS phylink instance access RCU protected

This patch makes the phylink back-pointer in struct phylink_pcs RCU
protected. phylink_pcs_change() now reads it under rcu_read_lock().
phylink_destroy() also clears the pointer on the currently selected PCS
and calls synchronize_rcu() before freeing the phylink instance.

> diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
> index d1f1142a98a4e..d736604b86f48 100644
> --- a/drivers/net/phy/phylink.c
> +++ b/drivers/net/phy/phylink.c

[ ... ]

> @@ -2157,6 +2158,16 @@ void phylink_destroy(struct phylink *pl)
>  	if (pl->link_gpio)
>  		gpiod_put(pl->link_gpio);
>  
> +	if (pl->pcs)
> +		rcu_assign_pointer(pl->pcs->phylink, NULL);

[Severity: Low]
Does this add a new lifetime requirement on the PCS for callers of
phylink_destroy()?

Before this patch, phylink_destroy() never touched the PCS. pl->pcs is
only reassigned in phylink_major_config() and is not cleared by
phylink_stop(). So at destroy time it still points at the last PCS
returned by mac_select_pcs().

If a MAC or DSA driver freed its PCS after phylink_stop() and before
phylink_destroy() (via xpcs_destroy_pcs(), lynx_pcs_destroy(),
mtk_pcs_lynxi_destroy() and so on), that order used to be harmless. With
this change it becomes a write into freed memory.

I couldn't find an in-tree caller that uses this order today. stmmac,
txgbe, altera_tse, enetc, dpaa and the DSA teardown paths all call
phylink_destroy() before they free the PCS. So this is about the API
contract rather than a current trigger.

The kernel-doc for phylink_destroy() still only says:

 * Destroy a phylink instance. Any PHY that has been attached must have been
 * cleaned up via phylink_disconnect_phy() prior to calling this function.

Should it also say that the last selected PCS must still be allocated
when phylink_destroy() is called? This is a Fixes: tagged patch, so
external drivers on stable kernels would pick up the new requirement.

The same requirement remains later in the series. There, phylink_destroy()
goes through phylink_detach_pcss(), which keeps the dereference for the
legacy mac_select_pcs path:

	if (pl->pcs) {
		rcu_assign_pointer(pl->pcs->phylink, NULL);
		WRITE_ONCE(pl->pcs, NULL);
	}

The phylink_destroy() kernel-doc is still unchanged at that point.

> +
> +	/*
> +	 * Unconditionally wait for readers that may have obtained this
> +	 * phylink through a PCS while phylink_major_config() was clearing
> +	 * the association.
> +	 */
> +	synchronize_rcu();
> +
>  	cancel_work_sync(&pl->resolve);
>  	kfree(pl);
>  }

[ ... ]

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261129230558.612526-1-ansuelsmth%40gmail.com
Technical Details
Message-ID: <179608245167.3146.15498248175431354564@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374528-linux-kernel-netdev=dewy.ru
References: <20261129230558.612526-2-ansuelsmth@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-374528-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v23 01/15] net: phylink: make PCS phylink
 instance access RCU protected
Date: Mon, 30 Nov 2026 23:47:31 +0000
Organization: Usenet Network
Message-ID: <179608245167.3146.15498248175431354564@kernel.org>
References: <20261129230558.612526-2-ansuelsmth@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1568392"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:WrqcQembMprerZPUc0tbHrOgq4o= sha256:g7Y3higU1j/HQgcjB57Pr1qLM3QgsIQzJB+IUIW82yk=
	sha1:BuNJ7luvmEWD2Su049D/3q47Om4= sha256:eGsn1XWmID2Hn96p6WXBIoAkfZplOMETDM+5YqizFv8=
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 9D107126015; Tue,  1 Dec 2026 02:47:56 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	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=kernel.org
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 AEYtrhqsY7Jb;
	Tue,  1 Dec 2026 02:47:53 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-374528-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id F34BE126018; Tue,  1 Dec 2026 02:47:42 +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 27A1328F07; Mon, 30 Nov 2026 23:47:36 +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=1796082454;
	b=GZUhDwKcZ7NP2CfYD2fqt4oomTylhImZdIqxvuEYtj0X6nT/M8QRtUIPRkxjXJap+Uw+
	 olIOK5ZKnGqlbrOD7dHGXUXgCVATl6ws2NHndfuGAk2snslatLn7fi5xNIhjcjxyWP41P
	 JAyHCrixSED7d/6PidiamQcOcjuSI7/WK+jYmRi1eDh7RIQA5jfiXE3yc5tFyYcwtFtiE
	 ad/KHadDj7MPyo3FWCSeut/js3KZgsmqnr3+gKUmyHEQyK1pEmm8lnsYs2+bVDpawthXE
	 2lPqpDFDhNgKpE6yoCzh0obWvSKFsoTWVa1JsTAT7CzIxQuxZ9+VhHs4we4fiM0VjfA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796082454;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=YG+JYaEMQnKIy6oYHiysyCh9efCCAqSQ6MsfQymQCeg=;
	b=bnSItFIlQ4ATk2z50ON04wZDX4+VqFBUc34siMAdoIi2h35PN7mEA5CVpqLhS6tmEFQz
	 pYF4hl57seBb9bNjeGM8tdrnK9PXwvLHwJ3qxkOjAL4zEe/58P5IHUUb3HE4HknOjpK9W
	 xwcLh+dTf73y4U7dcqDkeKjY3wGBVkej7c0v22RZ859O8YFvJANGs/1f0TcA87HH8BW/1
	 TxvgBJf74+60fMkRtRVGtA2sAu8PjFLgfES9pD8wpsK5wB9rSMCH5vd0AYwi3Su0SwlJd
	 EYVH24RibMbd2FpviznR5p4Lq/90Ei+dIV62qhrh/9c1QHmUSRyWZseqA0aKpxAA3ew==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="S3dC/S5r";
	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 D9C72606A337;
	Mon, 30 Nov 2026 23:47:34 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=S3dC/S5r
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796082454;
	b=3V8Yfdkdi9x0aa+imNwIpiaHm5vEcFDWoWKQWlcBMdj8GeaK489W21V1WbwZ0q6z+x+p
	 USffJxYTulJPKbaZrLnS3vwWcfrMCn7iodO3rOQVpjSQb/253qdekszM1L6mUJQVz79Lh
	 XJyz+9alxHGTPNBbwgKasJLPgA55THBVDkLyWrYNCGCexhB/njiWsEJBy4cgs+Zb5IOB0
	 TiBVsKWWTyZbhTF1a+un1bIjECEvgFJKcUqy7CqojAMjni+MkfjTONS9bP7xAKu14Zpef
	 hQ6KXRbQDOdmMGPDTC35Nsf2BOyfU/8okIyzfG1TDyBbMal8HY1e/SL6jgYjSnNFE8g==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796082454;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=YG+JYaEMQnKIy6oYHiysyCh9efCCAqSQ6MsfQymQCeg=;
	b=idTBRXXNd7VBczHiOabKc28x2yYnWhsGH4D6+XGDfueSHSFkk5z6wtWmahlawHvXQb3y
	 S6vuVYWXDMyOTT9DdV/MKCswlvdmmMohAnUBy5E90dA7c+Hp+uzAmaOu9ajubS666LsxT
	 FNFz7+GuLez/M2w0B/utZs4iGtw2VPHulPJeGV2mRtPveq5L5HQ6oucPh+tYy6FpfnbCw
	 EcDwGxTwmzuAvHDExTUKXkP9F5YKu4X6QoQ0jWAeFbu5HNY7TM+aV1Xc8QUSuGHn/6x7g
	 USxW8By/KYOD+7VqcqRuXB6ue3+ko6+6bXCTYDUYYD5iAu+HvK8hlkZ0l5iYvZi8JzQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="S3dC/S5r";
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(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 04E80606A31A;
	Mon, 30 Nov 2026 23:47:34 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 221561F000C1;
	Mon, 30 Nov 2026 23:47:32 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796082453;
	bh=YG+JYaEMQnKIy6oYHiysyCh9efCCAqSQ6MsfQymQCeg=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=S3dC/S5rbPtbYZhWamXCQ9d3xfnEuRVaa0fhtCrmQBH0rYjyjACR6HXsC6IQ2JMb/
	 0gLGXcDosJvIZte/YCpJmcOEficp7L3EqFvHfxrMRAw3bUP5U071a+VxRGXQlmC1Sh
	 bt/qADumA5A5FP2el51iLap8M07uEHMUyqNHMncgq0xm37UraZ91bCpyjSLYQmteVg
	 ya/Ps9BWgSbHA+JTm12ZVjeRlhOBphxC0faXa5QqvavOfgTNsD9SYzYF95gnnZ2aiH
	 CukBJvfCdnStFLFiqu3l28YUn4PA+ysS3Cw56ixF1OD4gjlvCjZtdZLoVY5zDtMIhA
	 n0lUDLSLfZg5A==
X-Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
 kuba@kernel.org, pabeni@redhat.com, robh@kernel.org, krzk+dt@kernel.org,
 conor+dt@kernel.org, willemb@google.com, horms@kernel.org, corbet@lwn.net,
 skhan@linuxfoundation.org, rdunlap@infradead.org, lorenzo@kernel.org,
 hkallweit1@gmail.com, linux@armlinux.org.uk, maxime.chevallier@bootlin.com,
 p.zabel@pengutronix.de, nathan@kernel.org, ndesaulniers@google.com,
 morbo@google.com, justinstitt@google.com, rmk+kernel@armlinux.org.uk,
 netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-doc@vger.kernel.org,
 linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
 linux-mediatek@lists.infradead.org, llvm@lists.linux.dev,
 zhengping.zhang@airoha.com
X-In-Reply-To: <20261129230558.612526-2-ansuelsmth@gmail.com>
X-sashiko-severity: Low
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