Skip to contentSkip to conversation

wifi: nl80211: don't WARN on a missing self-managed regdom

PATCH In review François Roux 3 participants 6 messages Oct 6 – Oct 11 802.11 (including cfg80211/NL80211)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wifi: nl80211: don't WARN on a missing self-managed regdom

nl80211_get_reg_do() has a WARN_ON() for a self-managed wiphy without a private regdomain. Userspace can trigger it with a plain NL80211_CMD_GET_REG request.

Drivers can register such a wiphy first and set its regdomain later. ath12k, for example, calls ieee80211_register_hw() and only then applies the regdomain with ath12k_regd_update(). iwd queries the regdomain of a new wiphy as soon as it shows up, so it can hit that window at boot:

  WARNING: net/wireless/nl80211.c:10828 at nl80211_get_reg_do+0x1d0/0x1fc [cfg80211], CPU#5: iwd/721
  Call trace:
   nl80211_get_reg_do+0x1d0/0x1fc [cfg80211] (P)
   genl_family_rcv_msg_doit+0xd0/0x138
   genl_rcv_msg+0x58/0xd4
   netlink_rcv_skb+0x5c/0x140
   genl_rcv+0x34/0x4c
   netlink_unicast+0x31c/0x39c
   netlink_sendmsg+0x188/0x400

The same trace has been reported with an Intel BE200 (iwlwifi). The dump variant, nl80211_get_reg_dump(), already skips a wiphy without a regdomain without warning.

Keep returning -EINVAL, but drop the WARN_ON(). The same change was posted in 2021 but was never applied.

Seen on a Microsoft Surface Pro 11 (WCN7850, ath12k) in 3 of 4 boots with next-20260929.

---
 net/wireless/nl80211.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
net/wireless/nl80211.c +6 -2
index a18240455..2589491af 100644
@@ -10824,8 +10824,12 @@ static int nl80211_get_reg_do(struct sk_buff *skb, struct genl_info *info)
 
 		regdom = get_wiphy_regdom(wiphy);
 
-		/* a self-managed-reg device must have a private regdom */
-		if (WARN_ON(!regdom && self_managed)) {
+		/*
+		 * A self-managed-reg device gets its private regdom from the
+		 * driver, which may happen only after the wiphy is registered.
+		 * Userspace can ask before that, so don't WARN.
+		 */
+		if (!regdom && self_managed) {
 			err = -EINVAL;
 			goto nla_put_failure_rcu;
 		}

base-commit: 6474fa070f2b8013b4b87350b775b8c3be6e8aac

Signature · 1 line
2.56.0
Tested-by on v1 1/1
#1 lore raw

Hi François,

Quoted 23 lines · François Roux

nl80211_get_reg_do() has a WARN_ON() for a self-managed wiphy without a private regdomain. Userspace can trigger it with a plain NL80211_CMD_GET_REG request.

Drivers can register such a wiphy first and set its regdomain later. ath12k, for example, calls ieee80211_register_hw() and only then applies the regdomain with ath12k_regd_update(). iwd queries the regdomain of a new wiphy as soon as it shows up, so it can hit that window at boot:

  WARNING: net/wireless/nl80211.c:10828 at nl80211_get_reg_do+0x1d0/0x1fc [cfg80211], CPU#5: iwd/721
  Call trace:
   nl80211_get_reg_do+0x1d0/0x1fc [cfg80211] (P)
   genl_family_rcv_msg_doit+0xd0/0x138
   genl_rcv_msg+0x58/0xd4
   netlink_rcv_skb+0x5c/0x140
   genl_rcv+0x34/0x4c
   netlink_unicast+0x31c/0x39c
   netlink_sendmsg+0x188/0x400

The same trace has been reported with an Intel BE200 (iwlwifi). The dump variant, nl80211_get_reg_dump(), already skips a wiphy without a regdomain without warning.

Quoted 5 lines

Keep returning -EINVAL, but drop the WARN_ON(). The same change was posted in 2021 but was never applied.

Seen on a Microsoft Surface Pro 11 (WCN7850, ath12k) in 3 of 4 boots with next-20260929.

Thanks for this patch :-)

I added it to my 7.3-rc6 based kernel and booted into it.
With that kernel but without this patch, I (still) got the stack trace as I reported earlier. But with this patch applied, I only see the following in dmesg when I start ``iwd.service``:

```sh
[   99.031552] ACPI: <n/a>: failed to evaluate _DSM bf0212f2-788f-c64d-a5b3-1f738e285ade rev:0 func:0 (0x1001)
[   99.619075] wlan0: authenticate with 20:05:b7:00:29:19 (local address=f8:cf:52:97:97:58)
[   99.619887] wlan0: send auth to 20:05:b7:00:29:19 (try 1/3)
[   99.622752] wlan0: authenticated
[   99.624881] wlan0: associate with 20:05:b7:00:29:19 (try 1/3)
[   99.627724] wlan0: RX AssocResp from 20:05:b7:00:29:19 (capab=0x111 status=0 aid=1)
[   99.631005] wlan0: associated
[   99.657741] wlan0: Limiting TX power to 20 (23 - 3) dBm as advertised by 20:05:b7:00:29:19
```

Thus no longer a stack trace. So feel free to include my

Cheers,
Diederik

Quoted 31 lines
---
 net/wireless/nl80211.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
net/wireless/nl80211.c +6 -2
index a18240455..2589491af 100644
@@ -10824,8 +10824,12 @@ static int nl80211_get_reg_do(struct sk_buff *skb, struct genl_info *info)
 
 		regdom = get_wiphy_regdom(wiphy);
 
-		/* a self-managed-reg device must have a private regdom */
-		if (WARN_ON(!regdom && self_managed)) {
+		/*
+		 * A self-managed-reg device gets its private regdom from the
+		 * driver, which may happen only after the wiphy is registered.
+		 * Userspace can ask before that, so don't WARN.
+		 */
+		if (!regdom && self_managed) {
 			err = -EINVAL;
 			goto nla_put_failure_rcu;
 		}

base-commit: 6474fa070f2b8013b4b87350b775b8c3be6e8aac

maintainer
#2 lore raw
In reply to François Roux
Quoted 10 lines · François Roux

nl80211_get_reg_do() has a WARN_ON() for a self-managed wiphy without a private regdomain. Userspace can trigger it with a plain NL80211_CMD_GET_REG request.

Drivers can register such a wiphy first and set its regdomain later. ath12k, for example, calls ieee80211_register_hw() and only then applies the regdomain with ath12k_regd_update(). iwd queries the regdomain of a new wiphy as soon as it shows up, so it can hit that window at boot:

  WARNING: net/wireless/nl80211.c:10828 at nl80211_get_reg_do+0x1d0/0x1fc [cfg80211], CPU#5: iwd/721

I'm not a fan of this, I think the drivers should have the regdom ready.

Quoted 1 line

The same trace has been reported with an Intel BE200 (iwlwifi).

I _thought_ we fixed that issue.

Anyway I think we need to fix the bugs, not paper over them. If it comes to it we can even put a WARN_ON there to reject wiphy registration w/o a regdomain. There should be one. As it is, iwd will get empty data or something, that makes no sense.

johannes

#3 lore raw
Quoted 10 lines · Johannes Berg
Quoted 9 lines · François Roux

nl80211_get_reg_do() has a WARN_ON() for a self-managed wiphy without a private regdomain. Userspace can trigger it with a plain NL80211_CMD_GET_REG request.

Drivers can register such a wiphy first and set its regdomain later. ath12k, for example, calls ieee80211_register_hw() and only then applies the regdomain with ath12k_regd_update(). iwd queries the regdomain of a new wiphy as soon as it shows up, so it can hit that window at boot:

Quoted 7 lines
Quoted 1 line
  WARNING: net/wireless/nl80211.c:10828 at nl80211_get_reg_do+0x1d0/0x1fc [cfg80211], CPU#5: iwd/721

I'm not a fan of this, I think the drivers should have the regdom ready.

Quoted 1 line

The same trace has been reported with an Intel BE200 (iwlwifi).

I _thought_ we fixed that issue.

If that fix is supposed to be in 7.3-rc6 (from Linus), then no. If that's a recent fix/patch which is f.e. slated for -next/7.4(-rc1), then can you point me to it? Happy to test it.

Before I reported the/my issue with Intel BE200 [1] I did search a bit on the linux-wireless ML and saw some patches where ACPI was an (important?) part. That's why I (so) explicitly mentioned that my system does NOT have an ACPI based firmware (but U-Boot (with TF-A)).

Cheers,
Diederik

[1] https://lore.kernel.org/linux-wireless/[email protected]/

maintainer
#4 lore raw
Quoted 15 lines · Diederik de Haas
Quoted 14 lines · Johannes Berg
Quoted 10 lines · François Roux

nl80211_get_reg_do() has a WARN_ON() for a self-managed wiphy without a private regdomain. Userspace can trigger it with a plain NL80211_CMD_GET_REG request.

Drivers can register such a wiphy first and set its regdomain later. ath12k, for example, calls ieee80211_register_hw() and only then applies the regdomain with ath12k_regd_update(). iwd queries the regdomain of a new wiphy as soon as it shows up, so it can hit that window at boot:

  WARNING: net/wireless/nl80211.c:10828 at nl80211_get_reg_do+0x1d0/0x1fc [cfg80211], CPU#5: iwd/721

I'm not a fan of this, I think the drivers should have the regdom ready.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

The same trace has been reported with an Intel BE200 (iwlwifi).

I _thought_ we fixed that issue.

If that fix is supposed to be in 7.3-rc6 (from Linus), then no. If that's a recent fix/patch which is f.e. slated for -next/7.4(-rc1), then can you point me to it? Happy to test it.

Well, it looks like it got *reverted*.

6895d74c11d8 ("wifi: iwlwifi: mld: initialize regulatory early") f81aa834bfa9 ("wifi: iwlwifi: mld: Move regulatory domain initialization")

johannes

#5 lore raw
In reply to Johannes Berg
Quoted 1 line · Johannes Berg

I'm not a fan of this, I think the drivers should have the regdom ready.

[...]

Quoted 1 line

Anyway I think we need to fix the bugs, not paper over them.

Fair enough, please drop this patch.

I've sent an ath12k fix that applies the boot-time regdomain before ieee80211_register_hw():

https://lore.kernel.org/all/[email protected]/

wiphy_register() holds the RTNL until wiphy_regulatory_register() has applied it, and nl80211_get_reg_do() takes the RTNL too, so the window is gone. On the Surface Pro 11 the warning no longer shows up over boots and repeated driver unbind/bind, where it used to on every rebind.

Diederik, thanks a lot for testing. As Johannes said, your BE200 needs the iwlwifi side fixed instead.

François