From: sashiko-bot@kernel.org
To: "Markus Stockhausen" <markus.stockhausen@gmx.de>
Cc: conor+dt@kernel.org, robh@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH net-next v14 06/13] net: mdio: realtek-rtl9300: suppress sysfs bind/unbind attributes
Date: Tue, 18 Aug 2026 16:27:27 +0000 [thread overview]
Message-ID: <20260818162727.AA7A41F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260817162632.1208891-7-markus.stockhausen@gmx.de>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [Critical] The proposed mitigation (`suppress_bind_attrs = true`) only prevents manual sysfs unbinding but leaves the identical Use-After-Free vulnerability unhandled during the probe error path.
--
--- Patch [6]: [PATCH net-next v14 06/13] net: mdio: realtek-rtl9300: suppress sysfs bind/unbind attributes ---
commit e83244316d6929d12214fe1f515d997dd87e2a27
Author: Markus Stockhausen <markus.stockhausen@gmx.de>
net: mdio: realtek-rtl9300: suppress sysfs bind/unbind attributes
This commit attempts to mitigate a use-after-free issue by setting
suppress_bind_attrs to true. The driver relies on devm for the central
controller structure, which can be freed early while MAC drivers still
hold references to PHY devices on the bus when unbound via sysfs.
> diff --git a/drivers/net/mdio/mdio-realtek-rtl9300.c b/drivers/net/mdio/mdio-realtek-rtl9300.c
> index 87b91aef9b56e..3360cadfb7f32 100644
> --- a/drivers/net/mdio/mdio-realtek-rtl9300.c
> +++ b/drivers/net/mdio/mdio-realtek-rtl9300.c
> @@ -839,6 +839,7 @@ static struct platform_driver otto_emdio_driver = {
> .driver = {
> .name = "mdio-rtl9300",
> .of_match_table = otto_emdio_ids,
> + .suppress_bind_attrs = true,
[Severity: Critical]
This isn't a bug introduced by this patch, but does this mitigation fully
address the load failure scenario mentioned in the commit message?
Looking at otto_emdio_probe(), the driver allocates priv via devm_kzalloc()
and then iterates over child nodes to register an MDIO bus for each:
device_for_each_child_node_scoped(dev, child) {
err = otto_emdio_probe_one(dev, priv, child);
if (err)
return err;
}
If a MAC driver concurrently attaches to a PHY on the first successfully
registered bus, it will hold a reference to the PHY device, keeping the
mii_bus structure alive.
If a subsequent child node fails to probe, otto_emdio_probe() returns an
error and triggers devres cleanup. Devres unregisters the buses but leaves
the mii_bus structure allocated due to the elevated reference count. However,
devres unconditionally frees the priv block.
If the MAC driver later attempts an MDIO operation, such as calling
otto_emdio_read_c22(), won't it dereference the freed priv pointer?
static int otto_emdio_read_c22(struct mii_bus *bus, int phy_id, int regnum)
{
struct otto_emdio_priv *priv = otto_emdio_bus_to_priv(bus);
...
scoped_guard(mutex, &priv->lock)
ret = priv->info->read_c22(bus, port, regnum, &value);
...
}
Should this probe error path also be addressed?
> },
> };
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260817162632.1208891-1-markus.stockhausen@gmx.de?part=6
next prev parent reply other threads:[~2026-08-18 16:27 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-17 16:26 [PATCH net-next v14 00/13] net: mdio: realtek-rtl9300: Add RTL83xx support Markus Stockhausen
2026-08-17 16:26 ` [PATCH net-next v14 01/13] dt-bindings: net: realtek,rtl9301-mdio: Add RTL83xx series Markus Stockhausen
2026-08-17 16:26 ` [PATCH net-next v14 02/13] net: mdio: realtek-rtl9300: Add polling documentation Markus Stockhausen
2026-08-17 16:26 ` [PATCH net-next v14 03/13] net: mdio: realtek-rtl9300: deny C45 over C22 access Markus Stockhausen
2026-08-18 16:27 ` sashiko-bot
2026-08-17 16:26 ` [PATCH net-next v14 04/13] net: phy: add phy_detach_internal() helper Markus Stockhausen
2026-08-17 16:41 ` Andrew Lunn
2026-08-18 16:27 ` sashiko-bot
2026-08-17 16:26 ` [PATCH net-next v14 05/13] net: phy: add (*notify_phy_attach/detach)() hooks to struct mii_bus Markus Stockhausen
2026-08-17 16:46 ` Andrew Lunn
2026-08-17 16:26 ` [PATCH net-next v14 06/13] net: mdio: realtek-rtl9300: suppress sysfs bind/unbind attributes Markus Stockhausen
2026-08-17 16:47 ` Andrew Lunn
2026-08-18 16:27 ` sashiko-bot [this message]
2026-08-17 16:26 ` [PATCH net-next v14 07/13] net: mdio: realtek-rtl9300: Configure hardware polling during probing Markus Stockhausen
2026-08-17 16:26 ` [PATCH net-next v14 08/13] net: mdio: realtek-rtl9300: Add page tracking Markus Stockhausen
2026-08-17 16:26 ` [PATCH net-next v14 09/13] net: mdio: realtek-rtl9300: Increase MDIO timeout Markus Stockhausen
2026-08-17 16:26 ` [PATCH net-next v14 10/13] net: mdio: realtek-rtl9300: Open up C22 and C45 space in parallel Markus Stockhausen
2026-08-17 17:03 ` Andrew Lunn
2026-08-17 17:29 ` AW: " Markus Stockhausen
2026-08-17 19:35 ` Andrew Lunn
2026-08-17 20:05 ` AW: " Markus Stockhausen
2026-08-17 20:10 ` Andrew Lunn
2026-08-17 20:25 ` AW: " Markus Stockhausen
2026-08-17 20:31 ` Andrew Lunn
2026-08-18 17:44 ` AW: " Markus Stockhausen
2026-08-18 19:32 ` Andrew Lunn
2026-08-18 16:27 ` sashiko-bot
2026-08-17 16:26 ` [PATCH net-next v14 11/13] net: mdio: realtek-rtl9300: Add support for RTL838x Markus Stockhausen
2026-08-17 16:26 ` [PATCH net-next v14 12/13] net: mdio: realtek-rtl9300: Add support for RTL839x Markus Stockhausen
2026-08-17 16:26 ` [PATCH net-next v14 13/13] net: mdio: realtek-rtl9300: reword Kconfig and module description Markus Stockhausen
2026-08-17 17:25 ` [PATCH net-next v14 00/13] net: mdio: realtek-rtl9300: Add RTL83xx support Jakub Kicinski
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=20260818162727.AA7A41F00A3A@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.