Repository navigation
Conversation
Until now there was not handling for NAN in reg_wdev_chan_valid. Now as this wdev might use chandefs, check the validity of those. Reviewed-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com> Link: https://patch.msgid.link/20260108102921.51b42ffc9a42.Iacb030fc17027afb55707ca1d6dc146631d55767@changeid Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com> Link: https://patch.msgid.link/20260219094725.3846371-4-miriam.rachel.korenblit@intel.com Link: https://patch.msgid.link/20260318123926.206536-3-miriam.rachel.korenblit@intel.com Signed-off-by: Johannes Berg <johannes.berg@intel.com> (cherry picked from commit 763a5a5) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
🧙 Sourcery has finished reviewing your pull request! Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 9 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="net/wireless/nl80211.c" line_range="16945" />
<code_context>
+ bool compatible = false;
+
+ ret = nl80211_parse_nan_channel(rdev, channel, info,
+ nan_channels, i, false);
+ if (ret)
+ return ret;
</code_context>
<issue_to_address>
**Large peer schedules crash the kernel**
When a caller with permission to configure NAN peer schedules submits more than 255 peer channels, which the current limit allows when the local schedule has at least 32 channels, the loop index exceeds 255, so the `u8 index` parameter of `nl80211_parse_nan_channel()` wraps while the caller later checks `nan_channels[i]` using the unwrapped index. It passes an uninitialized channel definition to `cfg80211_chandef_compatible()`, which can dereference its missing channel pointer and crash the kernel.
Reject peer schedules with more channels than the `u8` index and `n_channels` fields can represent, or use appropriately wide types and validate the count before allocation and parsing.
</issue_to_address>
### Comment 2
<location path="net/mac80211/rx.c" line_range="4546-4547" />
<code_context>
case NL80211_IFTYPE_P2P_CLIENT:
case NL80211_IFTYPE_P2P_GO:
case NL80211_IFTYPE_OCB:
+ case NL80211_IFTYPE_NAN_DATA:
/* shouldn't happen */
WARN_ON_ONCE(1);
</code_context>
<issue_to_address>
**NAN data frames never reach RX**
When a NAN_DATA frame takes the normal RX path, `ieee80211_accept_frame()` returns false for `NL80211_IFTYPE_NAN_DATA`, so `ieee80211_prepare_and_rx_handle()` stops before normal RX handling and the interface never receives the frame.
Allow NAN_DATA frames through `ieee80211_accept_frame()` on the normal RX path.
</issue_to_address>
### Comment 3
<location path="net/wireless/reg.c" line_range="2364" />
<code_context>
if (!wdev->netdev || !netif_running(wdev->netdev))
return true;
+ /* NAN doesn't have links, handle it separately */
+ if (iftype == NL80211_IFTYPE_NAN) {
+ for (int i = 0; i < wdev->u.nan.n_channels; i++) {
</code_context>
<issue_to_address>
**Invalid NAN channels remain active**
When a regulatory update rechecks a NAN interface with configured channels, `reg_wdev_chan_valid()` returns true at the earlier no-netdev guard before reaching the NAN chandef loop, so prohibited channels remain configured and NAN stays active.
Run the NAN chandef validation before the no-netdev early return.
Also at `net/wireless/reg.c:2365-2374`.
</issue_to_address>
### Comment 4
<location path="net/wireless/core.c" line_range="1724" />
<code_context>
- wiphy_work_cancel(wdev->wiphy, &wdev->disconnect_wk);
- }
+ /* since we just did cfg80211_leave() nothing to do there */
+ wiphy_work_cancel(wdev->wiphy, &wdev->disconnect_wk);
break;
case NETDEV_DOWN:
</code_context>
<issue_to_address>
**Disconnect work cancellation loses lock**
When a netdev enters `NETDEV_GOING_DOWN`, `wiphy_work_cancel` runs after the `scoped_guard` releases the wiphy mutex; its lock assertion fails, and cancellation can race work processing, allowing the disconnect work to run while the interface is going down.
Keep `wiphy_work_cancel` inside the wiphy-locked scope.
</issue_to_address>
### Comment 5
<location path="net/wireless/reg.c" line_range="2469-2470" />
<code_context>
- if (!reg_wdev_chan_valid(wiphy, wdev))
+ scoped_guard(wiphy, wiphy)
+ valid = reg_wdev_chan_valid(wiphy, wdev);
+ if (!valid)
cfg80211_leave(rdev, wdev);
+ }
}
</code_context>
<issue_to_address>
**Regulatory check stops a newly valid NAN schedule**
When a NAN local-schedule update races with regulatory channel validation, `cfg80211_leave()` acts on the earlier `valid` result after the wiphy lock has been released, so a concurrent local-schedule update can make that result stale and cfg80211 stops NAN despite its newly valid schedule. Conversely, a schedule can become invalid after a `true` result and escape this regulatory pass.
Make the validity decision and resulting leave atomic with respect to schedule updates, for example by rechecking under the lock used to perform the leave.
</issue_to_address>
### Comment 6
<location path="net/wireless/nl80211.c" line_range="8248" />
<code_context>
+ sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
if (ether_addr_equal(mac, sdata->vif.addr))
return -EINVAL;
</code_context>
<issue_to_address>
**NAN station queries are rejected**
When userspace requests an individual station on a non-netdev NAN interface, `nl80211_get_station()` returns `-EINVAL` at the no-netdev guard before calling `rdev_get_station()`, so userspace cannot retrieve individual NAN peer information.
Allow NAN wireless devices through the no-netdev guard and use the wireless-device-based station callback.
Also at `net/wireless/nl80211.c:8266`.
</issue_to_address>
### Comment 7
<location path="net/wireless/nl80211.c" line_range="9045-9046" />
<code_context>
+ if (params.sta_modify_mask & STATION_PARAM_APPLY_UAPSD)
+ return -EINVAL;
+ /* NAN NMI station must be added in associated or authorized state */
+ if (!(params.sta_flags_set & (BIT(NL80211_STA_FLAG_ASSOCIATED) |
+ BIT(NL80211_STA_FLAG_AUTHENTICATED))))
+ return -EINVAL;
+ }
</code_context>
<issue_to_address>
**Authorized-only NAN stations are rejected**
When userspace adds a NAN station with only AUTHORIZED set, the new-station state check accepts ASSOCIATED or AUTHENTICATED but not AUTHORIZED, so it returns `-EINVAL` despite the stated requirement allowing the authorized state.
Include AUTHORIZED in the accepted station-state flags.
</issue_to_address>
### Comment 8
<location path="net/wireless/nl80211.c" line_range="7287" />
<code_context>
+
+ /* WME is always used in NAN */
+ if (iftype == NL80211_IFTYPE_NAN_DATA) {
+ /* but don't let userspace control it */
+ if (params->sta_flags_mask & BIT(NL80211_STA_FLAG_WME))
+ return -EINVAL;
</code_context>
<issue_to_address>
**NMI capabilities are rejected**
When userspace adds an NMI station with HT, VHT, or HE capabilities, `parse_station_flags()` does not force WME for NAN management stations, and userspace cannot set WME through the NAN flag allowlist. The later QoS check therefore clears HT/VHT capabilities and rejects HE capabilities, preventing userspace from configuring the required NMI capabilities.
Force WME for NAN management stations while preventing userspace from controlling that flag.
</issue_to_address>
### Comment 9
<location path="net/mac80211/iface.c" line_range="1407" />
<code_context>
case NL80211_IFTYPE_P2P_CLIENT:
case NL80211_IFTYPE_P2P_GO:
case NL80211_IFTYPE_OCB:
+ case NL80211_IFTYPE_NAN_DATA:
/* shouldn't happen */
WARN_ON_ONCE(1);
</code_context>
<issue_to_address>
**Opening NAN data emits a warning**
When a mac80211 NAN data interface is brought up, `ieee80211_do_open()` reaches an interface-type switch that does not handle NAN_DATA, so the default branch executes `WARN_ON(1)` and emits a kernel warning.
Handle NAN_DATA in the later `ieee80211_do_open()` interface-type switch.
</issue_to_address>| bool compatible = false; | ||
|
|
||
| ret = nl80211_parse_nan_channel(rdev, channel, info, | ||
| nan_channels, i, false); |
There was a problem hiding this comment.
🟠 High · Large peer schedules crash the kernel
When a caller with permission to configure NAN peer schedules submits more than 255 peer channels, which the current limit allows when the local schedule has at least 32 channels, the loop index exceeds 255, so the u8 index parameter of nl80211_parse_nan_channel() wraps while the caller later checks nan_channels[i] using the unwrapped index. It passes an uninitialized channel definition to cfg80211_chandef_compatible(), which can dereference its missing channel pointer and crash the kernel.
Reject peer schedules with more channels than the u8 index and n_channels fields can represent, or use appropriately wide types and validate the count before allocation and parsing.
Prompt for AI agents
In `net/wireless/nl80211.c` at line 16945:
**Large peer schedules crash the kernel**
When a caller with permission to configure NAN peer schedules submits more than 255 peer channels, which the current limit allows when the local schedule has at least 32 channels, the loop index exceeds 255, so the `u8 index` parameter of `nl80211_parse_nan_channel()` wraps while the caller later checks `nan_channels[i]` using the unwrapped index. It passes an uninitialized channel definition to `cfg80211_chandef_compatible()`, which can dereference its missing channel pointer and crash the kernel.
Reject peer schedules with more channels than the `u8` index and `n_channels` fields can represent, or use appropriately wide types and validate the count before allocation and parsing.| case NL80211_IFTYPE_NAN_DATA: | ||
| return false; |
There was a problem hiding this comment.
🟠 High · NAN data frames never reach RX
When a NAN_DATA frame takes the normal RX path, ieee80211_accept_frame() returns false for NL80211_IFTYPE_NAN_DATA, so ieee80211_prepare_and_rx_handle() stops before normal RX handling and the interface never receives the frame.
Allow NAN_DATA frames through ieee80211_accept_frame() on the normal RX path.
Prompt for AI agents
In `net/mac80211/rx.c` at lines 4546-4547:
**NAN data frames never reach RX**
When a NAN_DATA frame takes the normal RX path, `ieee80211_accept_frame()` returns false for `NL80211_IFTYPE_NAN_DATA`, so `ieee80211_prepare_and_rx_handle()` stops before normal RX handling and the interface never receives the frame.
Allow NAN_DATA frames through `ieee80211_accept_frame()` on the normal RX path.| if (!wdev->netdev || !netif_running(wdev->netdev)) | ||
| return true; | ||
|
|
||
| /* NAN doesn't have links, handle it separately */ |
There was a problem hiding this comment.
🟠 High · Invalid NAN channels remain active
When a regulatory update rechecks a NAN interface with configured channels, reg_wdev_chan_valid() returns true at the earlier no-netdev guard before reaching the NAN chandef loop, so prohibited channels remain configured and NAN stays active.
Run the NAN chandef validation before the no-netdev early return.
Also at net/wireless/reg.c:2365-2374.
Prompt for AI agents
In `net/wireless/reg.c` at line 2364:
**Invalid NAN channels remain active**
When a regulatory update rechecks a NAN interface with configured channels, `reg_wdev_chan_valid()` returns true at the earlier no-netdev guard before reaching the NAN chandef loop, so prohibited channels remain configured and NAN stays active.
Run the NAN chandef validation before the no-netdev early return.
Also at `net/wireless/reg.c:2365-2374`.| wiphy_work_cancel(wdev->wiphy, &wdev->disconnect_wk); | ||
| } | ||
| /* since we just did cfg80211_leave() nothing to do there */ | ||
| wiphy_work_cancel(wdev->wiphy, &wdev->disconnect_wk); |
There was a problem hiding this comment.
🟡 Medium · Disconnect work cancellation loses lock
When a netdev enters NETDEV_GOING_DOWN, wiphy_work_cancel runs after the scoped_guard releases the wiphy mutex; its lock assertion fails, and cancellation can race work processing, allowing the disconnect work to run while the interface is going down.
Keep wiphy_work_cancel inside the wiphy-locked scope.
Prompt for AI agents
In `net/wireless/core.c` at line 1724:
**Disconnect work cancellation loses lock**
When a netdev enters `NETDEV_GOING_DOWN`, `wiphy_work_cancel` runs after the `scoped_guard` releases the wiphy mutex; its lock assertion fails, and cancellation can race work processing, allowing the disconnect work to run while the interface is going down.
Keep `wiphy_work_cancel` inside the wiphy-locked scope.| if (!valid) | ||
| cfg80211_leave(rdev, wdev); |
There was a problem hiding this comment.
🟡 Medium · Regulatory check stops a newly valid NAN schedule
When a NAN local-schedule update races with regulatory channel validation, cfg80211_leave() acts on the earlier valid result after the wiphy lock has been released, so a concurrent local-schedule update can make that result stale and cfg80211 stops NAN despite its newly valid schedule. Conversely, a schedule can become invalid after a true result and escape this regulatory pass.
Make the validity decision and resulting leave atomic with respect to schedule updates, for example by rechecking under the lock used to perform the leave.
Prompt for AI agents
In `net/wireless/reg.c` at lines 2469-2470:
**Regulatory check stops a newly valid NAN schedule**
When a NAN local-schedule update races with regulatory channel validation, `cfg80211_leave()` acts on the earlier `valid` result after the wiphy lock has been released, so a concurrent local-schedule update can make that result stale and cfg80211 stops NAN despite its newly valid schedule. Conversely, a schedule can become invalid after a `true` result and escape this regulatory pass.
Make the validity decision and resulting leave atomic with respect to schedule updates, for example by rechecking under the lock used to perform the leave.| memset(&sinfo, 0, sizeof(sinfo)); | ||
|
|
||
| if (!wdev->netdev) | ||
| return -EINVAL; |
There was a problem hiding this comment.
🟡 Medium · NAN station queries are rejected
When userspace requests an individual station on a non-netdev NAN interface, nl80211_get_station() returns -EINVAL at the no-netdev guard before calling rdev_get_station(), so userspace cannot retrieve individual NAN peer information.
Allow NAN wireless devices through the no-netdev guard and use the wireless-device-based station callback.
Also at net/wireless/nl80211.c:8266.
Prompt for AI agents
In `net/wireless/nl80211.c` at line 8248:
**NAN station queries are rejected**
When userspace requests an individual station on a non-netdev NAN interface, `nl80211_get_station()` returns `-EINVAL` at the no-netdev guard before calling `rdev_get_station()`, so userspace cannot retrieve individual NAN peer information.
Allow NAN wireless devices through the no-netdev guard and use the wireless-device-based station callback.
Also at `net/wireless/nl80211.c:8266`.| if (!(params.sta_flags_set & (BIT(NL80211_STA_FLAG_ASSOCIATED) | | ||
| BIT(NL80211_STA_FLAG_AUTHENTICATED)))) |
There was a problem hiding this comment.
🟡 Medium · Authorized-only NAN stations are rejected
When userspace adds a NAN station with only AUTHORIZED set, the new-station state check accepts ASSOCIATED or AUTHENTICATED but not AUTHORIZED, so it returns -EINVAL despite the stated requirement allowing the authorized state.
Include AUTHORIZED in the accepted station-state flags.
Prompt for AI agents
In `net/wireless/nl80211.c` at lines 9045-9046:
**Authorized-only NAN stations are rejected**
When userspace adds a NAN station with only AUTHORIZED set, the new-station state check accepts ASSOCIATED or AUTHENTICATED but not AUTHORIZED, so it returns `-EINVAL` despite the stated requirement allowing the authorized state.
Include AUTHORIZED in the accepted station-state flags.|
|
||
| /* WME is always used in NAN */ | ||
| if (iftype == NL80211_IFTYPE_NAN_DATA) { | ||
| /* but don't let userspace control it */ |
There was a problem hiding this comment.
🟠 High · NMI capabilities are rejected
When userspace adds an NMI station with HT, VHT, or HE capabilities, parse_station_flags() does not force WME for NAN management stations, and userspace cannot set WME through the NAN flag allowlist. The later QoS check therefore clears HT/VHT capabilities and rejects HE capabilities, preventing userspace from configuring the required NMI capabilities.
Force WME for NAN management stations while preventing userspace from controlling that flag.
Prompt for AI agents
In `net/wireless/nl80211.c` at line 7287:
**NMI capabilities are rejected**
When userspace adds an NMI station with HT, VHT, or HE capabilities, `parse_station_flags()` does not force WME for NAN management stations, and userspace cannot set WME through the NAN flag allowlist. The later QoS check therefore clears HT/VHT capabilities and rejects HE capabilities, preventing userspace from configuring the required NMI capabilities.
Force WME for NAN management stations while preventing userspace from controlling that flag.| case NL80211_IFTYPE_P2P_DEVICE: | ||
| case NL80211_IFTYPE_OCB: | ||
| case NL80211_IFTYPE_NAN: | ||
| case NL80211_IFTYPE_NAN_DATA: |
There was a problem hiding this comment.
🟡 Medium · Opening NAN data emits a warning
When a mac80211 NAN data interface is brought up, ieee80211_do_open() reaches an interface-type switch that does not handle NAN_DATA, so the default branch executes WARN_ON(1) and emits a kernel warning.
Handle NAN_DATA in the later ieee80211_do_open() interface-type switch.
Prompt for AI agents
In `net/mac80211/iface.c` at line 1407:
**Opening NAN data emits a warning**
When a mac80211 NAN data interface is brought up, `ieee80211_do_open()` reaches an interface-type switch that does not handle NAN_DATA, so the default branch executes `WARN_ON(1)` and emits a kernel warning.
Handle NAN_DATA in the later `ieee80211_do_open()` interface-type switch.There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical issues allow driver work on suspended hardware, cancel shutdown work without the required mutex, and silently clear non-evacuable channels through unchecked count truncation.
13 open issues
Reject NAN station creation until mac80211 supports it · New Cancel wiphy work while holding the wiphy mutex · New Reject non-evacuable channel counts above U8_MAX · New Set suspended before releasing the wiphy mutex · New Preserve active channels when a deferred schedule update fails · New Accept protected-dual action frames on NAN interfaces · New Allow GET_STATION queries for NAN management peers · New Allow NAN stations to provide HT/VHT/HE capabilities · New Allow NAN_DATA to cancel pending management-frame waits · New Multicast NAN updates when no socket owner is set · New Allow IBSS group keys without the IBSS_RSN capability · New Allow supported IGTK indices for mesh group keys · New Set the bridge restriction for newly created NAN_DATA interfaces · New
What changed in this PR
Extends Wi-Fi Aware support in cfg80211 and nl80211 with NAN data interfaces and peer scheduling, while adapting mac80211 and wireless drivers to wireless-device-based station APIs.
Changes:
- Define NAN data interfaces and band-independent HT, VHT, and HE capabilities.
- Add peer schedules, non-evacuable channel configuration, and ULW/channel-evacuation notifications.
- Update station APIs, NAN lifecycle dependencies, and teardown locking.
| File | Description |
|---|---|
| net/wireless/wext-compat.c | Adapt key validation and station queries. |
| net/wireless/util.c | Add NAN-aware key and interface handling. |
| net/wireless/trace.h | Update station traces and add NAN events. |
| net/wireless/sysfs.c | Restructure locking during suspend teardown. |
| net/wireless/reg.h | Declare regulatory teardown workers. |
| net/wireless/reg.c | Check NAN schedules and defer teardown. |
| net/wireless/rdev-ops.h | Update station wrappers and add NAN callbacks. |
| net/wireless/nl80211.c | Implement NAN commands, capabilities, and notifications. |
| net/wireless/mlme.c | Permit NAN protected-dual action transmission. |
| net/wireless/core.h | Declare NAN helpers and regulatory work state. |
| net/wireless/core.c | Enforce lifecycle dependencies and update teardown. |
| net/wireless/chan.c | Recognize NAN_DATA in channel handling. |
| net/mac80211/util.c | Recognize NAN_DATA during reconfiguration. |
| net/mac80211/sta_info.c | Pass wireless devices to station notifications. |
| net/mac80211/rx.c | Explicitly reject NAN_DATA in receive filtering. |
| net/mac80211/iface.c | Add NAN_DATA interface-switch cases. |
| net/mac80211/chan.c | Add NAN_DATA channel-context cases. |
| net/mac80211/cfg.c | Convert station callbacks to wireless devices. |
| include/uapi/linux/nl80211.h | Define NAN interface, command, and attribute APIs. |
| include/net/cfg80211.h | Extend NAN structures, callbacks, and documentation. |
| include/linux/ieee80211.h | Include the dedicated NAN definitions header. |
| include/linux/ieee80211-nan.h | Collect NAN constants and antenna masks. |
| drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | Adapt station callbacks and notifications. |
| drivers/net/wireless/virtual/virt_wifi.c | Adapt station query callbacks. |
| drivers/net/wireless/quantenna/qtnfmac/event.c | Update station notification arguments. |
| drivers/net/wireless/quantenna/qtnfmac/cfg80211.c | Adapt station management callbacks. |
| drivers/net/wireless/microchip/wilc1000/cfg80211.c | Adapt station management callbacks. |
| drivers/net/wireless/marvell/mwifiex/uap_event.c | Update AP station notifications. |
| drivers/net/wireless/marvell/mwifiex/cfg80211.c | Adapt station callbacks and notifications. |
| drivers/net/wireless/marvell/libertas/cfg.c | Update the station query signature. |
| drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | Adapt station callbacks and notifications. |
| drivers/net/wireless/ath/wil6210/wmi.c | Update connection-event station notifications. |
| drivers/net/wireless/ath/wil6210/main.c | Update station removal notifications. |
| drivers/net/wireless/ath/wil6210/cfg80211.c | Adapt station management callbacks. |
| drivers/net/wireless/ath/ath6kl/main.c | Update station association/removal notifications. |
| drivers/net/wireless/ath/ath6kl/cfg80211.c | Adapt station management callbacks. |
Review effort: Max (adaptive)
| return -EINVAL; | ||
| } else | ||
| sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
| sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); |
| wiphy_work_cancel(wdev->wiphy, &wdev->disconnect_wk); | ||
| } | ||
| /* since we just did cfg80211_leave() nothing to do there */ | ||
| wiphy_work_cancel(wdev->wiphy, &wdev->disconnect_wk); |
| nlmsg_for_each_attr_type(channel, NL80211_ATTR_NAN_CHANNEL, | ||
| info->nlhdr, GENL_HDRLEN, rem) | ||
| n_channels++; |
| if (rdev->ops->suspend) | ||
| ret = rdev_suspend(rdev, rdev->wiphy.wowlan_config); | ||
| } |
| if (cfg80211_chandef_identical(&wdev->u.nan.chandefs[j], | ||
| &channels->chandefs[i])) { |
| case NL80211_IFTYPE_P2P_GO: | ||
| break; | ||
| case NL80211_IFTYPE_NAN: | ||
| case NL80211_IFTYPE_NAN_DATA: |
| if (!wdev->owner_nlportid) | ||
| return; |
|
|
||
| switch (wdev->iftype) { | ||
| case NL80211_IFTYPE_ADHOC: | ||
| if (!(wdev->wiphy->flags & WIPHY_FLAG_IBSS_RSN)) |
| fallthrough; | ||
| case NL80211_IFTYPE_MESH_POINT: | ||
| /* no support for IGTK/BIGTK (yet?) */ | ||
| return key_idx < 4; |
| case NL80211_IFTYPE_OCB: | ||
| case NL80211_IFTYPE_P2P_CLIENT: | ||
| case NL80211_IFTYPE_ADHOC: | ||
| case NL80211_IFTYPE_NAN_DATA: |
This new interface type represents a NAN data interface (NDI). It is used for data communication with NAN peers. Note that the existing NL80211_IFTYPE_NAN interface, which is the NAN Management Interface (NMI), is used for management communication. An NDI interface is started when a new NAN data path is about to be established, and is stopped after the NAN data path is terminated. - An NDI interface can only be started if the NMI is running, and NAN is started. - Before the NMI is stopped, the NDI interfaces will be stopped. Add the new interface type, handle add/remove operations for it, and makes sure of the conditions above. Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com> Link: https://patch.msgid.link/20260219114327.0d681335c2e2.I92973483e927820ae2297853c141842fdb262747@changeid Link: https://patch.msgid.link/20260318123926.206536-4-miriam.rachel.korenblit@intel.com Signed-off-by: Johannes Berg <johannes.berg@intel.com> (cherry picked from commit 0e8ec73) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
In NAN, unlike in other modes, there is only one set of (HT, VHT, HE) capabilities that is used for all channels (and bands) used in the NAN data path. This set of capabilities will have to be a special one, for example - have the minimum of (HT-for-5 GHz, HT-for-2.4 GHz), careful handling of the bits that have a different meaning for each band, etc. While we could use the exiting sband/iftype capabilities, and require identical capabilities for all bands (makes no sense since this means that we will have VHT capabilities in the 2.4 GHz slot), or require that only one of the sbands will be set, or have logic to extract the minimum and handle the conflicting bits - it seems simpler to add a dedicated set of capabilities which is special for NAN, and is band agnostic, to be populated by the driver. That way we also let the driver decide how it wants to handle the conflicting bits. Add this special set of these capabilities to wiphy:nan_capabilities, to be populated by the driver. Send it to user space. Reviewed-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com> Link: https://patch.msgid.link/20260219114327.4b6f3e4a81b4.I45422adc0df3ad4101d857a92e83f0de5cf241e1@changeid Link: https://patch.msgid.link/20260318123926.206536-5-miriam.rachel.korenblit@intel.com Signed-off-by: Johannes Berg <johannes.berg@intel.com> (cherry picked from commit bd11c96) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
Currently, a station can only be added to a netdev interface, mainly because there was no need for a station of a non-netdev interface. But for NAN, we will have stations that belong to the NL80211_IFTYPE_NAN interface. Prepare for adding/changing/deleting a station that belongs to a non-netdev interface. This doesn't actually allow such stations - this will be done in a different patch. Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com> Link: https://patch.msgid.link/20260219114327.65c9cc96f814.Ic02066b88bb8ad6b21e15cbea8d720280008c83b@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com> (cherry picked from commit 033fe32) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
There are 2 types of logical links with a NAN peer: - management (NMI), which is used for Tx/Rx of NAN management frames. - data (NDI), which is used for Tx/Rx of data frames, or non-NAN management frames. The NMI station has two roles: - representation of the NAN peer - for example, the peer's schedule and the HT, VHT, HE capabilities - belong to the NMI station, and not to the NDI ones. - Tx/Rx of NAN management frames to/from the peer. The NDI station is used for Tx/Rx data frames of a specific NDP that was established with the NAN peer. Note that a peer can choose to reuse its NMI address as the NDI address. In that case, it is expected that two stations will be added even though they will have the same address. - An NDI station can only be added after the corresponding NMI station was configured with capabilities. - All the NDI stations will be removed before the NDI interface is brought down. - All NMI stations will be removed before NAN is stopped. - Before NMI sta removal, all corresponding NDI stations will be removed Add support for adding, removing, and changing NMI and NDI stations. Reviewed-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com> Link: https://patch.msgid.link/20260219114327.d280936ee832.I6d859eee759bb5824a9ffd2984410faf879ba00e@changeid Link: https://patch.msgid.link/20260318123926.206536-6-miriam.rachel.korenblit@intel.com Signed-off-by: Johannes Berg <johannes.berg@intel.com> (cherry picked from commit 1f1101c) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
Add an NL80211 command to configure the NAN schedule of a NAN peer. Such a schedule contains a list of NAN channels, and a mapping from each time slots to the corresponding channel (or unscheduled). Also contains more information about the schedule, such as sequence ID and map ID. Not all of the restrictions are validated in this patch. In particular, comparison of two maps of the same peer requires storing/retrieving each map of each peer, only for validation. Therefore, it is the responsibilty of the driver to check that. Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com> Link: https://patch.msgid.link/20260219114327.5b13fa5af4f6.If0e214ff5b52c9666e985fefa3f7be0ad14d93fb@changeid Link: https://patch.msgid.link/20260318123926.206536-7-miriam.rachel.korenblit@intel.com Signed-off-by: Johannes Berg <johannes.berg@intel.com> (cherry picked from commit c4aa273) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
According to Wi-Fi Aware (TM) specification Table 3, data frame should have 0 in the FromDS/ToDS fields. Don't drop received frames with 0 FromDS/ToDS if they are received on NAN_DATA interface. While at it, fix a double indent. Signed-off-by: Daniel Gabay <daniel.gabay@intel.com> Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com> Link: https://patch.msgid.link/20260108102921.de5f318a790a.Id34dd69552920b579e6881ffd38fa692a491b601@changeid Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com> Link: https://patch.msgid.link/20260219094725.3846371-5-miriam.rachel.korenblit@intel.com Link: https://patch.msgid.link/20260318123926.206536-8-miriam.rachel.korenblit@intel.com Signed-off-by: Johannes Berg <johannes.berg@intel.com> (cherry picked from commit 21ade3e) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
Currently we have this ability for AP and GO. But it is now needed also for NAN_DATA mode - as per Wi-Fi Aware (TM) 4.0 specification 6.2.5: "If a NAN Device receives a unicast NAN Data frame destined for it, but with A1 address and A2 address that are not assigned to the NDP, it shall discard the frame, and should send a Data Path Termination NAF to the frame transmitter" To allow this, change NL80211_CMD_UNEXPECTED_FRAME to support also NAN_DATA, so drivers can report such cases and the user space can act accordingly. Reviewed-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com> Link: https://patch.msgid.link/20260108102921.5cf9f1351655.I47c98ce37843730b8b9eb8bd8e9ef62ed6c17613@changeid Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com> Link: https://patch.msgid.link/20260219094725.3846371-6-miriam.rachel.korenblit@intel.com Link: https://patch.msgid.link/20260318123926.206536-9-miriam.rachel.korenblit@intel.com Signed-off-by: Johannes Berg <johannes.berg@intel.com> (cherry picked from commit f826534) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
Add a new notification command that allows drivers to notify user space when the device's ULW (Unaligned Schedule) blob has been updated. This enables user space to attach the updated ULW blob to frames sent to NAN peers. Reviewed-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com> Link: https://patch.msgid.link/20260219114327.32b715af4ebb.Ibdb6e33941afd94abf77245245f87e4338d729d3@changeid Link: https://patch.msgid.link/20260318123926.206536-10-miriam.rachel.korenblit@intel.com Signed-off-by: Johannes Berg <johannes.berg@intel.com> (cherry picked from commit 44ea50a) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
If all available channel resources are used for NAN channels, and one of them is shared with another interface, and that interface needs to move to a different channel (for example STA interface that needs to do a channel or a link switch), then the driver can evacuate one of the NAN channels (i.e. detach it from its channel resource and announce to the peers that this channel is ULWed). In that case, the driver needs to notify user space about the channel evacuation, so the user space can adjust the local schedule accordingly. Add a notification to let userspace know about it. Reviewed-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com> Link: https://patch.msgid.link/20260219114327.d5bebfd5ff73.Iaaf5ef17e1ab7a38c19d60558e68fcf517e2b400@changeid Link: https://patch.msgid.link/20260318123926.206536-11-miriam.rachel.korenblit@intel.com Signed-off-by: Johannes Berg <johannes.berg@intel.com> (cherry picked from commit 154b029) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
The ieee80211.h file has gotten very long, continue splitting it by putting NAN definitions into a separate file. Note that NAN isn't really even IEEE 802.11 but WFA. Link: https://patch.msgid.link/20251105153843.8da0e796dda2.I7b2ce11220b70e8794019501eabbf8afbaf431a6@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com> (cherry picked from commit 60a3734) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
Add some missing NAN Device capabilities definitions. Signed-off-by: Ilan Peer <ilan.peer@intel.com> Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com> Link: https://patch.msgid.link/20260318143604.5f6b36d2b208.I7ef571682d5add96eabfcf87f81285893021e851@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com> (cherry picked from commit 15d6dac) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
Allow transmitting protected dual of public action frames on NAN device and NAN data interfaces, since NAN action frames may be protected and can be sent on both. Signed-off-by: Avraham Stern <avraham.stern@intel.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com> Link: https://patch.msgid.link/20260318143604.73801a92180c.I16000c3e1e2bbc320457db1ac728d789bb2f36c6@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com> (cherry picked from commit e465ce0) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
reg_wdev_chan_valid() returns early for any wdev that has no netdev, which is fine for P2P originally (and later PD still), but NAN has no netdev and yet enforcement code was added and is needed, but is dead code right now. Use wdev_running() instead so that netdev-less wdevs aren't skipped. P2P/PD don't do anything in the later switch, but NAN code can now be reached. Assisted-by: LLM Fixes: 0e8ec73 ("wifi: cfg80211: add support for NAN data interface") Link: https://patch.msgid.link/20260904165614.6abc075b5401.Ib90696e3fa49b1698c27d64db5360d51f6f187a9@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com> (cherry picked from commit 17a5f85) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
Regulatory enforcement in reg_check_chans_work() does all work with the RTNL held, which can block the RTNL for a long time, which syzbot can hit and report hung tasks. Except for NAN, we don't need the RTNL for the enforcement, and the list iteration can be done with RCU instead. Split the enforcement off into new work structs: for NAN, we have to have the RTNL to close dependent NAN_DATA interfaces, everything else can use cfg80211_leave_locked() in a wiphy work. It'd be doable to use just a single work with RTNL, but then the RTNL would end up being used all the time, and really it only needs to be used for NAN. Assisted-by: LLM Reported-by: syzbot+adeb8550754921fece20@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=adeb8550754921fece20 Reported-by: syzbot+101224300649c3eb8af4@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=101224300649c3eb8af4 Link: https://patch.msgid.link/20260904165614.f65bd4d9fa35.I82dac71371d87f39e459fce931b0e5321e4f9767@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com> (cherry picked from commit f4e72e3) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
The support for NAN DATA was added for single radio devices only. For example, checking the interface combinations is done for a single radio. Prevent registration with NAN DATA interface type for multi radio devices. Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com> Link: https://patch.msgid.link/20260505194607.ff87e6fcff56.If201aa58119d2a6b08223ecb63bc2869f63ff5a1@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com> (cherry picked from commit 7b9b2dd) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
Per Wi-Fi Aware v4.0 section 7.1.2, NAN Data interfaces shall only use CCMP-128 or GCMP-256 for frame protection. Enforce this in cfg80211_validate_key_settings() by passing the wdev down to it. Signed-off-by: Daniel Gabay <daniel.gabay@intel.com> Reviewed-by: Ilan Peer <ilan.peer@intel.com> Reviewed-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com> Link: https://patch.msgid.link/20260415183550.14a422ac52fd.I486ae7188bc60e44503ecccc99af6ae3a31d16b8@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com> (cherry picked from commit ab45ef0) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
Currently, we accept per-STA GTK for any interface type if the IBSS_RSN flag is set, which doesn't make sense, and also accept various key indices that aren't really (meant to be) supported, such as IGTK/BIGTK on IBSS or AP_VLAN etc. For MESH and NAN_DATA interface types, per-STA GTKs are required, so their support shouldn't depend on IBSS_RSN. Conversely a driver setting IBSS_RSN doesn't really say it also accepts per-STA GTK for other interface types. Move more checks into cfg80211_valid_key_idx() and make them more precise: - allow IGTK and, if supported, BIGTK for NAN - allow per-STA (RX) GTK only for - NAN_DATA - IBSS if IBSS_RSN is supported - MESH - allow B/I/GTK for station/P2P-client without mac_addr for RX with the current AP (historic API quirk), subject to support - allow TX GTK for AP/P2P-GO/AP_VLAN - allow TX IGTK/BIGTK for AP/P2P-GO subject to support Other settings are rejected, clearing up corner cases and disallowing unexpected settings. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com> Link: https://patch.msgid.link/20260715212403.725e6b63e890.I24684374112bb94d0633d61ef76ecb8a1517f7f1@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com> (cherry picked from commit 8ff047b) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
[ Upstream commit 025ef5f ] Add a new NL80211_CMD_NAN_SET_NON_EVAC_CHANNELS command that lets user space mark a set of NAN channels as non-evacuable. The command carries the channels as nested NL80211_ATTR_NAN_CHANNEL attributes (chandef only) and replaces the entire set of non-evacuable channels; channels not included in the list become evacuable again. All provided channels must already exist in the current local schedule, otherwise -ENOENT is returned. The command is rejected with -EBUSY while a schedule update is pending. This prevents the kernel from evacuating channels that carry NDC or immutable schedules, so evacuating these channels would break existing NDP connections. Fixes: 154b029 ("wifi: nl80211: Add a notification to notify NAN channel evacuation") Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com> Reviewed-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com> Link: https://patch.msgid.link/20260921215936.2efc32011e73.Ice8839058e114f6f9783079807df446388187dda@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org> (cherry picked from commit ffc44913f1a777149d887a645f11e38cfdee64c0) Signed-off-by: Wentao Guan <guanwentao@uniontech.com> (cherry picked from commit 3c69ae7) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
Some frames sent to the NAN device may be protected, such as protected action frames (in particular protected dual of public action). Accept robust management frames except disassoc on the NAN device, and clean up the code a little bit. Signed-off-by: Avraham Stern <avraham.stern@intel.com> Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com> Link: https://patch.msgid.link/20260504101829.1900c926c2e8.Ia25b2e82b250058fefa179c39327d9c8b3c3cd62@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com> (cherry picked from commit fe553d2) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
baad268 to
be89ef1
Compare


Summary by Sourcery
Extend Wi-Fi Aware support with NAN data interfaces, peer scheduling, and related user-space notifications.
New Features:
Enhancements:
Chores: