Article View: linux.kernel.netdev
Article #27333Re: [PATCH net-next v5 2/4] r8169: hold MDIO bus lock while loading firmware
From: netdev-bot+sashiko
Date: Sat, 05 Dec 2026 10:32
Date: Sat, 05 Dec 2026 10:32
78 lines
10801 bytes
10801 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] 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
Technical Details
Message-ID:
<179646675777.3146.12988826761903830464@kernel.org>Path:
mbox-mo1.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377933-linux-kernel-netdev=dewy.ruReferences:
<20261201094454.1150-3-javen_xu@realsil.com.cn>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377933-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next v5 2/4] r8169: hold MDIO bus lock while loading firmware Date: Sat, 05 Dec 2026 10:32:37 +0000 Organization: Usenet Network Message-ID: <179646675777.3146.12988826761903830464@kernel.org> References: <20261201094454.1150-3-javen_xu@realsil.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3007402"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:2q3k0NgKFFq97/tqclVPZTNj1Zc= sha256:OpvJcTJwKj5MmEZBOZG+yNSLL5NxFhJ4BbsYckZaRK8= sha1:DnNg2v07iCqc6NyNuCBf8eGckAI= sha256:8p4B2pR76CgTEdNhp+Hhvi3s2m2ulZR5ph23LA8opBw= 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 87CDB117DE3; Sat, 5 Dec 2026 13:33:00 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.641 X-Spam-Status: No, score=-3.641 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.142, 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, URIBL_BLOCKED=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 5f82dsW6IPKi; Sat, 5 Dec 2026 13:32:58 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-377933-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id B4AA7117DE5; Sat, 5 Dec 2026 13:32:49 +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 AF1292AE72; Sat, 5 Dec 2026 10:32:45 +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=1796466765; b=fvHH7TGIGDbzTItVG3ewmYLjgsDFwIcV7EFDgoVO3QLpprDs7XtUXBo2WwLiTSb5nqQB V5rqBFkN/AMrBQbBpsLK2kKNftKcPYjLBWTVlgAIcyp4zcqrPEVHJcOY6idOR6Ru/6VMl AzCLyD/GO/9imSpkaYzulwqWn6MO1PhmkQstOk+iZnw6M42y1svDAcqxhRCfU1EHIaZba jyDMRk8WkPrzRqGWC9ZIftYhbJSquf9Vh36Ch5mHn5JBR5n+rgJcq9IW/lPGFUS6Q6z+f 6+mScIpcm+CtqdGBNlF8633KvtbfGEWMtZ/0l6LaW4k+0lrMHx41TO3R8z0OVMnpTag== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796466765; 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=MT0aucvt50v85xWdR8FlAQ7DvrrP7pzqmOYTGBj0vI0=; b=aZD4ju0GNGhAsHHlehtAmyLn960PspTA1LeSsaBiXNPOvOFRBKY/vd4RAvg7/qml5kqk 3gAXztg4ewAb3HVym1YYfFPlkVTPBr4/vj5s5lR6nLC7KJZnGrCAWu9MqWhKTQdThuaK/ yJgN1ENrkUKQwjnpj9KePrw42AiD7v1L2i2H0/KhWj56O4fSE1WdrVbY+gdeQTcPdb/FG q45yJ7P9p7Q0JBFAN1Drx1ctS7CHtO/jTXI0MLv8DyrPyp0rjm8RLlWQ4rZg9NbDPPeGW CqfHA1bFdVUtBkax92nMQcIDUrEvuCy7OOf1xvHEeAxy4gt/zZMG+EE4dnUYCyibDyg== 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=QRQ3n3qU; 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 58B17606A685; Sat, 5 Dec 2026 10:32:45 +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=QRQ3n3qU 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=1796466759; b=ADeAPsViNEcc8su/RUxnB3z+c5xVjhwH5hYdOJyhf4tO3ZnTvkW+r1l+kf2/EZFGwLKU gFPe6lk+79wuM9pBr6AsAGYZFlbW2i+xJ2UJG+PVnxm4FM/XpuoWHDnKVOozQph6VXpG5 uGP1lXD3CE4UALofWwXw2aMKCEF/QQaEW7YJ7UbHrvxCcRmZ3qzmGtcRkQLAIwakwPVj1 B6zbU/hHQkjTOIJf/3fK0AhH70oiVIfMRJjQV34aghSCoyc8UfjzksclJzStJAMoN0yDC 3AIyoOBphYnRJUvlIp01obg46nLGY8gBV1Y1xlNHSiyY5Mdv7Eb/s5/M4OqN/LV2nAA== X-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== 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=QRQ3n3qU; 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 5A832606A682; Sat, 5 Dec 2026 10:32:39 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39D931F0092B; Sat, 5 Dec 2026 10:32:38 +0000 (UTC) X-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== X-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 X-In-Reply-To: <20261201094454.1150-3-javen_xu@realsil.com.cn> 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