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=1796466759; b=ADeAPsViNEcc8su/RUxnB3z+c5xVjhwH5hYdOJyhf4tO3ZnTvkW+r1l+kf2/EZFGwLKU gFPe6lk+79wuM9pBr6AsAGYZFlbW2i+xJ2UJG+PVnxm4FM/XpuoWHDnKVOozQph6VXpG5 uGP1lXD3CE4UALofWwXw2aMKCEF/QQaEW7YJ7UbHrvxCcRmZ3qzmGtcRkQLAIwakwPVj1 B6zbU/hHQkjTOIJf/3fK0AhH70oiVIfMRJjQV34aghSCoyc8UfjzksclJzStJAMoN0yDC 3AIyoOBphYnRJUvlIp01obg46nLGY8gBV1Y1xlNHSiyY5Mdv7Eb/s5/M4OqN/LV2nAA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796466759; 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=MT0aucvt50v85xWdR8FlAQ7DvrrP7pzqmOYTGBj0vI0=; b=Bq+0RMcIXcDYD5Yq+FjPN1QYt7lvU++BYlsP3tQYw4HAkzi0WHOBykIPsQLwNDxhFV5v vlNQ+jOT8WF40ZHqyt3sujDTQpPKk0m1A2QniRcqX0V/+uS35X/wOsvGZ98OwFpHuwchP oU6/YU1abe7OpxdW7S7+MiWUHplTlCsHVSuGpFf8W0Ph3FOBYDas+brqDlfJcesccE9jh CmxTfNXDQM1t8hxbz9v9oUusLMIRX8NG4mjHrnau4KruGshRfWvho5ruCf3tOImVm7Op2 YIXP9Hpv0dTHAQV38aCoiI5kd92DBMhRYJ0cb6baLYcRukHvu/bXAHQ9qfREipjIx9A== 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=QRQ3n3qU; 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 5A832606A682; Sat, 5 Dec 2026 10:32:39 +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=QRQ3n3qU Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39D931F0092B; Sat, 5 Dec 2026 10:32:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796466759; bh=MT0aucvt50v85xWdR8FlAQ7DvrrP7pzqmOYTGBj0vI0=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=QRQ3n3qUZ8tkCoJJWGTOhnx1Felv+7e2T3w8WlACZeh4pEvsEzSzTrVKkT3hq5yrt Pn2iqCwGAf1w4Xkxba42PAJst/PtW6bpsfRQ1cAIkCuAZM51RMDir83D0cQzC369Le eGDTlRM9UkMK8vjpzZBGUj/4+ebHrYtgrvybtMH/zlYCrMXXCjLkKpawYP7PcYuNaq S9O4g+EgfnUbhjaIbnuCSEML0/WHwKrKliSKbw3shWgdy5z8a0ERAFPi98/RExlbZQ 42vhdZPT5c0ka/rHJXGcIr5o+vr5gmnsKJ4yEBHllxg+upVU7O45q6VBCM3HSrMUgi 6HgCw4jUJTIPg== Subject: Re: [PATCH net-next v5 2/4] r8169: hold MDIO bus lock while loading firmware From: netdev-bot+sashiko@kernel.org To: javen_xu@realsil.com.cn Cc: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, nb@tipi-net.de, maxime.chevallier@bootlin.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, daniel@makrotopia.org, vladimir.oltean@nxp.com Date: Sat, 05 Dec 2026 10:32:37 +0000 Message-ID: <179646675777.3146.12988826761903830464@kernel.org> In-Reply-To: <20261201094454.1150-3-javen_xu@realsil.com.cn> References: <20261201094454.1150-3-javen_xu@realsil.com.cn> X-sashiko-severity: Low Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@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] The commit message reads as preventive hardening, but the patch fixes a race that already exists before this series. -- r8169: hold MDIO bus lock while loading firmware This patch takes the MDIO bus lock around rtl_fw_write_firmware() in r8169_apply_firmware(). Other phylib users then cannot interleave their PHY accesses with the firmware sequence. The lock is skipped when there is no phydev, and tp->ocp_base is restored before the lock is released. > rtl_fw_write_firmware() accesses PHY registers directly, bypassing > phylib. Hold MDIO bus lock meanwhile, so other phylib users cannot > interleave their accesses with the firmware sequence. [Severity: Low] The code change looks right. However, the message reads like preventive hardening. Isn't this race already reachable before this series? Before this patch, r8169_apply_firmware() ran the firmware sequence without the MDIO bus lock: r8169_apply_firmware() rtl_fw_write_firmware() rtl_writephy() / rtl_readphy() r8168g_mdio_write() / r8168g_mdio_read() r8168_phy_ocp_write() / r8168_phy_ocp_read() r8168_phy_ocp_read() writes, polls and then reads the shared GPHY_OCP register. That is not atomic: RTL_W32(tp, GPHY_OCP, reg << 15); return rtl_loop_wait_high(tp, &rtl_ocp_gphy_cond, 25, 10) ? (RTL_R32(tp, GPHY_OCP) & 0xffff) : -ETIMEDOUT; Firmware writes to register 0x1f also change the shared tp->ocp_base. In the same tree, rtl822x_probe() in drivers/net/phy/realtek/ already calls rtl822x_hwmon_init() for the internal NBASE-T PHYs (RTL_8221B, RTL_8251B, RTL_8261C and 0x001cc841). A read of the 0444 temp1_input or temp1_max file follows this path: rtl822x_hwmon_read() phy_read_mmd(phydev, MDIO_MMD_VEND2, RTL822X_VND2_TSRR) rtl822x_read_mmd() r8169_mdio_read_reg_c45() r8168_phy_ocp_read() That path holds only the MDIO bus lock. Suppose the hwmon file is read while rtl_open(), the reset work or resume runs this chain: rtl8169_init_phy() r8169_hw_phy_config() rtl8125b_hw_phy_config() (or the 8125d/8126a/8127a variants) r8169_apply_firmware() Can the two OCP access sequences interleave? That could corrupt a firmware write, or a firmware PHY_READ could return the hwmon register value, and the PHY would be left with a broken firmware patch. If so, could the commit message say what goes wrong without the lock? Could it also carry a Fixes: tag for the commit that added hwmon support for these PHYs, so the patch is routed to net and stable? -- Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201094454.1150-1-javen_xu%40realsil.com.cn