lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20251025160905.3857885-285-sashal@kernel.org>
Date: Sat, 25 Oct 2025 11:58:36 -0400
From: Sasha Levin <sashal@...nel.org>
To: patches@...ts.linux.dev,
	stable@...r.kernel.org
Cc: Parthiban Veerasooran <parthiban.veerasooran@...rochip.com>,
	Andrew Lunn <andrew@...n.ch>,
	Jakub Kicinski <kuba@...nel.org>,
	Sasha Levin <sashal@...nel.org>,
	netdev@...r.kernel.org
Subject: [PATCH AUTOSEL 6.17-6.12] microchip: lan865x: add ndo_eth_ioctl handler to enable PHY ioctl support

From: Parthiban Veerasooran <parthiban.veerasooran@...rochip.com>

[ Upstream commit 34c21e91192aa1ff66f9d6cef8132717840d04e6 ]

Introduce support for standard MII ioctl operations in the LAN865x
Ethernet driver by implementing the .ndo_eth_ioctl callback. This allows
PHY-related ioctl commands to be handled via phy_do_ioctl_running() and
enables support for ethtool and other user-space tools that rely on ioctl
interface to perform PHY register access using commands like SIOCGMIIREG
and SIOCSMIIREG.

This feature enables improved diagnostics and PHY configuration
capabilities from userspace.

Signed-off-by: Parthiban Veerasooran <parthiban.veerasooran@...rochip.com>
Reviewed-by: Andrew Lunn <andrew@...n.ch>
Link: https://patch.msgid.link/20250828114549.46116-1-parthiban.veerasooran@microchip.com
Signed-off-by: Jakub Kicinski <kuba@...nel.org>
Signed-off-by: Sasha Levin <sashal@...nel.org>
---

LLM Generated explanations, may be completely bogus:

YES

Rationale
- What changed: The driver adds a single netdev op in
  drivers/net/ethernet/microchip/lan865x/lan865x.c to forward Ethernet
  ioctls to the PHY layer:
  - drivers/net/ethernet/microchip/lan865x/lan865x.c:330 sets
    `.ndo_eth_ioctl = phy_do_ioctl_running,` alongside existing ops such
    as `.ndo_open`, `.ndo_stop`, and `.ndo_set_mac_address`.
- Behavior enabled: With `.ndo_eth_ioctl` wired to
  `phy_do_ioctl_running`, standard MII ioctls are handled by the PHY
  core’s generic handler, enabling tools to read/write PHY registers:
  - `phy_do_ioctl_running()` checks the device is up (`netif_running`)
    and defers to `phy_do_ioctl()` (drivers/net/phy/phy.c:456).
  - `phy_do_ioctl()` dispatches to `phy_mii_ioctl()`, which implements
    SIOCGMIIPHY/SIOCGMIIREG/SIOCSMIIREG and hwtstamp handling
    (drivers/net/phy/phy.c:310, 322, 326, 345, 407).
- Preconditions are satisfied in this driver: The LAN865x stack actually
  attaches a PHY to the netdev via the OA-TC6 framework, so
  `dev->phydev` is valid:
  - `phy_connect_direct(tc6->netdev, tc6->phydev, ...)` in
    drivers/net/ethernet/oa_tc6.c:565 ensures the PHY is registered and
    attached, making the generic PHY ioctl path applicable.
- User impact fixed: Without this hook, standard userspace
  diagnostics/configuration via ioctl (mii-tool, legacy ethtool ioctl
  paths, register access) fail against this device. Enabling
  `.ndo_eth_ioctl` restores expected, widely used functionality for PHY
  access (SIOCGMIIREG/SIOCSMIIREG).
- Small, low-risk change:
  - Single-line addition in the driver’s `net_device_ops`, no
    architectural changes, no behavioral changes in normal TX/RX paths.
  - The chosen helper is the conservative variant:
    `phy_do_ioctl_running()` returns `-ENODEV` if the interface is down
    (drivers/net/phy/phy.c:456), reducing risk.
  - This pattern is standard across many Ethernet drivers (e.g.,
    drivers/net/usb/lan78xx.c:4600,
    drivers/net/ethernet/ti/cpsw_new.c:1135), indicating established
    practice and low regression potential.
- Stable criteria fit:
  - Fixes a user-visible deficiency (inability to use standard PHY
    ioctls) with a minimal, contained change.
  - No new kernel ABI; it wires the driver into existing, generic PHY
    ioctl support.
  - Touches only one driver; no core subsystem churn.
  - Although the commit message frames it as “introduce support,”
    functionally it corrects missing standard behavior expected by
    tooling, which is commonly accepted as a fix.

Recommendation
- Backport to stable series that include both the LAN865x driver and the
  `ndo_eth_ioctl`/`phy_do_ioctl_running` API (for older series lacking
  `ndo_eth_ioctl`, the analogous `.ndo_do_ioctl = phy_do_ioctl_running`
  pattern may be necessary).

 drivers/net/ethernet/microchip/lan865x/lan865x.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/microchip/lan865x/lan865x.c b/drivers/net/ethernet/microchip/lan865x/lan865x.c
index 79b800d2b72c2..b428ad6516c5e 100644
--- a/drivers/net/ethernet/microchip/lan865x/lan865x.c
+++ b/drivers/net/ethernet/microchip/lan865x/lan865x.c
@@ -326,6 +326,7 @@ static const struct net_device_ops lan865x_netdev_ops = {
 	.ndo_start_xmit		= lan865x_send_packet,
 	.ndo_set_rx_mode	= lan865x_set_multicast_list,
 	.ndo_set_mac_address	= lan865x_set_mac_address,
+	.ndo_eth_ioctl          = phy_do_ioctl_running,
 };
 
 static int lan865x_probe(struct spi_device *spi)
-- 
2.51.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ