From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 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== 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== 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 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) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 221561F000C1; Mon, 30 Nov 2026 23:47:32 +0000 (UTC) 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== Subject: Re: [PATCH net-next v23 01/15] net: phylink: make PCS phylink instance access RCU protected From: netdev-bot+sashiko@kernel.org To: ansuelsmth@gmail.com 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 Date: Mon, 30 Nov 2026 23:47:31 +0000 Message-ID: <179608245167.3146.15498248175431354564@kernel.org> In-Reply-To: <20261129230558.612526-2-ansuelsmth@gmail.com> References: <20261129230558.612526-2-ansuelsmth@gmail.com> X-sashiko-severity: Low Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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