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-107-sashal@kernel.org>
Date: Sat, 25 Oct 2025 11:55:38 -0400
From: Sasha Levin <sashal@...nel.org>
To: patches@...ts.linux.dev,
	stable@...r.kernel.org
Cc: Niklas Söderlund <niklas.soderlund+renesas@...natech.se>,
	Andrew Lunn <andrew@...n.ch>,
	Geert Uytterhoeven <geert+renesas@...der.be>,
	Jakub Kicinski <kuba@...nel.org>,
	Sasha Levin <sashal@...nel.org>,
	niklas.soderlund@...natech.se,
	netdev@...r.kernel.org,
	linux-renesas-soc@...r.kernel.org
Subject: [PATCH AUTOSEL 6.17-5.4] net: sh_eth: Disable WoL if system can not suspend

From: Niklas Söderlund <niklas.soderlund+renesas@...natech.se>

[ Upstream commit 9c02ea544ac35a9def5827d30594406947ccd81a ]

The MAC can't facilitate WoL if the system can't go to sleep. Gate the
WoL support callbacks in ethtool at compile time using CONFIG_PM_SLEEP.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@...natech.se>
Reviewed-by: Andrew Lunn <andrew@...n.ch>
Reviewed-by: Geert Uytterhoeven <geert+renesas@...der.be>
Link: https://patch.msgid.link/20250909085849.3808169-1-niklas.soderlund+renesas@ragnatech.se
Signed-off-by: Jakub Kicinski <kuba@...nel.org>
Signed-off-by: Sasha Levin <sashal@...nel.org>
---

LLM Generated explanations, may be completely bogus:

YES

- What it does
  - Gates the ethtool WoL callbacks behind `CONFIG_PM_SLEEP`, so WoL is
    only reported/configurable when the system can actually suspend.
  - Specifically wraps `sh_eth_get_wol()` and `sh_eth_set_wol()` with
    `#ifdef CONFIG_PM_SLEEP` and only sets the corresponding ethtool ops
    when sleep support is enabled.

- Code references
  - Function definitions are compiled only if sleep is enabled:
    drivers/net/ethernet/renesas/sh_eth.c:2363 and
    drivers/net/ethernet/renesas/sh_eth.c:2390
  - Etwttool ops pointers are likewise conditioned:
    drivers/net/ethernet/renesas/sh_eth.c:2406 and
    drivers/net/ethernet/renesas/sh_eth.c:2409
  - The driver’s suspend/resume path that actually uses WoL state
    (`mdp->wol_enabled`) is part of PM sleep handling:
    - `sh_eth_suspend()` checks `mdp->wol_enabled` to set up Magic
      Packet WoL: drivers/net/ethernet/renesas/sh_eth.c:3500
    - `sh_eth_resume()` mirrors that to restore state:
      drivers/net/ethernet/renesas/sh_eth.c:3519
  - The driver already declares PM sleep ops via `pm_sleep_ptr`, so
    suspend/resume are only active when `CONFIG_PM_SLEEP` is enabled,
    making the ethtool gating consistent:
    drivers/net/ethernet/renesas/sh_eth.c:3553

- Why this is a bug fix
  - Without system sleep support, the suspend/resume hooks that actually
    arm/disarm WoL are not used, so advertising WoL to userspace
    (`ethtool`) is misleading and non-functional. The patch prevents
    reporting/configuring WoL when it cannot work in practice.
  - This aligns the reported capability with the runtime behavior and
    avoids users enabling a feature that can’t take effect.

- Scope and risk
  - Change is small, compile-time only, and limited to `sh_eth` ethtool
    ops and two static helpers.
  - No data path changes; no architectural changes; only affects builds
    with `CONFIG_PM_SLEEP=n`.
  - When `CONFIG_PM_SLEEP=y`, behavior is unchanged.

- Stable backport criteria
  - Fixes a real user-visible correctness issue (capability
    misreporting).
  - Minimal and self-contained to a single driver file.
  - No new features or API changes; low regression risk.
  - Consistent with existing PM gating (`pm_sleep_ptr`) in the same
    driver.

Given the above, this is an appropriate, low-risk correctness fix to
backport.

 drivers/net/ethernet/renesas/sh_eth.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index 5fc8027c92c7c..695fa3592c9a2 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -2360,6 +2360,7 @@ static int sh_eth_set_ringparam(struct net_device *ndev,
 	return 0;
 }
 
+#ifdef CONFIG_PM_SLEEP
 static void sh_eth_get_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
 {
 	struct sh_eth_private *mdp = netdev_priv(ndev);
@@ -2386,6 +2387,7 @@ static int sh_eth_set_wol(struct net_device *ndev, struct ethtool_wolinfo *wol)
 
 	return 0;
 }
+#endif
 
 static const struct ethtool_ops sh_eth_ethtool_ops = {
 	.get_regs_len	= sh_eth_get_regs_len,
@@ -2401,8 +2403,10 @@ static const struct ethtool_ops sh_eth_ethtool_ops = {
 	.set_ringparam	= sh_eth_set_ringparam,
 	.get_link_ksettings = phy_ethtool_get_link_ksettings,
 	.set_link_ksettings = phy_ethtool_set_link_ksettings,
+#ifdef CONFIG_PM_SLEEP
 	.get_wol	= sh_eth_get_wol,
 	.set_wol	= sh_eth_set_wol,
+#endif
 };
 
 /* network device open function */
-- 
2.51.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ