Linux USB
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Birger Koblitz" <mail@birger-koblitz.de>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH net-next v17 02/13] phylib: Add support for PHYs with broken forced mode
Date: Wed, 07 Oct 2026 03:05:46 +0000	[thread overview]
Message-ID: <sashiko-outbox-162611@kernel.org> (raw)
In-Reply-To: <20261006-ax88179a-v17-2-252814fe35ea@birger-koblitz.de>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] phylib: NULL pointer dereference in phy_ethtool_ksettings_set()
- [Medium] phylib: Userspace can bypass PHY_BROKEN_FORCED via SIOCSMIIREG
--

commit ba73f96bed1d2e99a191c06a9e1fb6f1fd49beef
Author: Birger Koblitz <mail@birger-koblitz.de>

    phylib: Add support for PHYs with broken forced mode
    
    Add support for PHYs which only supported auto-negotiated
    speed modes. This prevents a kernel warning and stack-trace within the
    phy_state_machine when PHYs return -EOPNOTSUPP from config_aneg()
    because they do not support forced modes.

> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index fce9bc7be3304..b83f938fe7c3b 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -1190,6 +1190,10 @@ int phy_ethtool_ksettings_set(struct phy_device *phydev,
>  	      duplex != DUPLEX_FULL)))
>  		return -EINVAL;
>  
> +	if (autoneg == AUTONEG_DISABLE &&
> +	    (phydev->drv->flags & PHY_BROKEN_FORCED))
> +		return -EOPNOTSUPP;
> +

[Severity: High]
Can this unconditionally dereference phydev->drv when it might be NULL?

If a PHY driver is unbound (e.g., via sysfs), phy_remove() sets
phydev->drv = NULL but does not detach the PHY from the net_device. A
subsequent call to ethtool -s ethX autoneg off reaches
phy_ethtool_ksettings_set(). The newly added check accesses phydev->drv
without verifying it is non-NULL, which can cause a kernel oops, allowing
a privileged user to crash the system instead of receiving a graceful error.

Later in the same function, _phy_start_aneg() correctly checks for
!phydev->drv.

[Severity: Medium]
Does this fix fully prevent userspace from bypassing the check?

While this patch aims to prevent a WARN(1) and stack trace in
phy_state_machine() by blocking AUTONEG_DISABLE via ethtool for PHYs with
PHY_BROKEN_FORCED, userspace can still bypass this via the SIOCSMIIREG
ioctl.

By writing to MII_BMCR and clearing the BMCR_ANENABLE bit, phy_mii_ioctl()
intercepts it to unconditionally set phydev->autoneg = AUTONEG_DISABLE
without checking the new PHY_BROKEN_FORCED flag:

drivers/net/phy/phy.c:phy_mii_ioctl() {
    ...
					phydev->autoneg = AUTONEG_DISABLE;
					if (val & BMCR_FULLDPLX)
    ...
}

When phy_state_machine() subsequently runs and calls _phy_start_aneg(), the
driver will return -EOPNOTSUPP, and phy_error_precise() will trigger the
exact same WARN(1) the patch intended to fix.

>  	mutex_lock(&phydev->lock);
>  	phydev->autoneg = autoneg;
>

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261006-ax88179a-v17-0-252814fe35ea@birger-koblitz.de?part=2

  reply	other threads:[~2026-10-07  3:05 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-06  3:05 [PATCH net-next v17 00/13] ax88179_178a: Add support for AX88179A-based chips Birger Koblitz
2026-10-06  3:05 ` [PATCH net-next v17 01/13] phylink: Add phylink_mac_interrupt Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-07  3:55     ` Fwd: " Birger Koblitz
2026-10-07 12:18       ` Andrew Lunn
2026-10-07 14:16         ` Birger Koblitz
2026-10-08  3:34     ` Birger Koblitz
2026-10-06  3:05 ` [PATCH net-next v17 02/13] phylib: Add support for PHYs with broken forced mode Birger Koblitz
2026-10-07  3:05   ` sashiko-bot [this message]
2026-10-08  3:36     ` Birger Koblitz
2026-10-06  3:05 ` [PATCH net-next v17 03/13] ax88179_178a: Split driver into library and device specific code Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-08  3:38     ` Birger Koblitz
2026-10-06  3:05 ` [PATCH net-next v17 04/13] ax88179_178a: Add HW support for AX179A-based chips Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-08  3:41     ` Birger Koblitz
2026-10-06  3:05 ` [PATCH net-next v17 05/13] ax88179_178a: Add EEE configuration support for AX88179A MACs Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-06  3:05 ` [PATCH net-next v17 06/13] ax88179_178a: Add EEE configuration support for AX88179A PHYs Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-06  3:05 ` [PATCH net-next v17 07/13] ax88179_178a: Add VLAN offload support for AX88179A Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-08  3:44     ` Birger Koblitz
2026-10-06  3:05 ` [PATCH net-next v17 08/13] ax88179_178a: Add AX179A/AX279 multicast configuration Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-06  3:05 ` [PATCH net-next v17 09/13] ax88179_178a: Add Suspend/resume support for AX88179A/772D/279 Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-08  3:47     ` Birger Koblitz
2026-10-06  3:05 ` [PATCH net-next v17 10/13] ax88179_178a: Add ethtool get_drvinfo Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-06  3:05 ` [PATCH net-next v17 11/13] ax88179_178a: Update driver name and information Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-08  3:48     ` Birger Koblitz
2026-10-06  3:05 ` [PATCH net-next v17 12/13] ax88179_178a: Add support for AX88179A/772D/279 EEPROM access Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-06  3:05 ` [PATCH net-next v17 13/13] ax88796b: Add support for AX88772D, AX88179A and AX88279 Birger Koblitz
2026-10-07  3:05   ` sashiko-bot
2026-10-08  3:50     ` 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-162611@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox