From: sashiko-bot@kernel.org
To: "Markus Stockhausen" <markus.stockhausen@gmx.de>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH net-next v12 04/11] net: mdio: realtek-rtl9300: suppress sysfs bind/unbind attributes
Date: Tue, 04 Aug 2026 17:19:59 +0000 [thread overview]
Message-ID: <20260804171959.A95151F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260803171853.507506-5-markus.stockhausen@gmx.de>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the patch attempts to fix a devm-related use-after-free by suppressing sysfs unbind, while leaving the exact same use-after-free vulnerability open during probe failure and parent device removal. The underlying structural flaw (mismatched lifetimes between devm-managed `priv` and refcounted `mii_bus`) is not addressed.
--
--- Patch [4]: [PATCH net-next v12 04/11] net: mdio: realtek-rtl9300: suppress sysfs bind/unbind attributes ---
commit d996574f6db0effaeff6b6c77116223c1f0e43d9
Author: Markus Stockhausen <markus.stockhausen@gmx.de>
net: mdio: realtek-rtl9300: suppress sysfs bind/unbind attributes
This patch attempts to fix a use-after-free issue when the Realtek MDIO
driver is unbound via sysfs. It suppresses sysfs bind/unbind attributes to
prevent manual unbinding, mitigating the lifetime mismatch between
devm-managed resources and reference-counted MDIO buses.
> diff --git a/drivers/net/mdio/mdio-realtek-rtl9300.c b/drivers/net/mdio/mdio-realtek-rtl9300.c
> index 73ac5fdcd2674..1873928b362dd 100644
> --- a/drivers/net/mdio/mdio-realtek-rtl9300.c
> +++ b/drivers/net/mdio/mdio-realtek-rtl9300.c
> @@ -830,6 +830,7 @@ static struct platform_driver otto_emdio_driver = {
> .driver = {
> .name = "mdio-rtl9300",
> .of_match_table = otto_emdio_ids,
> + .suppress_bind_attrs = true,
[Severity: High]
This isn't a bug introduced by this patch, but does this fully mitigate the
use-after-free vulnerability?
While this prevents manual unbinding via sysfs, the same mismatched resource
lifetime issue appears to remain open during probe failures and parent device
removal.
If otto_emdio_probe() fails on a later child node iteration, devres cleanup
is triggered. This unregisters the previously registered MDIO bus and frees
the central priv structure:
drivers/net/mdio/mdio-realtek-rtl9300.c:otto_emdio_probe() {
...
for_each_available_child_of_node(np, child) {
err = otto_emdio_probe_one(dev, priv, child);
if (err)
return err;
...
}
If a MAC driver already holds a reference to a PHY device on the registered
bus, it keeps the mii_bus structure alive. If the MAC driver subsequently
accesses the PHY during its teardown, the bus read operation will dereference
the freed priv pointer to acquire the lock:
drivers/net/mdio/mdio-realtek-rtl9300.c:otto_emdio_read_c22() {
...
scoped_guard(mutex, &priv->lock)
ret = priv->info->read_c22(bus, port, regnum, &value);
...
}
Since the underlying structural flaw isn't addressed by suppressing sysfs
unbinding, would it be safer to fix the mismatched lifetimes directly?
> },
> };
>
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260803171853.507506-1-markus.stockhausen@gmx.de?part=4
next prev parent reply other threads:[~2026-08-04 17:20 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 17:18 [PATCH net-next v12 00/11] net: mdio: realtek-rtl9300: Add RTL83xx support Markus Stockhausen
2026-08-03 17:18 ` [PATCH net-next v12 01/11] dt-bindings: net: realtek,rtl9301-mdio: Add RTL83xx series Markus Stockhausen
2026-08-03 17:18 ` [PATCH net-next v12 02/11] net: mdio: realtek-rtl9300: Add polling documentation Markus Stockhausen
2026-08-03 17:18 ` [PATCH net-next v12 03/11] net: phy: add (*notify_phy_attach/detach)() hooks to struct mii_bus Markus Stockhausen
2026-08-04 17:19 ` sashiko-bot
2026-08-03 17:18 ` [PATCH net-next v12 04/11] net: mdio: realtek-rtl9300: suppress sysfs bind/unbind attributes Markus Stockhausen
2026-08-04 17:19 ` sashiko-bot [this message]
2026-08-03 17:18 ` [PATCH net-next v12 05/11] net: mdio: realtek-rtl9300: Configure hardware polling during probing Markus Stockhausen
2026-08-04 17:19 ` sashiko-bot
2026-08-03 17:18 ` [PATCH net-next v12 06/11] net: mdio: realtek-rtl9300: Add page tracking Markus Stockhausen
2026-08-03 17:18 ` [PATCH net-next v12 07/11] net: mdio: realtek-rtl9300: Increase MDIO timeout Markus Stockhausen
2026-08-03 17:18 ` [PATCH net-next v12 08/11] net: mdio: realtek-rtl9300: Check for C45 support during setup Markus Stockhausen
2026-08-03 17:18 ` [PATCH net-next v12 09/11] net: mdio: realtek-rtl9300: Add support for RTL838x Markus Stockhausen
2026-08-03 17:18 ` [PATCH net-next v12 10/11] net: mdio: realtek-rtl9300: Add support for RTL839x Markus Stockhausen
2026-08-03 17:18 ` [PATCH net-next v12 11/11] net: mdio: reword MDIO_REALTEK_RTL9300 Kconfig Markus Stockhausen
2026-08-03 20:07 ` [PATCH net-next v12 00/11] net: mdio: realtek-rtl9300: Add RTL83xx support Jakub Kicinski
2026-08-03 20:25 ` AW: " Markus Stockhausen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260804171959.A95151F00A3D@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=markus.stockhausen@gmx.de \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox