From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE59B606A68B for ; Mon, 30 Nov 2026 23:47:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=mwnNXndB; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=S3dC/S5r DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version: Content-Transfer-Encoding:Content-Type:References:In-Reply-To:Message-ID:Date :Cc:To:From:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=YG+JYaEMQnKIy6oYHiysyCh9efCCAqSQ6MsfQymQCeg=; b=mwnNXndBWWKc1PSqaLJXZu+gHw O5yhTArmxnvYFEeCgHxcYeX1OHdknVTUl9FPbTggd6x69BW9Ilu6CAes684Qh7N9nIbznGaanN8ez FOMVlIJr8rAbSbb/HoASDpJIWtSknOr77f7ZYqiO2eccsu3zjzfWLhV7Z/96Aa22SpV7MmsQ9LWi8 27veOeALEQTNIgxJhma3q89LR9Z7MCbJfTbEq99SZ4+u2e6cwVJw6qkzW+UarkGB6hZJ9l03tnx8u 0GaR/bekIp/ITow3ZmonjCzjf5E6TGvJKHH3GePhZJm7MlwzLQx1ZXwQVhLfT6p551I8JXIMnrBQw XXEfP8wg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYB5r-000000063xX-3IwN; Mon, 30 Nov 2026 23:47:35 +0000 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYB5q-000000063xM-2V6T; Mon, 30 Nov 2026 23:47:34 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id F22F1409E8; Mon, 30 Nov 2026 23:47:33 +0000 (UTC) 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-Archived-By: MIME-Version: 1.0 X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-10.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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