* [PATCH] net: phylink: reject unsupported speed/duplex in ksettings_set() with PHY
@ 2026-07-01 3:17 muhammad.nazim.amirul.nazle.asmade
2026-07-01 8:29 ` Maxime Chevallier
0 siblings, 1 reply; 3+ messages in thread
From: muhammad.nazim.amirul.nazle.asmade @ 2026-07-01 3:17 UTC (permalink / raw)
To: linux, andrew, hkallweit1
Cc: davem, edumazet, kuba, pabeni, netdev, linux-kernel
From: Nazim Amirul <muhammad.nazim.amirul.nazle.asmade@altera.com>
When using ethtool to change speed and duplex on a phylink-managed
interface with a PHY attached, the requested speed/duplex combination
is not validated against the MAC's supported capabilities before being
passed down to the PHY layer.
commit df0acdc59b09 ("net: phylink: fix ksettings_set() ethtool call")
and commit 03c44a21d033 ("net: phylink: actually fix ksettings_set()
ethtool call") introduced masking of the PHY advertising modes against
pl->supported, but did not add an explicit check that the requested
speed/duplex itself is within the MAC's capability set.
The AUTONEG_DISABLE path in the non-PHY case already uses
phy_caps_lookup() to validate speed/duplex against pl->supported.
Extend the same validation to the pl->phydev path so that ethtool
requests for unsupported speed/duplex combinations are rejected with
-EINVAL before reaching the PHY layer.
Signed-off-by: Nazim Amirul <muhammad.nazim.amirul.nazle.asmade@altera.com>
---
drivers/net/phy/phylink.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 087ac63f9193..22f9bbd381bd 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -2989,6 +2989,10 @@ int phylink_ethtool_ksettings_set(struct phylink *pl,
if (pl->phydev) {
struct ethtool_link_ksettings phy_kset = *kset;
+ if (!phy_caps_lookup(kset->base.speed, kset->base.duplex,
+ pl->supported, true))
+ return -EINVAL;
+
linkmode_and(phy_kset.link_modes.advertising,
phy_kset.link_modes.advertising,
pl->supported);
--
2.43.7
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] net: phylink: reject unsupported speed/duplex in ksettings_set() with PHY 2026-07-01 3:17 [PATCH] net: phylink: reject unsupported speed/duplex in ksettings_set() with PHY muhammad.nazim.amirul.nazle.asmade @ 2026-07-01 8:29 ` Maxime Chevallier 2026-07-01 14:27 ` Andrew Lunn 0 siblings, 1 reply; 3+ messages in thread From: Maxime Chevallier @ 2026-07-01 8:29 UTC (permalink / raw) To: muhammad.nazim.amirul.nazle.asmade, linux, andrew, hkallweit1 Cc: davem, edumazet, kuba, pabeni, netdev, linux-kernel Hi, On 7/1/26 05:17, muhammad.nazim.amirul.nazle.asmade@altera.com wrote: > From: Nazim Amirul <muhammad.nazim.amirul.nazle.asmade@altera.com> Target tree tag is still also missing in the subject :) > When using ethtool to change speed and duplex on a phylink-managed > interface with a PHY attached, the requested speed/duplex combination > is not validated against the MAC's supported capabilities before being > passed down to the PHY layer. > > commit df0acdc59b09 ("net: phylink: fix ksettings_set() ethtool call") > and commit 03c44a21d033 ("net: phylink: actually fix ksettings_set() > ethtool call") introduced masking of the PHY advertising modes against > pl->supported, but did not add an explicit check that the requested > speed/duplex itself is within the MAC's capability set. > > The AUTONEG_DISABLE path in the non-PHY case already uses > phy_caps_lookup() to validate speed/duplex against pl->supported. > Extend the same validation to the pl->phydev path so that ethtool > requests for unsupported speed/duplex combinations are rejected with > -EINVAL before reaching the PHY layer. > > Signed-off-by: Nazim Amirul <muhammad.nazim.amirul.nazle.asmade@altera.com> > --- > drivers/net/phy/phylink.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c > index 087ac63f9193..22f9bbd381bd 100644 > --- a/drivers/net/phy/phylink.c > +++ b/drivers/net/phy/phylink.c > @@ -2989,6 +2989,10 @@ int phylink_ethtool_ksettings_set(struct phylink *pl, > if (pl->phydev) { > struct ethtool_link_ksettings phy_kset = *kset; > > + if (!phy_caps_lookup(kset->base.speed, kset->base.duplex, > + pl->supported, true)) > + return -EINVAL; > + > linkmode_and(phy_kset.link_modes.advertising, > phy_kset.link_modes.advertising, > pl->supported); I can indeed reproduce that, with a 1000FD-only mac, running ethtool -s eth2 speed 1000 duplex half autoneg off brings the link down, no error reported, and running ethtool -s eth2 speed 1000 duplex half autoneg on also brings the link down, with Advertised link modes: Not reported This is expected, but yeah no error reported. I think rejecting these settings makes sense, I'm however wondering wether this is a fix or not, as this will change user-visible behaviour. I'd err to the side of caution and send that to net-next, but maybe Andrew will have more insight :) So at least, you'll have to resubmit targetting the correct tree. Maxime ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: phylink: reject unsupported speed/duplex in ksettings_set() with PHY 2026-07-01 8:29 ` Maxime Chevallier @ 2026-07-01 14:27 ` Andrew Lunn 0 siblings, 0 replies; 3+ messages in thread From: Andrew Lunn @ 2026-07-01 14:27 UTC (permalink / raw) To: Maxime Chevallier Cc: muhammad.nazim.amirul.nazle.asmade, linux, hkallweit1, davem, edumazet, kuba, pabeni, netdev, linux-kernel > I think rejecting these settings makes sense, I'm however wondering > wether this is a fix or not, as this will change user-visible behaviour. > I'd err to the side of caution and send that to net-next, but maybe > Andrew will have more insight :) net-next seems reasonable. Andrew ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-01 14:27 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-07-01 3:17 [PATCH] net: phylink: reject unsupported speed/duplex in ksettings_set() with PHY muhammad.nazim.amirul.nazle.asmade 2026-07-01 8:29 ` Maxime Chevallier 2026-07-01 14:27 ` Andrew Lunn
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox