Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Aleksei Sviridkin" <f@lex.la>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [RFC PATCH net-next 9/9] net: phylink: report no link modes while a late PHY is missing
Date: Sun, 30 Aug 2026 05:26:23 +0000	[thread overview]
Message-ID: <20260830052624.0A6DB1F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260829052546.1152446-10-f@lex.la>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Uninitialized stack memory read in `macb_taprio_setup_replace`.
--

commit 0643f275f79b61c4578a88309083d8ddef0461ba
Author: Aleksei Sviridkin <f@lex.la>

net: phylink: report no link modes while a late PHY is missing

This commit modifies phylink to report no link modes and reject settings 
while a slow-to-probe PHY is still pending. This prevents the port from 
using the MAC's capabilities for a link that cannot come up yet.

> diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
> index 62e6059a18da3..857d38ed45a6a 100644
> --- a/drivers/net/phy/phylink.c
> +++ b/drivers/net/phy/phylink.c
[ ... ]
> @@ -3106,6 +3112,17 @@ int phylink_ethtool_ksettings_get(struct phylink *pl,
>  	else
>  		kset->base.port = pl->link_port;
>  
> +	/* Until the PHY arrives the port can do nothing, so report no link
> +	 * modes at all rather than the MAC's own capabilities, which is what
> +	 * an empty SFP cage reports.
> +	 */
> +	if (phylink_slow_phy_pending(pl)) {
> +		linkmode_zero(kset->link_modes.supported);
> +		kset->base.speed = SPEED_UNKNOWN;
> +		kset->base.duplex = DUPLEX_UNKNOWN;
> +		return 0;
> +	}
> +

[Severity: High]
This is a pre-existing issue, but is it possible that kset contains
uninitialized stack memory when passed to phylink_ethtool_ksettings_get()?

For example, macb_taprio_setup_replace() in
drivers/net/ethernet/cadence/macb_main.c declares struct
ethtool_link_ksettings kset without initializing it:

drivers/net/ethernet/cadence/macb_main.c:macb_taprio_setup_replace() {
    struct ethtool_link_ksettings kset;
    ...
    err = phylink_ethtool_ksettings_get(bp->phylink, &kset);
    ...
}

If a user space process configures a TAPRIO qdisc on a MACB interface that
operates without an attached PHY, this function will call
phylink_get_ksettings(), which then reads the uninitialized stack memory in
phylink_merge_link_mode():

drivers/net/phy/phylink.c:phylink_merge_link_mode() {
    linkmode_and(dst, dst, mask);
    linkmode_or(dst, dst, b);
}

Additionally, kset->base.rate_matching is read to conditionally set
kset->base.speed:

drivers/net/phy/phylink.c:phylink_get_ksettings() {
    if (kset->base.rate_matching == RATE_MATCH_NONE) {
        kset->base.speed = state->speed;
}

This uninitialized speed is later returned and used for hardware interval
calculations. Since this can be reached by untrusted input via the tc
netlink interface if user namespaces are enabled, could this result in
incorrect hardware QoS limits and trigger KMSAN use-of-uninitialized-value
warnings?

>  	linkmode_copy(kset->link_modes.supported, pl->supported);
>  
>  	switch (pl->act_link_an_mode) {

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260829052546.1152446-1-f@lex.la?part=9

      reply	other threads:[~2026-08-30  5:26 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-29  5:25 [RFC PATCH net-next 0/9] net: survive a PHY whose firmware arrives after the MAC probes Aleksei Sviridkin
2026-08-29  5:25 ` [RFC PATCH net-next 1/9] dt-bindings: net: add Airoha EN8811H PHY MCU Aleksei Sviridkin
2026-08-29  5:25 ` [RFC PATCH net-next 2/9] dt-bindings: net: ethernet-controller: add slow-to-probe Aleksei Sviridkin
2026-08-30  5:26   ` sashiko-bot
2026-09-04  0:29   ` Andrew Lunn
2026-08-29  5:25 ` [RFC PATCH net-next 3/9] net: phy: air: type the buckpbus core on the bus and address Aleksei Sviridkin
2026-09-04  0:48   ` Andrew Lunn
2026-08-29  5:25 ` [RFC PATCH net-next 4/9] net: phy: air: move the EN8811H firmware download into the library Aleksei Sviridkin
2026-09-04  1:16   ` Andrew Lunn
2026-08-29  5:25 ` [RFC PATCH net-next 5/9] net: phy: air: skip the download when the MD32 is already running Aleksei Sviridkin
2026-08-29  5:25 ` [RFC PATCH net-next 6/9] net: mdio: add Airoha EN8811H MDIO device driver Aleksei Sviridkin
2026-08-30  5:26   ` sashiko-bot
2026-09-04  1:36   ` Andrew Lunn
2026-08-29  5:25 ` [RFC PATCH net-next 7/9] net: mdio: en8811h: add the nested pass-through bus Aleksei Sviridkin
2026-09-04  1:43   ` Andrew Lunn
2026-08-29  5:25 ` [RFC PATCH net-next 8/9] net: phylink: wait for PHYs that are known to probe late Aleksei Sviridkin
2026-08-30  5:26   ` sashiko-bot
2026-08-29  5:25 ` [RFC PATCH net-next 9/9] net: phylink: report no link modes while a late PHY is missing Aleksei Sviridkin
2026-08-30  5:26   ` sashiko-bot [this message]

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=20260830052624.0A6DB1F00A3D@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=f@lex.la \
    --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