From: sashiko-bot@kernel.org
To: "Birger Koblitz" <mail@birger-koblitz.de>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH net-next v19 01/13] phylink: Add phylink_mac_interrupt
Date: Sun, 11 Oct 2026 04:54:52 +0000 [thread overview]
Message-ID: <sashiko-outbox-167008@kernel.org> (raw)
In-Reply-To: <20261010-ax88179a-v19-1-7475173cfb56@birger-koblitz.de>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] phylink: UAF and TOCTOU in phylink_mac_interrupt due to lockless phydev access
--
commit 667c3fb1a09bf0994b40559aee9027d3f9775442
Author: Birger Koblitz <mail@birger-koblitz.de>
phylink: Add phylink_mac_interrupt
Adds the phylink_mac_interrupt() function to phylink, passing link-change
interrupts received by the MAC to phylib.
> diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
> index a7d086cdc9b25..a3ca7993eb7e0 100644
> --- a/drivers/net/phy/phylink.c
> +++ b/drivers/net/phy/phylink.c
[ ... ]
> @@ -1612,6 +1612,26 @@ static bool phylink_link_is_up(struct phylink *pl)
> return pl->netdev ? netif_carrier_ok(pl->netdev) : pl->old_link_state;
> }
>
> +/**
> + * phylink_mac_interrupt() - wrapper for phy_mac_interrupt()
> + * @pl: a pointer to a &struct phylink returned from phylink_create()
> + *
> + * Passes a link-change interrupt received by the MAC to phylib.
> + * This function may be called in interrupt context, and therefore cannot take
> + * a mutex. However, it is safe to assume that the reference to phy does not
> + * disappear during the call, as only an SFP module may be unplugged to make a
> + * PHY disappear. SFP modules however do not support interrupts.
> + */
> +void phylink_mac_interrupt(struct phylink *pl)
> +{
> + struct phy_device *phy;
> +
> + phy = pl->phydev;
> + if (phy)
> + phy_mac_interrupt(phy);
[Severity: High]
The function comment notes that SFP modules do not support interrupts. However,
when an SFP module is physically unplugged, the electrical link drops. Could
this link drop trigger the MAC interrupt being handled here?
If so, can this race with the concurrent SFP unplug worker and cause a
use-after-free?
The SFP unplug worker concurrently clears the pointer without RCU
synchronization:
drivers/net/phy/phylink.c:phylink_disconnect_phy() {
...
pl->phydev = NULL;
...
}
And then immediately frees the PHY device:
drivers/net/phy/sfp.c:sfp_sm_phy_detach() {
...
phy_device_free(sfp->mod_phy);
...
}
Because phylink_mac_interrupt() reads pl->phydev locklessly and without an
RCU read-side critical section, is it possible for the interrupt to fetch the
pointer right before the worker frees it?
Additionally, does the lack of READ_ONCE() here allow the compiler to reload
pl->phydev after the if (phy) check, potentially causing a time-of-check to
time-of-use NULL pointer dereference?
> +}
> +EXPORT_SYMBOL_GPL(phylink_mac_interrupt);
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261010-ax88179a-v19-0-7475173cfb56@birger-koblitz.de?part=1
next prev parent reply other threads:[~2026-10-11 4:54 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-10 4:54 [PATCH net-next v19 00/13] ax88179_178a: Add support for AX88179A-based chips Birger Koblitz
2026-10-10 4:54 ` [PATCH net-next v19 01/13] phylink: Add phylink_mac_interrupt Birger Koblitz
2026-10-11 4:54 ` sashiko-bot [this message]
2026-10-11 5:32 ` Birger Koblitz
2026-10-10 4:54 ` [PATCH net-next v19 02/13] phylib: Add support for PHYs with broken forced mode Birger Koblitz
2026-10-11 4:54 ` sashiko-bot
2026-10-10 4:54 ` [PATCH net-next v19 03/13] ax88179_178a: Split driver into library and device specific code Birger Koblitz
2026-10-11 4:54 ` sashiko-bot
2026-10-10 4:54 ` [PATCH net-next v19 04/13] ax88179_178a: Add HW support for AX179A-based chips Birger Koblitz
2026-10-11 4:54 ` sashiko-bot
2026-10-10 4:54 ` [PATCH net-next v19 05/13] ax88179_178a: Add EEE configuration support for AX88179A MACs Birger Koblitz
2026-10-11 4:54 ` sashiko-bot
2026-10-10 4:54 ` [PATCH net-next v19 06/13] ax88179_178a: Add EEE configuration support for AX88179A PHYs Birger Koblitz
2026-10-11 4:54 ` sashiko-bot
2026-10-10 4:54 ` [PATCH net-next v19 07/13] ax88179_178a: Add VLAN offload support for AX88179A Birger Koblitz
2026-10-11 4:54 ` sashiko-bot
2026-10-10 4:54 ` [PATCH net-next v19 08/13] ax88179_178a: Add AX179A/AX279 multicast configuration Birger Koblitz
2026-10-11 4:54 ` sashiko-bot
2026-10-10 4:54 ` [PATCH net-next v19 09/13] ax88179_178a: Add Suspend/resume support for AX88179A/772D/279 Birger Koblitz
2026-10-11 4:54 ` sashiko-bot
2026-10-10 4:54 ` [PATCH net-next v19 10/13] ax88179_178a: Add ethtool get_drvinfo Birger Koblitz
2026-10-11 4:54 ` sashiko-bot
2026-10-10 4:54 ` [PATCH net-next v19 11/13] ax88179_178a: Update driver name and information Birger Koblitz
2026-10-11 4:54 ` sashiko-bot
2026-10-10 4:54 ` [PATCH net-next v19 12/13] ax88179_178a: Add support for AX88179A/772D/279 EEPROM access Birger Koblitz
2026-10-11 4:55 ` sashiko-bot
2026-10-10 4:54 ` [PATCH net-next v19 13/13] ax88796b: Add support for AX88772D, AX88179A and AX88279 Birger Koblitz
2026-10-11 4:55 ` sashiko-bot
2026-10-10 6:20 ` [PATCH v19 0/13] ax88179_178a: Add support for AX88179A-based chips Jianhui Xu
2026-10-10 7:42 ` Birger Koblitz
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=sashiko-outbox-167008@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mail@birger-koblitz.de \
--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.