AI Trajectory


Trajectory: (Expand/Collapse All)
Seq Timestamp Type Name Duration
0/0 2026/10/14 16:38 flow patch-triage
18m Args:
null

Results:
{
  "EnableConfigs": [
    "CFG80211",
    "MAC80211",
    "MAC80211_HWSIM"
  ],
  "FocusSymbols": [
    "nl80211_nan_ndp_initiate",
    "nl80211_nan_ndp_respond",
    "nl80211_nan_ndp_terminate",
    "nl80211_nan_add_func",
    "nl80211_pmsr_start",
    "pmsr_parse_peer",
    "pmsr_parse_ftm_nan",
    "cfg80211_nan_ndp_request",
    "cfg80211_nan_ndp_confirm",
    "cfg80211_nan_ndp_terminated",
    "cfg80211_nan_match",
    "cfg80211_free_nan_func"
  ],
  "KMSANReasoning": "The patch series adds support for NAN Data Path (NDP) offload and NAN ranging to cfg80211 and nl80211.\n\n1. Memory Initialization:\n- Stack-allocated structures in nl80211 handlers (`struct cfg80211_nan_ndp_initiate`, `struct cfg80211_nan_ndp_respond`, and `struct cfg80211_nan_ndp_terminate`) are zero-initialized upon declaration using `= {}`.\n- Heap-allocated structures that hold the parsed data (`cfg80211_nan_func` and `cfg80211_pmsr_request`) are allocated using `kzalloc_obj()` and `kzalloc_flex()`, respectively, ensuring all newly added struct fields start in a zeroed state.\n- Dynamic arrays such as `func-\u003ecsids` are allocated and populated with `kmemdup()` after validating that the netlink attribute length is a multiple of `sizeof(u32)`.\n- Channel configuration parsing via `nl80211_parse_chandef()` explicitly zeroes `chandef` with `memset()` before populating it.\n\n2. Kernel-to-Userspace Communication:\n- Netlink notifications to userspace (`cfg80211_nan_match`, `cfg80211_nan_ndp_request`, `cfg80211_nan_ndp_confirm`, and `cfg80211_nan_ndp_terminated`) construct messages using individual typed Netlink helpers (`nla_put_u8`, `nla_put_u16`, `nla_put_u32`, `nla_put_s32`, `nla_put_flag`) and bounded byte buffers (`nla_put`).\n- No raw structs containing uninitialized padding or uninitialized memory fields are copied or leaked to userspace via `copy_to_user` or netlink blobs.\n\n3. KASAN vs KMSAN Applicability:\n- Any risks arising from these changes pertain to Netlink attribute parsing, length validation, or pointer manipulation (such as NULL dereferences or out-of-bounds accesses), which are comprehensively covered by KASAN and standard bug detectors.\n- There are no risks of uninitialized memory reads, conditional branching on uninitialized data, or information leaks. Therefore, a dedicated KMSAN fuzzing session is not warranted.",
  "NeedsKMSAN": false,
  "Reasoning": "The patch series adds infrastructure for NAN Data Path (NDP) and NAN Ranging in cfg80211 and nl80211. It introduces three new netlink commands (NL80211_CMD_NAN_NDP_INITIATE, NL80211_CMD_NAN_NDP_RESPOND, NL80211_CMD_NAN_NDP_TERMINATE), adds new netlink policies and attributes, introduces defensive checks in nl80211_nan_add_func, and extends peer measurement (PMSR) parsing for NAN ranging. This code is in the core networking subsystem and directly accessible from userspace over Generic Netlink in standard virtualized environments supporting mac80211_hwsim.",
  "WorthFuzzing": true
}

1/1 2026/10/14 16:38 action read-patch-diff
0m Args:
null

Results:
{
  "PatchDiff": "commit e69ce378af275ac551b3277525fb9a976aef3381\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate:   Wed Oct 14 16:38:25 2026 +0000\n\n    syz-cluster: applied patch under review\n\ndiff --git a/include/net/cfg80211.h b/include/net/cfg80211.h\nindex f773856c18181..8e0325501bcf4 100644\n--- a/include/net/cfg80211.h\n+++ b/include/net/cfg80211.h\n@@ -4334,6 +4334,192 @@ struct cfg80211_nan_peer_sched {\n \tstruct cfg80211_nan_peer_map maps[CFG80211_NAN_MAX_PEER_MAPS];\n };\n \n+/**\n+ * struct cfg80211_nan_ndp_initiate - NAN NDP initiate parameters\n+ *\n+ * @peer_nmi: peer NMI address\n+ * @publish_id: publisher's service instance ID\n+ * @service_id: NAN service ID (%NL80211_NAN_FUNC_SERVICE_ID_LEN bytes)\n+ * @init_ndi: initiator NDI MAC address. The corresponding\n+ *\t%NL80211_IFTYPE_NAN_DATA interface must exist.\n+ * @ssi: service-specific info (may be NULL)\n+ * @ssi_len: length of @ssi\n+ * @cipher_suite: NAN cipher suite ID, 0 for open NDP\n+ * @pmk: NAN Data Path PMK (%NL80211_NAN_NDP_PMK_LEN bytes,\n+ *\tvalid when @pmk_set is true)\n+ * @pmk_set: if true, @pmk contains a valid PMK\n+ * @pmkid: PMKID (%NL80211_NAN_NDP_PMKID_LEN bytes,\n+ *\tvalid when @pmkid_set is true)\n+ * @pmkid_set: if true, @pmkid contains a valid PMKID\n+ * @gtk_required: if true, GTK protection is required\n+ * @gtk_cipher: GTK cipher suite ID (valid when @gtk_required is true)\n+ * @ipv6_intf_id: IPv6 link-local interface identifier\n+ *\t(%NL80211_NAN_NDP_IPV6_INTF_ID_LEN bytes,\n+ *\tvalid when @ipv6_intf_id_set is true)\n+ * @ipv6_intf_id_set: if true, @ipv6_intf_id is valid\n+ * @ndpe: if true, use NDPE attribute instead of NDP attribute\n+ */\n+struct cfg80211_nan_ndp_initiate {\n+\tconst u8 *peer_nmi;\n+\tu8 publish_id;\n+\tu8 service_id[NL80211_NAN_FUNC_SERVICE_ID_LEN];\n+\tconst u8 *init_ndi;\n+\tconst u8 *ssi;\n+\tu8 ssi_len;\n+\tu32 cipher_suite;\n+\tu8 pmk[NL80211_NAN_NDP_PMK_LEN];\n+\tbool pmk_set;\n+\tu8 pmkid[NL80211_NAN_NDP_PMKID_LEN];\n+\tbool pmkid_set;\n+\tbool gtk_required;\n+\tu32 gtk_cipher;\n+\tu8 ipv6_intf_id[NL80211_NAN_NDP_IPV6_INTF_ID_LEN];\n+\tbool ipv6_intf_id_set;\n+\tbool ndpe;\n+};\n+\n+/**\n+ * struct cfg80211_nan_ndp_respond - NAN NDP respond parameters\n+ *\n+ * @peer_nmi: peer NMI address\n+ * @ndp_id: NDP ID from the received NDP Request\n+ * @init_ndi: initiator NDI MAC from the received NDP Request\n+ * @resp_ndi: responder NDI MAC. The corresponding\n+ *\t%NL80211_IFTYPE_NAN_DATA interface must exist (if accepting).\n+ * @accept: if true, accept the NDP; if false, reject it\n+ * @reason: rejection reason code (valid when @accept is false)\n+ * @ssi: response service-specific info (may be NULL)\n+ * @ssi_len: length of @ssi\n+ * @cipher_suite: NAN cipher suite ID (must match initiator's)\n+ * @pmk: NAN Data Path PMK (%NL80211_NAN_NDP_PMK_LEN bytes,\n+ *\tvalid when @pmk_set is true)\n+ * @pmk_set: if true, @pmk contains a valid PMK\n+ * @gtk_required: if true, GTK protection is required\n+ * @gtk_cipher: GTK cipher suite ID\n+ * @ipv6_intf_id: IPv6 link-local interface identifier\n+ *\t(%NL80211_NAN_NDP_IPV6_INTF_ID_LEN bytes,\n+ *\tvalid when @ipv6_intf_id_set is true)\n+ * @ipv6_intf_id_set: if true, @ipv6_intf_id is valid\n+ * @ndpe: if true, use NDPE attribute instead of NDP attribute\n+ */\n+struct cfg80211_nan_ndp_respond {\n+\tconst u8 *peer_nmi;\n+\tu8 ndp_id;\n+\tconst u8 *init_ndi;\n+\tconst u8 *resp_ndi;\n+\tbool accept;\n+\tu8 reason;\n+\tconst u8 *ssi;\n+\tu8 ssi_len;\n+\tu32 cipher_suite;\n+\tu8 pmk[NL80211_NAN_NDP_PMK_LEN];\n+\tbool pmk_set;\n+\tbool gtk_required;\n+\tu32 gtk_cipher;\n+\tu8 ipv6_intf_id[NL80211_NAN_NDP_IPV6_INTF_ID_LEN];\n+\tbool ipv6_intf_id_set;\n+\tbool ndpe;\n+};\n+\n+/**\n+ * struct cfg80211_nan_ndp_terminate - NAN NDP terminate parameters\n+ *\n+ * @peer_nmi: peer NMI address\n+ * @ndp_id: NDP ID to terminate\n+ * @init_ndi: initiator NDI MAC address\n+ * @reason: termination reason code\n+ */\n+struct cfg80211_nan_ndp_terminate {\n+\tconst u8 *peer_nmi;\n+\tu8 ndp_id;\n+\tconst u8 *init_ndi;\n+\tu8 reason;\n+};\n+\n+/**\n+ * struct cfg80211_nan_ndp_request_params - NAN NDP request event parameters\n+ *\n+ * Sent to userspace when the driver receives a NDP Request frame.\n+ *\n+ * @peer_nmi: peer NMI address\n+ * @ndp_id: NDP ID from the received frame\n+ * @init_ndi: initiator NDI MAC from the received frame\n+ * @publish_id: publisher's service instance ID\n+ * @ssi: service-specific info (may be NULL)\n+ * @ssi_len: length of @ssi\n+ * @cipher_suite: initiator's cipher suite ID\n+ * @pmkid: PMKID from the peer's SCIA (%NL80211_NAN_NDP_PMKID_LEN bytes,\n+ *\tvalid when @pmkid_set is true)\n+ * @pmkid_set: if true, @pmkid is valid\n+ * @gtk_required: if true, initiator requires GTK protection\n+ * @ipv6_intf_id: initiator's IPv6 link-local interface identifier\n+ *\t(%NL80211_NAN_NDP_IPV6_INTF_ID_LEN bytes,\n+ *\tvalid when @ipv6_intf_id_set is true)\n+ * @ipv6_intf_id_set: if true, @ipv6_intf_id is valid\n+ * @ndpe: if true, use NDPE attribute instead of NDP attribute\n+ */\n+struct cfg80211_nan_ndp_request_params {\n+\tconst u8 *peer_nmi;\n+\tu8 ndp_id;\n+\tconst u8 *init_ndi;\n+\tu8 publish_id;\n+\tconst u8 *ssi;\n+\tu8 ssi_len;\n+\tu32 cipher_suite;\n+\tu8 pmkid[NL80211_NAN_NDP_PMKID_LEN];\n+\tbool pmkid_set;\n+\tbool gtk_required;\n+\tu8 ipv6_intf_id[NL80211_NAN_NDP_IPV6_INTF_ID_LEN];\n+\tbool ipv6_intf_id_set;\n+\tbool ndpe;\n+};\n+\n+/**\n+ * struct cfg80211_nan_ndp_confirm_params - NAN NDP confirm event parameters\n+ *\n+ * Sent to userspace after the driver completes NDP setup.\n+ *\n+ * @peer_nmi: peer NMI address\n+ * @ndp_id: NDP ID\n+ * @init_ndi: initiator NDI MAC address\n+ * @resp_ndi: responder NDI MAC address (valid when @accepted is true)\n+ * @accepted: if true, NDP was accepted; if false, rejected\n+ * @reason: rejection reason (valid when @accepted is false)\n+ * @ssi: response service-specific info (may be NULL)\n+ * @ssi_len: length of @ssi\n+ * @ipv6_intf_id: peer's IPv6 link-local interface identifier\n+ *\t(%NL80211_NAN_NDP_IPV6_INTF_ID_LEN bytes,\n+ *\tvalid when @ipv6_intf_id_set is true)\n+ * @ipv6_intf_id_set: if true, @ipv6_intf_id is valid\n+ */\n+struct cfg80211_nan_ndp_confirm_params {\n+\tconst u8 *peer_nmi;\n+\tu8 ndp_id;\n+\tconst u8 *init_ndi;\n+\tconst u8 *resp_ndi;\n+\tbool accepted;\n+\tu8 reason;\n+\tconst u8 *ssi;\n+\tu8 ssi_len;\n+\tu8 ipv6_intf_id[NL80211_NAN_NDP_IPV6_INTF_ID_LEN];\n+\tbool ipv6_intf_id_set;\n+};\n+\n+/**\n+ * struct cfg80211_nan_ndp_terminated_params - NAN NDP terminated event\n+ *\n+ * @peer_nmi: peer NMI address\n+ * @ndp_id: NDP ID\n+ * @init_ndi: initiator NDI MAC address\n+ * @reason: termination reason code\n+ */\n+struct cfg80211_nan_ndp_terminated_params {\n+\tconst u8 *peer_nmi;\n+\tu8 ndp_id;\n+\tconst u8 *init_ndi;\n+\tu8 reason;\n+};\n+\n /**\n  * enum cfg80211_nan_conf_changes - indicates changed fields in NAN\n  * configuration\n@@ -4392,6 +4578,34 @@ struct cfg80211_nan_func_filter {\n  * @num_tx_filters: length of \u0026tx_filters.\n  * @instance_id: driver allocated id of the function.\n  * @cookie: unique NAN function identifier.\n+ * @sdea_ctrl: SDEA control field bitmask as defined in Wi-Fi Aware\n+ *\tspecification Table 9-297. Bit 2: Data Path Required. Bit 6:\n+ *\tSecurity Required. Bit 10: GTK Required. The Security Required and\n+ *\tGTK Required bits require %NL80211_EXT_FEATURE_SECURE_NAN.\n+ * @pairing_bootstrap_methods: bitmap of supported NAN pairing\n+ *\tbootstrapping methods per the Wi-Fi Aware Specification Table 9-321.\n+ * @csids: array of u32 NAN Cipher Suite ID (CSID) selectors supported by\n+ *\tthis service. See the Wi-Fi Aware Specification for cipher suite values.\n+ * @num_csids: number of entries in @csids.\n+ * @nd_pmk: pre-shared NAN Data Path PMK (%NL80211_NAN_NDP_PMK_LEN bytes).\n+ * @nd_pmk_set: if true, @nd_pmk contains a valid pre-shared ND-PMK.\n+ * @pairing_setup: if true, this service supports NAN pairing setup.\n+ * @pairing_cache: if true, this service supports NAN pairing caching.\n+ * @pairing_verify: if true, this service supports NAN pairing\n+ *\tverification using a cached NPK.\n+ * @ranging_interval: interval in milliseconds between two consecutive\n+ *\tranging measurements, or 0 if not specified.\n+ * @ingress_distance: inner geofence threshold in millimetres, or 0 if\n+ *\tnot specified.\n+ * @egress_distance: outer geofence threshold in millimetres, or 0 if\n+ *\tnot specified.\n+ * @ftms_per_burst: number of FTM frames per burst, or 0 if not specified.\n+ * @preamble: PHY preamble for FTM frames, see \u0026enum nl80211_preamble,\n+ *\tor %NL80211_PREAMBLE_LEGACY if not specified.\n+ * @chandef_valid: if true, @chandef is valid.\n+ * @chandef: channel definition for FTM ranging.\n+ * @range_report: if true, a NAN Ranging Report is required after the FTM\n+ *\tsession.\n  */\n struct cfg80211_nan_func {\n \tenum nl80211_nan_function_type type;\n@@ -4418,6 +4632,23 @@ struct cfg80211_nan_func {\n \tu8 num_rx_filters;\n \tu8 instance_id;\n \tu64 cookie;\n+\tu16 sdea_ctrl;\n+\tu16 pairing_bootstrap_methods;\n+\tu32 *csids;\n+\tu8 num_csids;\n+\tu8 nd_pmk[NL80211_NAN_NDP_PMK_LEN];\n+\tbool nd_pmk_set;\n+\tbool pairing_setup;\n+\tbool pairing_cache;\n+\tbool pairing_verify;\n+\tu32 ranging_interval;\n+\tu32 ingress_distance;\n+\tu32 egress_distance;\n+\tu8 ftms_per_burst;\n+\tenum nl80211_preamble preamble;\n+\tbool chandef_valid;\n+\tstruct cfg80211_chan_def chandef;\n+\tbool range_report;\n };\n \n /**\n@@ -4702,6 +4933,8 @@ struct cfg80211_pmsr_result {\n  *\t\t @trigger_based or @non_trigger_based is set.\n  * @rsta: Operate as the RSTA in the measurement. Only valid if @lmr_feedback\n  *\tand either @trigger_based or @non_trigger_based is set.\n+ *\tAlso valid when @range_report is set and @request_type is\n+ *\t%NL80211_PMSR_FTM_REQ_TYPE_NAN.\n  * @bss_color: the bss color of the responder. Optional. Set to zero to\n  *\tindicate the driver should set the BSS color. Only valid if\n  *\t@non_trigger_based or @trigger_based is set.\n@@ -4747,6 +4980,10 @@ struct cfg80211_pmsr_result {\n  *\tprovide ranging services to a peer (e.g. in RSTA role) but does\n  *\tnot report the measurement results to userspace. Only valid when\n  *\t@request_type is %NL80211_PMSR_FTM_REQ_TYPE_PD.\n+ * @range_report: a NAN Ranging Report is required after the FTM session.\n+ *\tOnly valid for a NAN RSTA request.\n+ * @min_delta_ftm: NAN Min Delta FTM value in units of 100 microseconds.\n+ *\tZero indicates no preference.\n  *\n  * See also nl80211 for the respective attribute documentation.\n  */\n@@ -4763,6 +5000,7 @@ struct cfg80211_pmsr_ftm_request_peer {\n \t   rsta:1;\n \tu8 num_bursts_exp;\n \tu8 burst_duration;\n+\tu8 min_delta_ftm;\n \tu8 ftms_per_burst;\n \tu8 ftmr_retries;\n \tu8 bss_color;\n@@ -4775,7 +5013,8 @@ struct cfg80211_pmsr_ftm_request_peer {\n \tu32 num_measurements;\n \tu64 ingress_distance;\n \tu64 egress_distance;\n-\tu8 pd_suppress_range_results:1;\n+\tu8 pd_suppress_range_results:1,\n+\t   range_report:1;\n };\n \n /**\n@@ -5259,6 +5498,13 @@ struct mgmt_frame_regs {\n  *\tnot included become evacuable again. All provided channels are\n  *\tguaranteed by cfg80211 to belong to the current local schedule.\n  *\n+ * @nan_ndp_initiate: Initiate a NAN Data Path session as the initiator.\n+ *\tOnly valid if the driver has set %WIPHY_NAN_FLAGS_OFFLOAD_NDP.\n+ * @nan_ndp_respond: Respond to an incoming NDP request as the responder.\n+ *\tOnly valid if the driver has set %WIPHY_NAN_FLAGS_OFFLOAD_NDP.\n+ * @nan_ndp_terminate: Terminate an established NDP session.\n+ *\tOnly valid if the driver has set %WIPHY_NAN_FLAGS_OFFLOAD_NDP.\n+ *\n  * @set_multicast_to_unicast: configure multicast to unicast conversion for BSS\n  *\n  * @get_txq_stats: Get TXQ stats for interface or phy. If wdev is %NULL, this\n@@ -5666,6 +5912,15 @@ struct cfg80211_ops {\n \tint\t(*nan_set_non_evac_channels)(struct wiphy *wiphy,\n \t\t\t\t\t     struct wireless_dev *wdev,\n \t\t\t\t\t     struct cfg80211_nan_non_evac_channels *channels);\n+\tint     (*nan_ndp_initiate)(struct wiphy *wiphy,\n+\t\t\t\t    struct wireless_dev *wdev,\n+\t\t\t\t    struct cfg80211_nan_ndp_initiate *params);\n+\tint\t(*nan_ndp_respond)(struct wiphy *wiphy,\n+\t\t\t\t   struct wireless_dev *wdev,\n+\t\t\t\t   struct cfg80211_nan_ndp_respond *params);\n+\tint\t(*nan_ndp_terminate)(struct wiphy *wiphy,\n+\t\t\t\t     struct wireless_dev *wdev,\n+\t\t\t\t     struct cfg80211_nan_ndp_terminate *params);\n \tint\t(*set_multicast_to_unicast)(struct wiphy *wiphy,\n \t\t\t\t\t    struct net_device *dev,\n \t\t\t\t\t    const bool enabled);\n@@ -6215,6 +6470,8 @@ cfg80211_get_iftype_ext_capa(struct wiphy *wiphy, enum nl80211_iftype type);\n  * @ftm.type.pd_support: supports peer-to-peer ranging as mentioned in the\n  *\tspecification \"PR Implementation Consideration Draft 1.9 rev 1\" where\n  *\tPD stands for proximity detection\n+ * @ftm.type.nan_support: supports NAN ranging as defined in\n+ *\tthe \"Wi-Fi Aware Specification v4.0, clause 8\".\n  * @ftm.concurrent_ista_rsta_support: indicates if the device can\n  *\tsimultaneously act as initiator and responder in a multi-peer\n  *\tmeasurement request. Only valid if @ftm.rsta_support is set.\n@@ -6265,7 +6522,8 @@ struct cfg80211_pmsr_capabilities {\n \t\tu32 min_allowed_ranging_interval_ntb;\n \t\tstruct {\n \t\t\tu8 infra_support:1,\n-\t\t\t   pd_support:1;\n+\t\t\t   pd_support:1,\n+\t\t\t   nan_support:1;\n \t\t} type;\n \t\tu8 concurrent_ista_rsta_support:1;\n \t\tu32 pd_preambles;\n@@ -6348,11 +6606,18 @@ struct wiphy_radio {\n  * @WIPHY_NAN_FLAGS_USERSPACE_DE: Device doesn't support DE offload.\n  * @WIPHY_NAN_FLAGS_INSTANT_COMM: Device can switch to Instant Communication\n  *     (IC) mode. Can only be set along with %WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC.\n+ * @WIPHY_NAN_FLAGS_OFFLOAD_NDP: Driver handles NAN Data Path (NDP) handshake\n+ *\tframes and data path key installation autonomously.\n+ * @WIPHY_NAN_FLAGS_OFFLOAD_RANGING: Firmware supports fully offloaded NAN\n+ *\tranging procedure, including ranging session setup, update, and\n+ *\ttermination, FTM protocol and procedure, and ranging report.\n  */\n enum wiphy_nan_flags {\n \tWIPHY_NAN_FLAGS_CONFIGURABLE_SYNC = BIT(0),\n \tWIPHY_NAN_FLAGS_USERSPACE_DE   = BIT(1),\n \tWIPHY_NAN_FLAGS_INSTANT_COMM = BIT(2),\n+\tWIPHY_NAN_FLAGS_OFFLOAD_NDP = BIT(3),\n+\tWIPHY_NAN_FLAGS_OFFLOAD_RANGING = BIT(4),\n };\n \n /**\n@@ -10554,7 +10819,26 @@ void cfg80211_free_nan_func(struct cfg80211_nan_func *f);\n  * @addr: the MAC address of the peer\n  * @info_len: the length of the \u0026info\n  * @info: the Service Specific Info from the peer (if any)\n+ * @extra_info_len: the length of @extra_info (Extended SSI)\n+ * @extra_info: Extended Service Specific Info from the peer (if any)\n+ * @ies_len: the length of @ies\n+ * @ies: additional elements from the peer's Service Descriptor frame (if any)\n+ * @sdea_ctrl: SDEA control field from the peer's SDEA attribute. Bit 2\n+ *\tindicates Data Path Required, bit 6 Security Required.\n+ * @pairing_bootstrap_methods: bitmap of the peer's supported NAN pairing\n+ *\tbootstrapping methods.\n+ * @csids: array of NAN cipher suite IDs advertised by the peer.\n+ *\tNULL if not present.\n+ * @num_csids: number of entries in @csids.\n+ * @pairing_setup: if true, the peer supports NAN pairing setup.\n+ * @pairing_cache: if true, the peer supports NAN pairing NPK/NIK caching.\n+ * @pairing_verify: if true, the peer supports NAN pairing re-verification.\n+ * @rssi: received signal strength in dBm at the time of the match.\n+ *\tOnly valid when @rssi_valid is true.\n+ * @rssi_valid: if true, @rssi contains a valid RSSI measurement.\n  * @cookie: unique identifier of the corresponding function\n+ * @ranging_indication: bitmap indicating the type of ranging performed.\n+ * @ranging_measurement: distance to the peer in millimetres.\n  */\n struct cfg80211_nan_match_params {\n \tenum nl80211_nan_function_type type;\n@@ -10563,7 +10847,22 @@ struct cfg80211_nan_match_params {\n \tconst u8 *addr;\n \tu8 info_len;\n \tconst u8 *info;\n+\tu8 extra_info_len;\n+\tconst u8 *extra_info;\n+\tu16 ies_len;\n+\tconst u8 *ies;\n+\tu16 sdea_ctrl;\n+\tu16 pairing_bootstrap_methods;\n+\tconst u32 *csids;\n+\tu8 num_csids;\n+\tbool pairing_setup;\n+\tbool pairing_cache;\n+\tbool pairing_verify;\n+\ts32 rssi;\n+\tbool rssi_valid;\n \tu64 cookie;\n+\tu8 ranging_indication;\n+\ts32 ranging_measurement;\n };\n \n /**\n@@ -11099,6 +11398,46 @@ cfg80211_s1g_get_primary_sibling(struct wiphy *wiphy,\n }\n \n \n+/**\n+ * cfg80211_nan_ndp_request - notify userspace of a received NDP request\n+ * @wdev: the wireless device reporting the event\n+ * @params: NDP request parameters parsed from the received frame\n+ * @gfp: allocation flags\n+ *\n+ * Notify userspace that a NAN Data Path request was received from a peer.\n+ * Only valid when %WIPHY_NAN_FLAGS_OFFLOAD_NDP is set.\n+ */\n+void cfg80211_nan_ndp_request(struct wireless_dev *wdev,\n+\t\t\t      struct cfg80211_nan_ndp_request_params *params,\n+\t\t\t      gfp_t gfp);\n+\n+/**\n+ * cfg80211_nan_ndp_confirm - notify userspace that NDP setup is complete\n+ * @wdev: the wireless device reporting the event\n+ * @params: NDP confirm parameters\n+ * @gfp: allocation flags\n+ *\n+ * Notify userspace that NAN Data Path setup is complete. Includes the\n+ * accept/reject status and, if accepted, the responder NDI. Only valid\n+ * when %WIPHY_NAN_FLAGS_OFFLOAD_NDP is set.\n+ */\n+void cfg80211_nan_ndp_confirm(struct wireless_dev *wdev,\n+\t\t\t      struct cfg80211_nan_ndp_confirm_params *params,\n+\t\t\t      gfp_t gfp);\n+\n+/**\n+ * cfg80211_nan_ndp_terminated - notify userspace that an NDP was terminated\n+ * @wdev: the wireless device reporting the event\n+ * @params: NDP termination parameters\n+ * @gfp: allocation flags\n+ *\n+ * Notify userspace that a NAN Data Path was torn down. Only valid\n+ * when %WIPHY_NAN_FLAGS_OFFLOAD_NDP is set.\n+ */\n+void cfg80211_nan_ndp_terminated(struct wireless_dev *wdev,\n+\t\t\t\t struct cfg80211_nan_ndp_terminated_params *params,\n+\t\t\t\t gfp_t gfp);\n+\n /**\n  * cfg80211_incumbent_signal_notify - Notify userspace of incumbent signal detection\n  * @wiphy: the wiphy to use\ndiff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h\nindex b56a96f57bec2..71ed38992d334 100644\n--- a/include/uapi/linux/nl80211.h\n+++ b/include/uapi/linux/nl80211.h\n@@ -1468,6 +1468,36 @@\n  *\tand multiple can be nested in %NL80211_ATTR_MLO_LINKS but then the\n  *\tupdate isn't atomic if any failures happen.\n  *\tOnly supported with %NL80211_EXT_FEATURE_UPDATE_BEACON.\n+ *\n+ * @NL80211_CMD_NAN_NDP_INITIATE: Initiate NAN Data Path (NDP) setup\n+ *\tas the initiator. Requires %WIPHY_NAN_FLAGS_OFFLOAD_NDP. The NDI\n+ *\tinterface specified in %NL80211_NAN_NDP_ATTR_INIT_NDI must already\n+ *\texist as a %NL80211_IFTYPE_NAN_DATA interface. Carries\n+ *\t%NL80211_ATTR_NAN_NDP nested with %NL80211_NAN_NDP_ATTR_* fields.\n+ * @NL80211_CMD_NAN_NDP_RESPOND: Respond to a received NDP request as\n+ *\tthe responder. Requires %WIPHY_NAN_FLAGS_OFFLOAD_NDP. The NDI\n+ *\tinterface specified in %NL80211_NAN_NDP_ATTR_RESP_NDI must already\n+ *\texist as a %NL80211_IFTYPE_NAN_DATA interface. Carries\n+ *\t%NL80211_ATTR_NAN_NDP nested with %NL80211_NAN_NDP_ATTR_* fields.\n+ * @NL80211_CMD_NAN_NDP_TERMINATE: Terminate an established NDP.\n+ *\tRequires %WIPHY_NAN_FLAGS_OFFLOAD_NDP. Carries %NL80211_ATTR_NAN_NDP\n+ *\tnested with %NL80211_NAN_NDP_ATTR_ID, %NL80211_NAN_NDP_ATTR_INIT_NDI\n+ *\tand optionally %NL80211_NAN_NDP_ATTR_REASON.\n+ * @NL80211_CMD_NAN_NDP_REQUEST: Notification sent to userspace when\n+ *\tthe driver receives a NDP Request frame from a peer. Carries\n+ *\t%NL80211_ATTR_MAC (peer NMI) and %NL80211_ATTR_NAN_NDP nested with\n+ *\tall parsed NDP request parameters. Userspace must ensure the NDI\n+ *\tinterface is ready before calling %NL80211_CMD_NAN_NDP_RESPOND.\n+ * @NL80211_CMD_NAN_NDP_CONFIRM: Notification sent to userspace after\n+ *\tthe driver completes NDP setup and installs data path keys. Carries\n+ *\t%NL80211_ATTR_MAC (peer NMI) and %NL80211_ATTR_NAN_NDP nested with\n+ *\tthe NDP confirm parameters including %NL80211_NAN_NDP_ATTR_RESP_NDI.\n+ *\tUserspace should call %NL80211_CMD_NEW_STATION on the NDI interface\n+ *\tto add the peer NDI station.\n+ * @NL80211_CMD_NAN_NDP_TERMINATED: Notification sent to userspace\n+ *\twhen an NDP is terminated. Carries %NL80211_ATTR_MAC (peer NMI)\n+ *\tand %NL80211_ATTR_NAN_NDP nested with the termination parameters.\n+ *\n  * @NL80211_CMD_MAX: highest used command number\n  * @__NL80211_CMD_AFTER_LAST: internal use\n  */\n@@ -1750,6 +1780,13 @@ enum nl80211_commands {\n \n \tNL80211_CMD_UPDATE_BEACON,\n \n+\tNL80211_CMD_NAN_NDP_INITIATE,\n+\tNL80211_CMD_NAN_NDP_RESPOND,\n+\tNL80211_CMD_NAN_NDP_TERMINATE,\n+\tNL80211_CMD_NAN_NDP_REQUEST,\n+\tNL80211_CMD_NAN_NDP_CONFIRM,\n+\tNL80211_CMD_NAN_NDP_TERMINATED,\n+\n \t/* add new commands above here */\n \n \t/* used to define NL80211_CMD_MAX below */\n@@ -3243,6 +3280,9 @@ enum nl80211_commands {\n  * @NL80211_ATTR_ASSOC_PROTECTED_TWT: Enable protected TWT for the association,\n  *\trequires protected TWT support (flag attribute)\n  *\n+ * @NL80211_ATTR_NAN_NDP: nested attribute carrying NAN Data Path parameters.\n+ *\tSee \u0026enum nl80211_nan_ndp_attributes.\n+ *\n  * @NUM_NL80211_ATTR: total number of nl80211_attrs available\n  * @NL80211_ATTR_MAX: highest attribute number currently defined\n  * @__NL80211_ATTR_AFTER_LAST: internal use\n@@ -3850,6 +3890,8 @@ enum nl80211_attrs {\n \n \tNL80211_ATTR_ASSOC_PROTECTED_TWT,\n \n+\tNL80211_ATTR_NAN_NDP,\n+\n \t/* add attributes here, update the policy in nl80211.c */\n \n \t__NL80211_ATTR_AFTER_LAST,\n@@ -7715,6 +7757,8 @@ enum nl80211_nan_func_term_reason {\n #define NL80211_NAN_FUNC_SERVICE_SPEC_INFO_MAX_LEN 0xff\n #define NL80211_NAN_FUNC_SRF_MAX_LEN 0xff\n \n+#define NL80211_NAN_NDP_PMK_LEN 32\n+\n /**\n  * enum nl80211_nan_func_attributes - NAN function attributes\n  * @__NL80211_NAN_FUNC_INVALID: invalid\n@@ -7753,6 +7797,40 @@ enum nl80211_nan_func_term_reason {\n  *\tIts type is u8 and it cannot be 0.\n  * @NL80211_NAN_FUNC_TERM_REASON: NAN function termination reason.\n  *\tSee \u0026enum nl80211_nan_func_term_reason.\n+ * @NL80211_NAN_FUNC_SDEA_CTRL: u16 Service Descriptor Extension Attribute\n+ *\t(SDEA) control field bitmask as defined in the Wi-Fi Aware Specification\n+ *\tTable 9-297. See \u0026enum nl80211_nan_func_sdea_ctrl_flags for the\n+ *\trelevant bit definitions. The Security Required and GTK Required bits\n+ *\trequire %NL80211_EXT_FEATURE_SECURE_NAN.\n+ * @NL80211_NAN_FUNC_PAIRING_BOOTSTRAP_METHODS: u16 bitmap of supported\n+ *\tNAN pairing bootstrapping methods as defined in Wi-Fi Aware\n+ *\tspecification Table 9-321. Each bit corresponds to one method.\n+ * @NL80211_NAN_FUNC_CSIDS: a set of u32 NAN Cipher Suite ID (CSID)\n+ *\tselectors supported by this service. Requires\n+ *\t%NL80211_EXT_FEATURE_SECURE_NAN.\n+ * @NL80211_NAN_FUNC_PAIRING_SETUP: flag attribute. This service supports\n+ *\tNAN pairing setup (new pairing).\n+ * @NL80211_NAN_FUNC_PAIRING_CACHE: flag attribute. This service supports\n+ *\tNAN pairing caching (NPK caching).\n+ * @NL80211_NAN_FUNC_PAIRING_VERIFY: flag attribute. This service supports\n+ *\tNAN pairing verification using a cached NPK.\n+ * @NL80211_NAN_FUNC_ND_PMK: %NL80211_NAN_NDP_PMK_LEN-byte pre-shared NAN\n+ *\tData Path PMK (ND-PMK).\n+ *\tRequires %NL80211_EXT_FEATURE_SECURE_NAN.\n+ * @NL80211_NAN_FUNC_RANGING_INTERVAL: u32 attribute. Interval in\n+ *\tmilliseconds between two consecutive ranging measurements.\n+ * @NL80211_NAN_FUNC_INGRESS_DISTANCE: u32 attribute. Inner geofence\n+ *\tthreshold in millimetres.\n+ * @NL80211_NAN_FUNC_EGRESS_DISTANCE: u32 attribute. Outer geofence\n+ *\tthreshold in millimetres.\n+ * @NL80211_NAN_FUNC_FTMS_PER_BURST: u8 attribute. Number of FTM\n+ *\tframes per burst.\n+ * @NL80211_NAN_FUNC_PREAMBLE: u32 attribute. PHY preamble type for\n+ *\tFTM frames (see \u0026enum nl80211_preamble).\n+ * @NL80211_NAN_FUNC_CHAN: channel definition for FTM ranging, nested,\n+ *\tusing top-level attributes like %NL80211_ATTR_WIPHY_FREQ etc.\n+ * @NL80211_NAN_FUNC_RANGE_REPORT: flag indicating that a NAN Ranging\n+ *\tReport is required after the FTM session.\n  *\n  * @NUM_NL80211_NAN_FUNC_ATTR: internal\n  * @NL80211_NAN_FUNC_ATTR_MAX: highest NAN function attribute\n@@ -7775,12 +7853,45 @@ enum nl80211_nan_func_attributes {\n \tNL80211_NAN_FUNC_TX_MATCH_FILTER,\n \tNL80211_NAN_FUNC_INSTANCE_ID,\n \tNL80211_NAN_FUNC_TERM_REASON,\n+\tNL80211_NAN_FUNC_SDEA_CTRL,\n+\tNL80211_NAN_FUNC_PAIRING_BOOTSTRAP_METHODS,\n+\tNL80211_NAN_FUNC_CSIDS,\n+\tNL80211_NAN_FUNC_PAIRING_SETUP,\n+\tNL80211_NAN_FUNC_PAIRING_CACHE,\n+\tNL80211_NAN_FUNC_PAIRING_VERIFY,\n+\tNL80211_NAN_FUNC_ND_PMK,\n+\tNL80211_NAN_FUNC_RANGING_INTERVAL,\n+\tNL80211_NAN_FUNC_INGRESS_DISTANCE,\n+\tNL80211_NAN_FUNC_EGRESS_DISTANCE,\n+\tNL80211_NAN_FUNC_FTMS_PER_BURST,\n+\tNL80211_NAN_FUNC_PREAMBLE,\n+\tNL80211_NAN_FUNC_CHAN,\n+\tNL80211_NAN_FUNC_RANGE_REPORT,\n \n \t/* keep last */\n \tNUM_NL80211_NAN_FUNC_ATTR,\n \tNL80211_NAN_FUNC_ATTR_MAX = NUM_NL80211_NAN_FUNC_ATTR - 1\n };\n \n+/**\n+ * enum nl80211_nan_func_sdea_ctrl_flags - NAN SDEA control field bit flags\n+ *\n+ * Bit definitions for the u16 SDEA control field carried in\n+ * %NL80211_NAN_FUNC_SDEA_CTRL, as specified in the Wi-Fi Aware\n+ * Specification Table 9-297.\n+ *\n+ * @NL80211_NAN_FUNC_SDEA_CTRL_DATAPATH_REQUIRED: bit 2 - Data Path Required.\n+ * @NL80211_NAN_FUNC_SDEA_CTRL_SECURITY_REQUIRED: bit 6 - Security Required.\n+ * @NL80211_NAN_FUNC_SDEA_CTRL_RANGING_REQUIRED: bit 7 - Ranging Required.\n+ * @NL80211_NAN_FUNC_SDEA_CTRL_GTK_REQUIRED: bit 10 - GTK Required.\n+ */\n+enum nl80211_nan_func_sdea_ctrl_flags {\n+\tNL80211_NAN_FUNC_SDEA_CTRL_DATAPATH_REQUIRED\t= 1 \u003c\u003c 2,\n+\tNL80211_NAN_FUNC_SDEA_CTRL_SECURITY_REQUIRED\t= 1 \u003c\u003c 6,\n+\tNL80211_NAN_FUNC_SDEA_CTRL_RANGING_REQUIRED\t= 1 \u003c\u003c 7,\n+\tNL80211_NAN_FUNC_SDEA_CTRL_GTK_REQUIRED\t\t= 1 \u003c\u003c 10,\n+};\n+\n /**\n  * enum nl80211_nan_srf_attributes - NAN Service Response filter attributes\n  * @__NL80211_NAN_SRF_INVALID: invalid\n@@ -7817,6 +7928,34 @@ enum nl80211_nan_srf_attributes {\n  * @NL80211_NAN_MATCH_FUNC_PEER: the peer function\n  *\tthat caused the match. This is a nested attribute.\n  *\tSee \u0026enum nl80211_nan_func_attributes.\n+ * @NL80211_NAN_MATCH_SDEA_CTRL: u16 SDEA control field from the peer's\n+ *\tService Descriptor Extension Attribute. Bit 2 indicates Data Path\n+ *\tRequired, bit 6 Security Required, bit 7 Ranging Required, bit 10\n+ *\tGTK Required.\n+ * @NL80211_NAN_MATCH_BOOTSTRAP_METHODS: u16 bitmap of the peer's\n+ *\tsupported NAN pairing bootstrapping methods per the Wi-Fi Aware\n+ *\tSpecification Table 9-321.\n+ * @NL80211_NAN_MATCH_CIPHER_SUITES: a set of u32 values indicating the NAN\n+ *\tcipher suite selectors advertised by the peer.\n+ * @NL80211_NAN_MATCH_PAIRING_SETUP: flag attribute. Set if the peer\n+ *\tsupports NAN pairing setup.\n+ * @NL80211_NAN_MATCH_PAIRING_CACHE: flag attribute. Set if the peer\n+ *\tsupports NAN pairing NPK/NIK caching.\n+ * @NL80211_NAN_MATCH_PAIRING_VERIFY: flag attribute. Set if the peer\n+ *\tsupports NAN pairing re-verification.\n+ * @NL80211_NAN_MATCH_EXTRA_INFO: binary attribute carrying the peer's\n+ *\tExtended Service Specific Info (Extended SSI), if present.\n+ * @NL80211_NAN_MATCH_IES: binary attribute carrying additional elements from\n+ *\tthe peer's Service Descriptor frame, if present.\n+ * @NL80211_NAN_MATCH_RSSI: s32 attribute. Received signal strength in dBm\n+ *\tat the time of the match. Only present when the driver provides a\n+ *\tvalid RSSI measurement.\n+ * @NL80211_NAN_MATCH_RANGING_INDICATION: u8 attribute. Bitmap indicating\n+ *\tthe type of ranging performed: bit 0: continuous ranging,\n+ *\tbit 1: ingress condition met, bit 2: egress condition met,\n+ *\tbit 1 and bit 2: both conditions met. Only present when non-zero.\n+ * @NL80211_NAN_MATCH_RANGING_MEASUREMENT: s32 attribute. Distance to\n+ *\tthe peer in millimetres measured via FTM.\n  *\n  * @NUM_NL80211_NAN_MATCH_ATTR: internal\n  * @NL80211_NAN_MATCH_ATTR_MAX: highest NAN match attribute\n@@ -7825,6 +7964,17 @@ enum nl80211_nan_match_attributes {\n \t__NL80211_NAN_MATCH_INVALID,\n \tNL80211_NAN_MATCH_FUNC_LOCAL,\n \tNL80211_NAN_MATCH_FUNC_PEER,\n+\tNL80211_NAN_MATCH_SDEA_CTRL,\n+\tNL80211_NAN_MATCH_BOOTSTRAP_METHODS,\n+\tNL80211_NAN_MATCH_CIPHER_SUITES,\n+\tNL80211_NAN_MATCH_PAIRING_SETUP,\n+\tNL80211_NAN_MATCH_PAIRING_CACHE,\n+\tNL80211_NAN_MATCH_PAIRING_VERIFY,\n+\tNL80211_NAN_MATCH_EXTRA_INFO,\n+\tNL80211_NAN_MATCH_IES,\n+\tNL80211_NAN_MATCH_RSSI,\n+\tNL80211_NAN_MATCH_RANGING_INDICATION,\n+\tNL80211_NAN_MATCH_RANGING_MEASUREMENT,\n \n \t/* keep last */\n \tNUM_NL80211_NAN_MATCH_ATTR,\n@@ -7938,6 +8088,100 @@ enum nl80211_nan_conf_attributes {\n \tNL80211_NAN_CONF_ATTR_MAX = NUM_NL80211_NAN_CONF_ATTR - 1,\n };\n \n+#define NL80211_NAN_NDP_PMKID_LEN\t\t16\n+#define NL80211_NAN_NDP_IPV6_INTF_ID_LEN\t8\n+\n+/**\n+ * enum nl80211_nan_ndp_attributes - NAN Data Path attributes\n+ *\n+ * Nested attributes used within %NL80211_ATTR_NAN_NDP for NDP setup\n+ * commands and events.\n+ *\n+ * @__NL80211_NAN_NDP_ATTR_INVALID: Invalid.\n+ * @NL80211_NAN_NDP_ATTR_ID: (u8) NDP ID (1-255). Allocated by the\n+ *\tinitiator and echoed in all subsequent NDP messages.\n+ * @NL80211_NAN_NDP_ATTR_PUBLISH_ID: (u8) Publisher's service instance\n+ *\tID. Present in %NL80211_CMD_NAN_NDP_INITIATE and\n+ *\t%NL80211_CMD_NAN_NDP_REQUEST. Used to match the NDP to a service.\n+ * @NL80211_NAN_NDP_ATTR_SERVICE_ID: binary (%NL80211_NAN_FUNC_SERVICE_ID_LEN\n+ *\tbytes). NAN service ID derived from the service name.\n+ * @NL80211_NAN_NDP_ATTR_INIT_NDI: (%ETH_ALEN bytes) Initiator NDI MAC\n+ *\taddress. The corresponding %NL80211_IFTYPE_NAN_DATA interface must\n+ *\texist.\n+ * @NL80211_NAN_NDP_ATTR_RESP_NDI: (%ETH_ALEN bytes) Responder NDI MAC\n+ *\taddress. Present in %NL80211_CMD_NAN_NDP_RESPOND (if accepting) and\n+ *\t%NL80211_CMD_NAN_NDP_CONFIRM. The corresponding\n+ *\t%NL80211_IFTYPE_NAN_DATA interface must exist.\n+ * @NL80211_NAN_NDP_ATTR_SSI: binary. Service-specific info carried in\n+ *\tthe NDP setup frames.\n+ * @NL80211_NAN_NDP_ATTR_CIPHER_SUITE: (u32) NAN cipher suite ID. 0 for\n+ *\topen (no security). See the Wi-Fi Aware Specification for values.\n+ * @NL80211_NAN_NDP_ATTR_PMK: binary (%NL80211_NAN_NDP_PMK_LEN bytes).\n+ *\tNAN Data Path PMK.\n+ *\tThe driver uses this to compute the PMKID and derive the PTK.\n+ *\tRequires %NL80211_EXT_FEATURE_SECURE_NAN.\n+ * @NL80211_NAN_NDP_ATTR_PMKID: binary (%NL80211_NAN_NDP_PMKID_LEN bytes).\n+ *\tPMKID from the peer's\n+ *\tSCIA attribute. Present in %NL80211_CMD_NAN_NDP_REQUEST to allow\n+ *\tuserspace to look up a cached PMK.\n+ * @NL80211_NAN_NDP_ATTR_GTK_REQUIRED: flag. GTK/IGTK/BIGTK protection\n+ *\trequired for group-addressed NDP frames.\n+ * @NL80211_NAN_NDP_ATTR_GTK_CIPHER: (u32) GTK cipher suite ID. Required\n+ *\tif %NL80211_NAN_NDP_ATTR_GTK_REQUIRED is set.\n+ * @NL80211_NAN_NDP_ATTR_IPV6_INTF_ID: binary (%NL80211_NAN_NDP_IPV6_INTF_ID_LEN\n+ *\tbytes). IPv6 link-local\n+ *\tinterface identifier. Included as NDPE TLV type 0 when present.\n+ * @NL80211_NAN_NDP_ATTR_NDPE: flag. Use NDPE attribute instead of NDP\n+ *\tattribute when peer supports NDPE.\n+ * @NL80211_NAN_NDP_ATTR_ACCEPT: flag. If present in\n+ *\t%NL80211_CMD_NAN_NDP_RESPOND, the NDP is accepted. If absent, it is\n+ *\trejected.\n+ * @NL80211_NAN_NDP_ATTR_REASON: (u8) Termination or rejection reason\n+ *\tcode (enum nan_reason from the Wi-Fi Aware Specification).\n+ * @NL80211_NAN_NDP_ATTR_STATUS: (u8) NDP status in\n+ *\t%NL80211_CMD_NAN_NDP_CONFIRM, see \u0026enum nl80211_nan_ndp_status.\n+ * @__NL80211_NAN_NDP_ATTR_LAST: Internal.\n+ * @NL80211_NAN_NDP_ATTR_MAX: Highest NDP attribute.\n+ */\n+enum nl80211_nan_ndp_attributes {\n+\t__NL80211_NAN_NDP_ATTR_INVALID,\n+\n+\tNL80211_NAN_NDP_ATTR_ID,\n+\tNL80211_NAN_NDP_ATTR_PUBLISH_ID,\n+\tNL80211_NAN_NDP_ATTR_SERVICE_ID,\n+\tNL80211_NAN_NDP_ATTR_INIT_NDI,\n+\tNL80211_NAN_NDP_ATTR_RESP_NDI,\n+\tNL80211_NAN_NDP_ATTR_SSI,\n+\tNL80211_NAN_NDP_ATTR_CIPHER_SUITE,\n+\tNL80211_NAN_NDP_ATTR_PMK,\n+\tNL80211_NAN_NDP_ATTR_PMKID,\n+\tNL80211_NAN_NDP_ATTR_GTK_REQUIRED,\n+\tNL80211_NAN_NDP_ATTR_GTK_CIPHER,\n+\tNL80211_NAN_NDP_ATTR_IPV6_INTF_ID,\n+\tNL80211_NAN_NDP_ATTR_NDPE,\n+\tNL80211_NAN_NDP_ATTR_ACCEPT,\n+\tNL80211_NAN_NDP_ATTR_REASON,\n+\tNL80211_NAN_NDP_ATTR_STATUS,\n+\n+\t/* keep last */\n+\t__NL80211_NAN_NDP_ATTR_LAST,\n+\tNL80211_NAN_NDP_ATTR_MAX = __NL80211_NAN_NDP_ATTR_LAST - 1,\n+};\n+\n+/**\n+ * enum nl80211_nan_ndp_status - NAN Data Path setup status\n+ *\n+ * Values for %NL80211_NAN_NDP_ATTR_STATUS reported in\n+ * %NL80211_CMD_NAN_NDP_CONFIRM.\n+ *\n+ * @NL80211_NAN_NDP_STATUS_ACCEPTED: NDP setup was accepted by the peer.\n+ * @NL80211_NAN_NDP_STATUS_REJECTED: NDP setup was rejected by the peer.\n+ */\n+enum nl80211_nan_ndp_status {\n+\tNL80211_NAN_NDP_STATUS_ACCEPTED,\n+\tNL80211_NAN_NDP_STATUS_REJECTED,\n+};\n+\n /**\n  * enum nl80211_external_auth_action - Action to perform with external\n  *     authentication request. Used by NL80211_ATTR_EXTERNAL_AUTH_ACTION.\n@@ -8143,12 +8387,16 @@ enum nl80211_peer_measurement_resp {\n  * @NL80211_PMSR_FTM_REQ_TYPE_PD: peer-to-peer ranging as defined in the\n  *\tWi-Fi Alliance specification \"Proximity Ranging (PR) Implementation\n  *\tConsideration Draft 1.9 Rev 1\"\n+ * @NL80211_PMSR_FTM_REQ_TYPE_NAN: NAN ranging between two NAN devices as\n+ *\tdefined in the \"Wi-Fi Aware Specification v4.0, clause 8\".\n+ *\tMust be issued on a %NL80211_IFTYPE_NAN interface.\n  * @NUM_NL80211_PMSR_FTM_REQ_TYPE: internal\n  * @NL80211_PMSR_FTM_REQ_TYPE_MAX: highest request type value\n  */\n enum nl80211_peer_measurement_ftm_req_type {\n \tNL80211_PMSR_FTM_REQ_TYPE_INFRA,\n \tNL80211_PMSR_FTM_REQ_TYPE_PD,\n+\tNL80211_PMSR_FTM_REQ_TYPE_NAN,\n \n \t/* keep last */\n \tNUM_NL80211_PMSR_FTM_REQ_TYPE,\n@@ -8397,6 +8645,9 @@ enum nl80211_peer_measurement_ftm_capa {\n  *\tthe device supports peer-to-peer ranging as mentioned in the\n  *\tspecification \"PR Implementation Consideration Draft 1.9 rev 1\" where\n  *\tPD stands for proximity detection\n+ * @NL80211_PMSR_FTM_TYPE_CAPA_ATTR_NAN_SUPPORT: flag attribute indicating\n+ *\tthat the device supports NAN ranging between two NAN devices as\n+ *\tdefined in the \"Wi-Fi Aware Specification v4.0, clause 8\".\n  *\n  * @NUM_NL80211_PMSR_FTM_TYPE_CAPA_ATTR: internal\n  * @NL80211_PMSR_FTM_TYPE_CAPA_ATTR_MAX: highest attribute number\n@@ -8406,6 +8657,7 @@ enum nl80211_peer_measurement_ftm_type_capa {\n \n \tNL80211_PMSR_FTM_TYPE_CAPA_ATTR_INFRA_SUPPORT,\n \tNL80211_PMSR_FTM_TYPE_CAPA_ATTR_PD_SUPPORT,\n+\tNL80211_PMSR_FTM_TYPE_CAPA_ATTR_NAN_SUPPORT,\n \n \t/* keep last */\n \tNUM_NL80211_PMSR_FTM_TYPE_CAPA_ATTR,\n@@ -8512,6 +8764,11 @@ enum nl80211_peer_measurement_ftm_type_capa {\n  *\tbut results are not reported to userspace, regardless of ranging role\n  *\tor type. Only valid when %NL80211_PMSR_PEER_ATTR_REQ_TYPE is set to\n  *\t%NL80211_PMSR_FTM_REQ_TYPE_PD.\n+ * @NL80211_PMSR_FTM_REQ_ATTR_RANGE_REPORT: Flag indicating that a NAN\n+ *\tRanging Report is required after the FTM session. Only valid for a NAN\n+ *\tRSTA request.\n+ * @NL80211_PMSR_FTM_REQ_ATTR_MIN_DELTA_FTM: NAN Min Delta FTM value in units\n+ *\tof 100 microseconds (u8, 0-63). A value of 0 indicates no preference.\n  *\n  * @NUM_NL80211_PMSR_FTM_REQ_ATTR: internal\n  * @NL80211_PMSR_FTM_REQ_ATTR_MAX: highest attribute number\n@@ -8542,6 +8799,8 @@ enum nl80211_peer_measurement_ftm_req {\n \tNL80211_PMSR_FTM_REQ_ATTR_INGRESS,\n \tNL80211_PMSR_FTM_REQ_ATTR_EGRESS,\n \tNL80211_PMSR_FTM_REQ_ATTR_PD_SUPPRESS_RESULTS,\n+\tNL80211_PMSR_FTM_REQ_ATTR_RANGE_REPORT,\n+\tNL80211_PMSR_FTM_REQ_ATTR_MIN_DELTA_FTM,\n \n \t/* keep last */\n \tNUM_NL80211_PMSR_FTM_REQ_ATTR,\n@@ -9153,6 +9412,12 @@ enum nl80211_s1g_short_beacon_attrs {\n  *\tof the Wi-Fi Aware Specification v4.0. Can only be set if\n  *\t%NL80211_NAN_CAPA_CONFIGURABLE_SYNC is set. When IC is enabled, the IC\n  *\tschedule is expected to be configured by user space.\n+ * @NL80211_NAN_CAPA_OFFLOAD_RANGING: flag attribute. Firmware supports the\n+ *\tfully offloaded NAN ranging procedure, including ranging session setup,\n+ *\tupdate, and termination, FTM protocol and procedure, and ranging reports.\n+ * @NL80211_NAN_CAPA_OFFLOAD_NDP: flag attribute. Driver handles NAN Data\n+ *\tPath (NDP) handshake frames and data path key installation.\n+\n  * @__NL80211_NAN_CAPABILITIES_LAST: Internal\n  * @NL80211_NAN_CAPABILITIES_MAX: Highest NAN capability attribute.\n  */\n@@ -9167,6 +9432,8 @@ enum nl80211_nan_capabilities {\n \tNL80211_NAN_CAPA_CAPABILITIES,\n \tNL80211_NAN_CAPA_PHY,\n \tNL80211_NAN_CAPA_INSTANT_COMM,\n+\tNL80211_NAN_CAPA_OFFLOAD_RANGING,\n+\tNL80211_NAN_CAPA_OFFLOAD_NDP,\n \t/* keep last */\n \t__NL80211_NAN_CAPABILITIES_LAST,\n \tNL80211_NAN_CAPABILITIES_MAX = __NL80211_NAN_CAPABILITIES_LAST - 1,\ndiff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c\nindex d790e204aee36..e4b664bdf53df 100644\n--- a/net/wireless/nl80211.c\n+++ b/net/wireless/nl80211.c\n@@ -557,7 +557,7 @@ nl80211_ftm_responder_policy[NL80211_FTM_RESP_ATTR_MAX + 1] = {\n \t\t\t\t\t     .len = U8_MAX },\n };\n \n-static const struct nla_policy\n+const struct nla_policy\n nl80211_pmsr_ftm_req_attr_policy[NL80211_PMSR_FTM_REQ_ATTR_MAX + 1] = {\n \t[NL80211_PMSR_FTM_REQ_ATTR_ASAP] = { .type = NLA_FLAG },\n \t[NL80211_PMSR_FTM_REQ_ATTR_PREAMBLE] =\n@@ -589,6 +589,9 @@ nl80211_pmsr_ftm_req_attr_policy[NL80211_PMSR_FTM_REQ_ATTR_MAX + 1] = {\n \t[NL80211_PMSR_FTM_REQ_ATTR_INGRESS] = { .type = NLA_U64 },\n \t[NL80211_PMSR_FTM_REQ_ATTR_EGRESS] = { .type = NLA_U64 },\n \t[NL80211_PMSR_FTM_REQ_ATTR_PD_SUPPRESS_RESULTS] = { .type = NLA_FLAG },\n+\t[NL80211_PMSR_FTM_REQ_ATTR_RANGE_REPORT] = { .type = NLA_FLAG },\n+\t[NL80211_PMSR_FTM_REQ_ATTR_MIN_DELTA_FTM] =\n+\t\tNLA_POLICY_MAX(NLA_U8, 63),\n };\n \n static const struct nla_policy\n@@ -769,6 +772,33 @@ nl80211_nan_peer_map_policy[NL80211_NAN_PEER_MAP_ATTR_MAX + 1] = {\n \t\tNLA_POLICY_EXACT_LEN(CFG80211_NAN_SCHED_NUM_TIME_SLOTS),\n };\n \n+static const struct nla_policy\n+nl80211_nan_ndp_policy[NL80211_NAN_NDP_ATTR_MAX + 1] = {\n+\t[NL80211_NAN_NDP_ATTR_ID] = NLA_POLICY_RANGE(NLA_U8, 1, 255),\n+\t[NL80211_NAN_NDP_ATTR_PUBLISH_ID] = { .type = NLA_U8 },\n+\t[NL80211_NAN_NDP_ATTR_SERVICE_ID] =\n+\t\tNLA_POLICY_EXACT_LEN(NL80211_NAN_FUNC_SERVICE_ID_LEN),\n+\t[NL80211_NAN_NDP_ATTR_INIT_NDI] = NLA_POLICY_EXACT_LEN(ETH_ALEN),\n+\t[NL80211_NAN_NDP_ATTR_RESP_NDI] = NLA_POLICY_EXACT_LEN(ETH_ALEN),\n+\t[NL80211_NAN_NDP_ATTR_SSI] = {\n+\t\t.type = NLA_BINARY,\n+\t\t.len = NL80211_NAN_FUNC_SERVICE_SPEC_INFO_MAX_LEN\n+\t},\n+\t[NL80211_NAN_NDP_ATTR_CIPHER_SUITE] = { .type = NLA_U32 },\n+\t[NL80211_NAN_NDP_ATTR_PMK] =\n+\t\tNLA_POLICY_EXACT_LEN(NL80211_NAN_NDP_PMK_LEN),\n+\t[NL80211_NAN_NDP_ATTR_PMKID] =\n+\t\tNLA_POLICY_EXACT_LEN(NL80211_NAN_NDP_PMKID_LEN),\n+\t[NL80211_NAN_NDP_ATTR_GTK_REQUIRED] = { .type = NLA_FLAG },\n+\t[NL80211_NAN_NDP_ATTR_GTK_CIPHER] = { .type = NLA_U32 },\n+\t[NL80211_NAN_NDP_ATTR_IPV6_INTF_ID] =\n+\t\tNLA_POLICY_EXACT_LEN(NL80211_NAN_NDP_IPV6_INTF_ID_LEN),\n+\t[NL80211_NAN_NDP_ATTR_NDPE] = { .type = NLA_FLAG },\n+\t[NL80211_NAN_NDP_ATTR_ACCEPT] = { .type = NLA_FLAG },\n+\t[NL80211_NAN_NDP_ATTR_REASON] = { .type = NLA_U8 },\n+\t[NL80211_NAN_NDP_ATTR_STATUS] = { .type = NLA_U8 },\n+};\n+\n static const struct nla_policy\n nl80211_nan_conf_policy[NL80211_NAN_CONF_ATTR_MAX + 1] = {\n \t[NL80211_NAN_CONF_CLUSTER_ID] =\n@@ -1193,6 +1223,7 @@ static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {\n \t[NL80211_ATTR_NAN_MAX_CHAN_SWITCH_TIME] = { .type = NLA_U16 },\n \t[NL80211_ATTR_NAN_PEER_MAPS] =\n \t\tNLA_POLICY_NESTED_ARRAY(nl80211_nan_peer_map_policy),\n+\t[NL80211_ATTR_NAN_NDP] = NLA_POLICY_NESTED(nl80211_nan_ndp_policy),\n \t[NL80211_ATTR_NPCA_PRIMARY_FREQ] = { .type = NLA_U32 },\n \t[NL80211_ATTR_NPCA_PUNCT_BITMAP] =\n \t\tNLA_POLICY_FULL_RANGE(NLA_U32, \u0026nl80211_punct_bitmap_range),\n@@ -1334,6 +1365,24 @@ nl80211_nan_func_policy[NL80211_NAN_FUNC_ATTR_MAX + 1] = {\n \t[NL80211_NAN_FUNC_TX_MATCH_FILTER] = { .type = NLA_NESTED },\n \t[NL80211_NAN_FUNC_INSTANCE_ID] = { .type = NLA_U8 },\n \t[NL80211_NAN_FUNC_TERM_REASON] = { .type = NLA_U8 },\n+\t[NL80211_NAN_FUNC_SDEA_CTRL] = { .type = NLA_U16 },\n+\t[NL80211_NAN_FUNC_PAIRING_BOOTSTRAP_METHODS] = { .type = NLA_U16 },\n+\t[NL80211_NAN_FUNC_CSIDS] = { .type = NLA_BINARY,\n+\t\t\t\t     .len = U8_MAX * sizeof(u32) },\n+\t[NL80211_NAN_FUNC_ND_PMK] =\n+\t\tNLA_POLICY_EXACT_LEN(NL80211_NAN_NDP_PMK_LEN),\n+\t[NL80211_NAN_FUNC_PAIRING_SETUP] = { .type = NLA_FLAG },\n+\t[NL80211_NAN_FUNC_PAIRING_CACHE] = { .type = NLA_FLAG },\n+\t[NL80211_NAN_FUNC_PAIRING_VERIFY] = { .type = NLA_FLAG },\n+\t[NL80211_NAN_FUNC_RANGING_INTERVAL] = { .type = NLA_U32 },\n+\t[NL80211_NAN_FUNC_INGRESS_DISTANCE] = { .type = NLA_U32 },\n+\t[NL80211_NAN_FUNC_EGRESS_DISTANCE] = { .type = NLA_U32 },\n+\t[NL80211_NAN_FUNC_FTMS_PER_BURST] = { .type = NLA_U8 },\n+\t[NL80211_NAN_FUNC_PREAMBLE] =\n+\t\tNLA_POLICY_RANGE(NLA_U32, NL80211_PREAMBLE_LEGACY,\n+\t\t\t\t NL80211_PREAMBLE_HE),\n+\t[NL80211_NAN_FUNC_CHAN] = { .type = NLA_NESTED },\n+\t[NL80211_NAN_FUNC_RANGE_REPORT] = { .type = NLA_FLAG },\n };\n \n /* policy for Service Response Filter attributes */\n@@ -2730,7 +2779,8 @@ nl80211_send_pmsr_ftm_capa(const struct cfg80211_pmsr_capabilities *cap,\n \t\t\tcap-\u003eftm.min_allowed_ranging_interval_ntb))\n \t\treturn -ENOBUFS;\n \n-\tif (cap-\u003eftm.type.infra_support || cap-\u003eftm.type.pd_support) {\n+\tif (cap-\u003eftm.type.infra_support || cap-\u003eftm.type.pd_support ||\n+\t    cap-\u003eftm.type.nan_support) {\n \t\tstruct nlattr *pd_caps;\n \n \t\tpd_caps = nla_nest_start_noflag(msg,\n@@ -2746,6 +2796,10 @@ nl80211_send_pmsr_ftm_capa(const struct cfg80211_pmsr_capabilities *cap,\n \t\t    nla_put_flag(msg, NL80211_PMSR_FTM_TYPE_CAPA_ATTR_PD_SUPPORT))\n \t\t\treturn -ENOBUFS;\n \n+\t\tif (cap-\u003eftm.type.nan_support \u0026\u0026\n+\t\t    nla_put_flag(msg, NL80211_PMSR_FTM_TYPE_CAPA_ATTR_NAN_SUPPORT))\n+\t\t\treturn -ENOBUFS;\n+\n \t\tnla_nest_end(msg, pd_caps);\n \t}\n \n@@ -3138,6 +3192,14 @@ static int nl80211_put_nan_capa(struct wiphy *wiphy, struct sk_buff *msg)\n \t    nla_put_flag(msg, NL80211_NAN_CAPA_INSTANT_COMM))\n \t\tgoto fail;\n \n+\tif ((wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_OFFLOAD_RANGING) \u0026\u0026\n+\t    nla_put_flag(msg, NL80211_NAN_CAPA_OFFLOAD_RANGING))\n+\t\tgoto fail;\n+\n+\tif ((wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_OFFLOAD_NDP) \u0026\u0026\n+\t    nla_put_flag(msg, NL80211_NAN_CAPA_OFFLOAD_NDP))\n+\t\tgoto fail;\n+\n \tif (nla_put_u8(msg, NL80211_NAN_CAPA_OP_MODE,\n \t\t       wiphy-\u003enan_capa.op_mode) ||\n \t    nla_put_u8(msg, NL80211_NAN_CAPA_NUM_ANTENNAS,\n@@ -17383,6 +17445,12 @@ static int nl80211_nan_add_func(struct sk_buff *skb,\n \tif (!wdev_running(wdev))\n \t\treturn -ENOTCONN;\n \n+\tif (wdev-\u003ewiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_USERSPACE_DE) {\n+\t\tNL_SET_ERR_MSG(info-\u003eextack,\n+\t\t\t       \"NAN Discovery Engine is in userspace\");\n+\t\treturn -EOPNOTSUPP;\n+\t}\n+\n \tif (!info-\u003eattrs[NL80211_ATTR_NAN_FUNC])\n \t\treturn -EINVAL;\n \n@@ -17558,6 +17626,189 @@ static int nl80211_nan_add_func(struct sk_buff *skb,\n \t\t\tgoto out;\n \t}\n \n+\tif (tb[NL80211_NAN_FUNC_SDEA_CTRL]) {\n+\t\tu16 sdea = nla_get_u16(tb[NL80211_NAN_FUNC_SDEA_CTRL]);\n+\n+\t\tif ((sdea \u0026 NL80211_NAN_FUNC_SDEA_CTRL_SECURITY_REQUIRED) \u0026\u0026\n+\t\t    !(sdea \u0026 NL80211_NAN_FUNC_SDEA_CTRL_DATAPATH_REQUIRED)) {\n+\t\t\tNL_SET_ERR_MSG(info-\u003eextack,\n+\t\t\t\t       \"SDEA Security Required requires Data Path Required\");\n+\t\t\terr = -EINVAL;\n+\t\t\tgoto out;\n+\t\t}\n+\n+\t\tif ((sdea \u0026 (NL80211_NAN_FUNC_SDEA_CTRL_SECURITY_REQUIRED |\n+\t\t\t     NL80211_NAN_FUNC_SDEA_CTRL_GTK_REQUIRED)) \u0026\u0026\n+\t\t    !wiphy_ext_feature_isset(wdev-\u003ewiphy,\n+\t\t\t\t\t     NL80211_EXT_FEATURE_SECURE_NAN)) {\n+\t\t\tNL_SET_ERR_MSG(info-\u003eextack,\n+\t\t\t\t       \"SDEA security bits require SECURE_NAN\");\n+\t\t\terr = -EOPNOTSUPP;\n+\t\t\tgoto out;\n+\t\t}\n+\n+\t\tif ((sdea \u0026 NL80211_NAN_FUNC_SDEA_CTRL_DATAPATH_REQUIRED) \u0026\u0026\n+\t\t    !(wdev-\u003ewiphy-\u003enan_capa.flags \u0026\n+\t\t      WIPHY_NAN_FLAGS_OFFLOAD_NDP)) {\n+\t\t\tNL_SET_ERR_MSG(info-\u003eextack,\n+\t\t\t\t       \"SDEA Data Path bit requires OFFLOAD_NDP\");\n+\t\t\terr = -EOPNOTSUPP;\n+\t\t\tgoto out;\n+\t\t}\n+\t\tfunc-\u003esdea_ctrl = sdea;\n+\t}\n+\n+\tif (tb[NL80211_NAN_FUNC_PAIRING_BOOTSTRAP_METHODS] ||\n+\t    tb[NL80211_NAN_FUNC_PAIRING_SETUP] ||\n+\t    tb[NL80211_NAN_FUNC_PAIRING_CACHE] ||\n+\t    tb[NL80211_NAN_FUNC_PAIRING_VERIFY] ||\n+\t    tb[NL80211_NAN_FUNC_CSIDS] ||\n+\t    tb[NL80211_NAN_FUNC_ND_PMK]) {\n+\t\tif (!wiphy_ext_feature_isset(wdev-\u003ewiphy,\n+\t\t\t\t\t     NL80211_EXT_FEATURE_SECURE_NAN)) {\n+\t\t\tNL_SET_ERR_MSG(info-\u003eextack,\n+\t\t\t\t       \"Security attributes require SECURE_NAN\");\n+\t\t\terr = -EINVAL;\n+\t\t\tgoto out;\n+\t\t}\n+\n+\t\tif (tb[NL80211_NAN_FUNC_PAIRING_BOOTSTRAP_METHODS])\n+\t\t\tfunc-\u003epairing_bootstrap_methods =\n+\t\t\t\tnla_get_u16(tb[NL80211_NAN_FUNC_PAIRING_BOOTSTRAP_METHODS]);\n+\n+\t\tfunc-\u003epairing_setup =\n+\t\t\tnla_get_flag(tb[NL80211_NAN_FUNC_PAIRING_SETUP]);\n+\t\tfunc-\u003epairing_cache =\n+\t\t\tnla_get_flag(tb[NL80211_NAN_FUNC_PAIRING_CACHE]);\n+\t\tfunc-\u003epairing_verify =\n+\t\t\tnla_get_flag(tb[NL80211_NAN_FUNC_PAIRING_VERIFY]);\n+\n+\t\tif (tb[NL80211_NAN_FUNC_CSIDS]) {\n+\t\t\tint len = nla_len(tb[NL80211_NAN_FUNC_CSIDS]);\n+\t\t\tint n = len / sizeof(u32);\n+\n+\t\t\tif (len % sizeof(u32)) {\n+\t\t\t\tNL_SET_ERR_MSG_ATTR(info-\u003eextack,\n+\t\t\t\t\t\t    tb[NL80211_NAN_FUNC_CSIDS],\n+\t\t\t\t\t\t    \"CSIDs must be an array of u32 values\");\n+\t\t\t\terr = -EINVAL;\n+\t\t\t\tgoto out;\n+\t\t\t}\n+\n+\t\t\tif (n \u003e 0) {\n+\t\t\t\tfunc-\u003ecsids =\n+\t\t\t\t\tkmemdup(nla_data(tb[NL80211_NAN_FUNC_CSIDS]),\n+\t\t\t\t\t\tlen, GFP_KERNEL);\n+\t\t\t\tif (!func-\u003ecsids) {\n+\t\t\t\t\terr = -ENOMEM;\n+\t\t\t\t\tgoto out;\n+\t\t\t\t}\n+\t\t\t\tfunc-\u003enum_csids = n;\n+\t\t\t}\n+\t\t}\n+\n+\t\tif (tb[NL80211_NAN_FUNC_ND_PMK]) {\n+\t\t\tmemcpy(func-\u003end_pmk,\n+\t\t\t       nla_data(tb[NL80211_NAN_FUNC_ND_PMK]),\n+\t\t\t       sizeof(func-\u003end_pmk));\n+\t\t\tfunc-\u003end_pmk_set = true;\n+\t\t}\n+\t}\n+\n+\tif (tb[NL80211_NAN_FUNC_RANGING_INTERVAL] ||\n+\t    tb[NL80211_NAN_FUNC_INGRESS_DISTANCE] ||\n+\t    tb[NL80211_NAN_FUNC_EGRESS_DISTANCE] ||\n+\t    tb[NL80211_NAN_FUNC_FTMS_PER_BURST] ||\n+\t    tb[NL80211_NAN_FUNC_PREAMBLE] ||\n+\t    tb[NL80211_NAN_FUNC_CHAN] ||\n+\t    tb[NL80211_NAN_FUNC_RANGE_REPORT]) {\n+\t\tconst struct cfg80211_pmsr_capabilities *pmsr_capa =\n+\t\t\trdev-\u003ewiphy.pmsr_capa;\n+\n+\t\t/* SDEA Ranging Required bit must be set */\n+\t\tif (!(func-\u003esdea_ctrl \u0026 NL80211_NAN_FUNC_SDEA_CTRL_RANGING_REQUIRED)) {\n+\t\t\tNL_SET_ERR_MSG(info-\u003eextack,\n+\t\t\t\t       \"NAN ranging parameters require SDEA Ranging Required bit\");\n+\t\t\terr = -EINVAL;\n+\t\t\tgoto out;\n+\t\t}\n+\n+\t\tif (!(wdev-\u003ewiphy-\u003enan_capa.flags \u0026\n+\t\t      WIPHY_NAN_FLAGS_OFFLOAD_RANGING) ||\n+\t\t    !pmsr_capa || !pmsr_capa-\u003eftm.supported) {\n+\t\t\tNL_SET_ERR_MSG(info-\u003eextack,\n+\t\t\t\t       \"NAN ranging not supported by device\");\n+\t\t\terr = -EOPNOTSUPP;\n+\t\t\tgoto out;\n+\t\t}\n+\n+\t\tif (tb[NL80211_NAN_FUNC_RANGING_INTERVAL])\n+\t\t\tfunc-\u003eranging_interval =\n+\t\t\t\tnla_get_u32(tb[NL80211_NAN_FUNC_RANGING_INTERVAL]);\n+\n+\t\tif (tb[NL80211_NAN_FUNC_INGRESS_DISTANCE])\n+\t\t\tfunc-\u003eingress_distance =\n+\t\t\t\tnla_get_u32(tb[NL80211_NAN_FUNC_INGRESS_DISTANCE]);\n+\n+\t\tif (tb[NL80211_NAN_FUNC_EGRESS_DISTANCE])\n+\t\t\tfunc-\u003eegress_distance =\n+\t\t\t\tnla_get_u32(tb[NL80211_NAN_FUNC_EGRESS_DISTANCE]);\n+\n+\t\tif (tb[NL80211_NAN_FUNC_FTMS_PER_BURST]) {\n+\t\t\tfunc-\u003eftms_per_burst =\n+\t\t\t\tnla_get_u8(tb[NL80211_NAN_FUNC_FTMS_PER_BURST]);\n+\t\t\tif (func-\u003eftms_per_burst \u003e 31) {\n+\t\t\t\tNL_SET_ERR_MSG_ATTR(info-\u003eextack,\n+\t\t\t\t\t\t    tb[NL80211_NAN_FUNC_FTMS_PER_BURST],\n+\t\t\t\t\t\t    \"NAN FTMs per burst exceeds limit of 31\");\n+\t\t\t\terr = -EINVAL;\n+\t\t\t\tgoto out;\n+\t\t\t}\n+\t\t\tif (pmsr_capa-\u003eftm.max_ftms_per_burst \u0026\u0026\n+\t\t\t    func-\u003eftms_per_burst \u003e pmsr_capa-\u003eftm.max_ftms_per_burst) {\n+\t\t\t\tNL_SET_ERR_MSG_ATTR(info-\u003eextack,\n+\t\t\t\t\t\t    tb[NL80211_NAN_FUNC_FTMS_PER_BURST],\n+\t\t\t\t\t\t    \"NAN FTMs per burst exceeds device limit\");\n+\t\t\t\terr = -EINVAL;\n+\t\t\t\tgoto out;\n+\t\t\t}\n+\t\t}\n+\n+\t\tif (tb[NL80211_NAN_FUNC_PREAMBLE]) {\n+\t\t\tfunc-\u003epreamble =\n+\t\t\t\tnla_get_u32(tb[NL80211_NAN_FUNC_PREAMBLE]);\n+\t\t\tif (!(pmsr_capa-\u003eftm.preambles \u0026 BIT(func-\u003epreamble))) {\n+\t\t\t\tNL_SET_ERR_MSG_ATTR(info-\u003eextack,\n+\t\t\t\t\t\t    tb[NL80211_NAN_FUNC_PREAMBLE],\n+\t\t\t\t\t\t    \"NAN ranging: unsupported preamble\");\n+\t\t\t\terr = -EINVAL;\n+\t\t\t\tgoto out;\n+\t\t\t}\n+\t\t}\n+\n+\t\tif (tb[NL80211_NAN_FUNC_CHAN]) {\n+\t\t\t/* Reuse info-\u003eattrs for chandef parsing; the original contents\n+\t\t\t * are no longer needed.\n+\t\t\t */\n+\t\t\tmemset(info-\u003eattrs, 0,\n+\t\t\t       sizeof(*info-\u003eattrs) * (NL80211_ATTR_MAX + 1));\n+\t\t\terr = nla_parse_nested(info-\u003eattrs, NL80211_ATTR_MAX,\n+\t\t\t\t\t       tb[NL80211_NAN_FUNC_CHAN],\n+\t\t\t\t\t       nl80211_policy, info-\u003eextack);\n+\t\t\tif (err)\n+\t\t\t\tgoto out;\n+\t\t\terr = nl80211_parse_chandef(rdev, info-\u003eextack,\n+\t\t\t\t\t\t    info-\u003eattrs,\n+\t\t\t\t\t\t    \u0026func-\u003echandef, false);\n+\t\t\tif (err)\n+\t\t\t\tgoto out;\n+\t\t\tfunc-\u003echandef_valid = true;\n+\t\t}\n+\n+\t\tfunc-\u003erange_report =\n+\t\t\tnla_get_flag(tb[NL80211_NAN_FUNC_RANGE_REPORT]);\n+\t}\n+\n \tmsg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);\n \tif (!msg) {\n \t\terr = -ENOMEM;\n@@ -17757,6 +18008,58 @@ void cfg80211_nan_match(struct wireless_dev *wdev,\n \t\tgoto nla_put_failure;\n \n \tnla_nest_end(msg, peer_func_attr);\n+\n+\tif (match-\u003esdea_ctrl \u0026\u0026\n+\t    nla_put_u16(msg, NL80211_NAN_MATCH_SDEA_CTRL, match-\u003esdea_ctrl))\n+\t\tgoto nla_put_failure;\n+\n+\tif (match-\u003epairing_bootstrap_methods \u0026\u0026\n+\t    nla_put_u16(msg, NL80211_NAN_MATCH_BOOTSTRAP_METHODS,\n+\t\t\tmatch-\u003epairing_bootstrap_methods))\n+\t\tgoto nla_put_failure;\n+\n+\tif (match-\u003ecsids \u0026\u0026 match-\u003enum_csids \u0026\u0026\n+\t    nla_put(msg, NL80211_NAN_MATCH_CIPHER_SUITES,\n+\t\t    match-\u003enum_csids * sizeof(u32),\n+\t\t    match-\u003ecsids))\n+\t\tgoto nla_put_failure;\n+\n+\tif (match-\u003epairing_setup \u0026\u0026\n+\t    nla_put_flag(msg, NL80211_NAN_MATCH_PAIRING_SETUP))\n+\t\tgoto nla_put_failure;\n+\n+\tif (match-\u003epairing_cache \u0026\u0026\n+\t    nla_put_flag(msg, NL80211_NAN_MATCH_PAIRING_CACHE))\n+\t\tgoto nla_put_failure;\n+\n+\tif (match-\u003epairing_verify \u0026\u0026\n+\t    nla_put_flag(msg, NL80211_NAN_MATCH_PAIRING_VERIFY))\n+\t\tgoto nla_put_failure;\n+\n+\tif (match-\u003eextra_info \u0026\u0026 match-\u003eextra_info_len \u0026\u0026\n+\t    nla_put(msg, NL80211_NAN_MATCH_EXTRA_INFO, match-\u003eextra_info_len,\n+\t\t    match-\u003eextra_info))\n+\t\tgoto nla_put_failure;\n+\n+\tif (match-\u003eies \u0026\u0026 match-\u003eies_len \u0026\u0026\n+\t    nla_put(msg, NL80211_NAN_MATCH_IES, match-\u003eies_len, match-\u003eies))\n+\t\tgoto nla_put_failure;\n+\n+\tif (match-\u003erssi_valid \u0026\u0026\n+\t    nla_put_s32(msg, NL80211_NAN_MATCH_RSSI, match-\u003erssi))\n+\t\tgoto nla_put_failure;\n+\n+\t/* report ranging info only if ranging was indicated */\n+\tif (match-\u003eranging_indication) {\n+\t\tif (nla_put_u8(msg, NL80211_NAN_MATCH_RANGING_INDICATION,\n+\t\t\t       match-\u003eranging_indication))\n+\t\t\tgoto nla_put_failure;\n+\n+\t\tif (nla_put_s32(msg, NL80211_NAN_MATCH_RANGING_MEASUREMENT,\n+\t\t\t\tmatch-\u003eranging_measurement))\n+\t\t\tgoto nla_put_failure;\n+\t}\n+\n \tnla_nest_end(msg, match_attr);\n \tgenlmsg_end(msg, hdr);\n \n@@ -18198,6 +18501,507 @@ static int nl80211_nan_set_peer_sched(struct sk_buff *skb,\n \treturn rdev_nan_set_peer_sched(rdev, wdev, \u0026sched);\n }\n \n+static int nl80211_nan_ndp_initiate(struct sk_buff *skb,\n+\t\t\t\t    struct genl_info *info)\n+{\n+\tstruct cfg80211_registered_device *rdev = info-\u003euser_ptr[0];\n+\tstruct wireless_dev *wdev = info-\u003euser_ptr[1];\n+\tstruct nlattr *tb[NL80211_NAN_NDP_ATTR_MAX + 1];\n+\tstruct cfg80211_nan_ndp_initiate params = {};\n+\tint err;\n+\n+\tif (wdev-\u003eiftype != NL80211_IFTYPE_NAN) {\n+\t\tNL_SET_ERR_MSG(info-\u003eextack,\n+\t\t\t       \"NDP initiate requires NAN interface\");\n+\t\treturn -EOPNOTSUPP;\n+\t}\n+\n+\tif (!(rdev-\u003ewiphy.nan_capa.flags \u0026 WIPHY_NAN_FLAGS_OFFLOAD_NDP)) {\n+\t\tNL_SET_ERR_MSG(info-\u003eextack,\n+\t\t\t       \"NAN NDP offload not supported by driver\");\n+\t\treturn -EOPNOTSUPP;\n+\t}\n+\n+\tif (!info-\u003eattrs[NL80211_ATTR_MAC] ||\n+\t    !info-\u003eattrs[NL80211_ATTR_NAN_NDP]) {\n+\t\tNL_SET_ERR_MSG(info-\u003eextack,\n+\t\t\t       \"NDP initiate requires peer NMI and NDP params\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\terr = nla_parse_nested(tb, NL80211_NAN_NDP_ATTR_MAX,\n+\t\t\t       info-\u003eattrs[NL80211_ATTR_NAN_NDP],\n+\t\t\t       nl80211_nan_ndp_policy,\n+\t\t\t       info-\u003eextack);\n+\tif (err)\n+\t\treturn err;\n+\n+\tif (!tb[NL80211_NAN_NDP_ATTR_INIT_NDI] ||\n+\t    !tb[NL80211_NAN_NDP_ATTR_PUBLISH_ID] ||\n+\t    !tb[NL80211_NAN_NDP_ATTR_SERVICE_ID]) {\n+\t\tNL_SET_ERR_MSG(info-\u003eextack,\n+\t\t\t       \"NDP initiate requires INIT_NDI, PUBLISH_ID and SERVICE_ID\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tparams.peer_nmi = nla_data(info-\u003eattrs[NL80211_ATTR_MAC]);\n+\tparams.init_ndi = nla_data(tb[NL80211_NAN_NDP_ATTR_INIT_NDI]);\n+\tparams.publish_id = nla_get_u8(tb[NL80211_NAN_NDP_ATTR_PUBLISH_ID]);\n+\tmemcpy(params.service_id,\n+\t       nla_data(tb[NL80211_NAN_NDP_ATTR_SERVICE_ID]),\n+\t       NL80211_NAN_FUNC_SERVICE_ID_LEN);\n+\n+\tif (tb[NL80211_NAN_NDP_ATTR_SSI]) {\n+\t\tparams.ssi = nla_data(tb[NL80211_NAN_NDP_ATTR_SSI]);\n+\t\tparams.ssi_len = nla_len(tb[NL80211_NAN_NDP_ATTR_SSI]);\n+\t}\n+\n+\tif (tb[NL80211_NAN_NDP_ATTR_CIPHER_SUITE])\n+\t\tparams.cipher_suite =\n+\t\t\tnla_get_u32(tb[NL80211_NAN_NDP_ATTR_CIPHER_SUITE]);\n+\n+\tif (tb[NL80211_NAN_NDP_ATTR_PMK]) {\n+\t\tif (!wiphy_ext_feature_isset(\u0026rdev-\u003ewiphy,\n+\t\t\t\t\t     NL80211_EXT_FEATURE_SECURE_NAN)) {\n+\t\t\tNL_SET_ERR_MSG_ATTR(info-\u003eextack,\n+\t\t\t\t\t    tb[NL80211_NAN_NDP_ATTR_PMK],\n+\t\t\t\t\t    \"PMK requires SECURE_NAN feature\");\n+\t\t\treturn -EOPNOTSUPP;\n+\t\t}\n+\t\tmemcpy(params.pmk,\n+\t\t       nla_data(tb[NL80211_NAN_NDP_ATTR_PMK]),\n+\t\t       NL80211_NAN_NDP_PMK_LEN);\n+\t\tparams.pmk_set = true;\n+\t}\n+\n+\tif (tb[NL80211_NAN_NDP_ATTR_PMKID]) {\n+\t\tif (!wiphy_ext_feature_isset(\u0026rdev-\u003ewiphy,\n+\t\t\t\t\t     NL80211_EXT_FEATURE_SECURE_NAN)) {\n+\t\t\tNL_SET_ERR_MSG_ATTR(info-\u003eextack,\n+\t\t\t\t\t    tb[NL80211_NAN_NDP_ATTR_PMKID],\n+\t\t\t\t\t    \"PMKID requires SECURE_NAN feature\");\n+\t\t\treturn -EOPNOTSUPP;\n+\t\t}\n+\t\tmemcpy(params.pmkid,\n+\t\t       nla_data(tb[NL80211_NAN_NDP_ATTR_PMKID]),\n+\t\t       NL80211_NAN_NDP_PMKID_LEN);\n+\t\tparams.pmkid_set = true;\n+\t}\n+\n+\tif (tb[NL80211_NAN_NDP_ATTR_GTK_REQUIRED]) {\n+\t\tif (!wiphy_ext_feature_isset(\u0026rdev-\u003ewiphy,\n+\t\t\t\t\t     NL80211_EXT_FEATURE_SECURE_NAN)) {\n+\t\t\tNL_SET_ERR_MSG_ATTR(info-\u003eextack,\n+\t\t\t\t\t    tb[NL80211_NAN_NDP_ATTR_GTK_REQUIRED],\n+\t\t\t\t\t    \"GTK_REQUIRED requires SECURE_NAN feature\");\n+\t\t\treturn -EOPNOTSUPP;\n+\t\t}\n+\n+\t\tif (!tb[NL80211_NAN_NDP_ATTR_GTK_CIPHER]) {\n+\t\t\tNL_SET_ERR_MSG_ATTR(info-\u003eextack,\n+\t\t\t\t\t    tb[NL80211_NAN_NDP_ATTR_GTK_REQUIRED],\n+\t\t\t\t\t    \"GTK_CIPHER is required when GTK_REQUIRED is set\");\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\n+\t\tparams.gtk_required = true;\n+\t\tparams.gtk_cipher =\n+\t\t\tnla_get_u32(tb[NL80211_NAN_NDP_ATTR_GTK_CIPHER]);\n+\t} else if (tb[NL80211_NAN_NDP_ATTR_GTK_CIPHER]) {\n+\t\tNL_SET_ERR_MSG_ATTR(info-\u003eextack,\n+\t\t\t\t    tb[NL80211_NAN_NDP_ATTR_GTK_CIPHER],\n+\t\t\t\t    \"GTK_CIPHER requires GTK_REQUIRED\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (tb[NL80211_NAN_NDP_ATTR_IPV6_INTF_ID]) {\n+\t\tmemcpy(params.ipv6_intf_id,\n+\t\t       nla_data(tb[NL80211_NAN_NDP_ATTR_IPV6_INTF_ID]),\n+\t\t       NL80211_NAN_NDP_IPV6_INTF_ID_LEN);\n+\t\tparams.ipv6_intf_id_set = true;\n+\t}\n+\n+\tparams.ndpe = nla_get_flag(tb[NL80211_NAN_NDP_ATTR_NDPE]);\n+\n+\treturn rdev_nan_ndp_initiate(rdev, wdev, \u0026params);\n+}\n+\n+static int nl80211_nan_ndp_respond(struct sk_buff *skb,\n+\t\t\t\t   struct genl_info *info)\n+{\n+\tstruct cfg80211_registered_device *rdev = info-\u003euser_ptr[0];\n+\tstruct wireless_dev *wdev = info-\u003euser_ptr[1];\n+\tstruct nlattr *tb[NL80211_NAN_NDP_ATTR_MAX + 1];\n+\tstruct cfg80211_nan_ndp_respond params = {};\n+\tint err;\n+\n+\tif (wdev-\u003eiftype != NL80211_IFTYPE_NAN) {\n+\t\tNL_SET_ERR_MSG(info-\u003eextack,\n+\t\t\t       \"NDP respond requires NAN interface\");\n+\t\treturn -EOPNOTSUPP;\n+\t}\n+\n+\tif (!(rdev-\u003ewiphy.nan_capa.flags \u0026 WIPHY_NAN_FLAGS_OFFLOAD_NDP)) {\n+\t\tNL_SET_ERR_MSG(info-\u003eextack,\n+\t\t\t       \"NAN NDP offload not supported by driver\");\n+\t\treturn -EOPNOTSUPP;\n+\t}\n+\n+\tif (!info-\u003eattrs[NL80211_ATTR_MAC] ||\n+\t    !info-\u003eattrs[NL80211_ATTR_NAN_NDP]) {\n+\t\tNL_SET_ERR_MSG(info-\u003eextack,\n+\t\t\t       \"NDP respond requires peer NMI and NDP params\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\terr = nla_parse_nested(tb, NL80211_NAN_NDP_ATTR_MAX,\n+\t\t\t       info-\u003eattrs[NL80211_ATTR_NAN_NDP],\n+\t\t\t       nl80211_nan_ndp_policy,\n+\t\t\t       info-\u003eextack);\n+\tif (err)\n+\t\treturn err;\n+\n+\tif (!tb[NL80211_NAN_NDP_ATTR_ID] ||\n+\t    !tb[NL80211_NAN_NDP_ATTR_INIT_NDI]) {\n+\t\tNL_SET_ERR_MSG(info-\u003eextack,\n+\t\t\t       \"NDP respond requires NDP ID and INIT_NDI\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tparams.peer_nmi = nla_data(info-\u003eattrs[NL80211_ATTR_MAC]);\n+\tparams.ndp_id = nla_get_u8(tb[NL80211_NAN_NDP_ATTR_ID]);\n+\tparams.init_ndi = nla_data(tb[NL80211_NAN_NDP_ATTR_INIT_NDI]);\n+\tparams.accept = nla_get_flag(tb[NL80211_NAN_NDP_ATTR_ACCEPT]);\n+\n+\tif (params.accept) {\n+\t\tif (!tb[NL80211_NAN_NDP_ATTR_RESP_NDI]) {\n+\t\t\tNL_SET_ERR_MSG(info-\u003eextack,\n+\t\t\t\t       \"NDP accept requires RESP_NDI\");\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t\tparams.resp_ndi = nla_data(tb[NL80211_NAN_NDP_ATTR_RESP_NDI]);\n+\t} else {\n+\t\tif (tb[NL80211_NAN_NDP_ATTR_REASON])\n+\t\t\tparams.reason =\n+\t\t\t\tnla_get_u8(tb[NL80211_NAN_NDP_ATTR_REASON]);\n+\t}\n+\n+\tif (tb[NL80211_NAN_NDP_ATTR_SSI]) {\n+\t\tparams.ssi = nla_data(tb[NL80211_NAN_NDP_ATTR_SSI]);\n+\t\tparams.ssi_len = nla_len(tb[NL80211_NAN_NDP_ATTR_SSI]);\n+\t}\n+\n+\tif (tb[NL80211_NAN_NDP_ATTR_CIPHER_SUITE])\n+\t\tparams.cipher_suite =\n+\t\t\tnla_get_u32(tb[NL80211_NAN_NDP_ATTR_CIPHER_SUITE]);\n+\n+\tif (params.accept \u0026\u0026 tb[NL80211_NAN_NDP_ATTR_PMK]) {\n+\t\tif (!wiphy_ext_feature_isset(\u0026rdev-\u003ewiphy,\n+\t\t\t\t\t     NL80211_EXT_FEATURE_SECURE_NAN)) {\n+\t\t\tNL_SET_ERR_MSG_ATTR(info-\u003eextack,\n+\t\t\t\t\t    tb[NL80211_NAN_NDP_ATTR_PMK],\n+\t\t\t\t\t    \"PMK requires SECURE_NAN feature\");\n+\t\t\treturn -EOPNOTSUPP;\n+\t\t}\n+\t\tmemcpy(params.pmk,\n+\t\t       nla_data(tb[NL80211_NAN_NDP_ATTR_PMK]),\n+\t\t       NL80211_NAN_NDP_PMK_LEN);\n+\t\tparams.pmk_set = true;\n+\t}\n+\n+\tif (params.accept \u0026\u0026 tb[NL80211_NAN_NDP_ATTR_GTK_REQUIRED]) {\n+\t\tif (!wiphy_ext_feature_isset(\u0026rdev-\u003ewiphy,\n+\t\t\t\t\t     NL80211_EXT_FEATURE_SECURE_NAN)) {\n+\t\t\tNL_SET_ERR_MSG_ATTR(info-\u003eextack,\n+\t\t\t\t\t    tb[NL80211_NAN_NDP_ATTR_GTK_REQUIRED],\n+\t\t\t\t\t    \"GTK_REQUIRED requires SECURE_NAN feature\");\n+\t\t\treturn -EOPNOTSUPP;\n+\t\t}\n+\n+\t\tif (!tb[NL80211_NAN_NDP_ATTR_GTK_CIPHER]) {\n+\t\t\tNL_SET_ERR_MSG_ATTR(info-\u003eextack,\n+\t\t\t\t\t    tb[NL80211_NAN_NDP_ATTR_GTK_REQUIRED],\n+\t\t\t\t\t    \"GTK_CIPHER is required when GTK_REQUIRED is set\");\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\n+\t\tparams.gtk_required = true;\n+\t\tparams.gtk_cipher =\n+\t\t\tnla_get_u32(tb[NL80211_NAN_NDP_ATTR_GTK_CIPHER]);\n+\t} else if (params.accept \u0026\u0026 tb[NL80211_NAN_NDP_ATTR_GTK_CIPHER]) {\n+\t\tNL_SET_ERR_MSG_ATTR(info-\u003eextack,\n+\t\t\t\t    tb[NL80211_NAN_NDP_ATTR_GTK_CIPHER],\n+\t\t\t\t    \"GTK_CIPHER requires GTK_REQUIRED\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (tb[NL80211_NAN_NDP_ATTR_IPV6_INTF_ID]) {\n+\t\tmemcpy(params.ipv6_intf_id,\n+\t\t       nla_data(tb[NL80211_NAN_NDP_ATTR_IPV6_INTF_ID]),\n+\t\t       NL80211_NAN_NDP_IPV6_INTF_ID_LEN);\n+\t\tparams.ipv6_intf_id_set = true;\n+\t}\n+\n+\tparams.ndpe = nla_get_flag(tb[NL80211_NAN_NDP_ATTR_NDPE]);\n+\n+\treturn rdev_nan_ndp_respond(rdev, wdev, \u0026params);\n+}\n+\n+static int nl80211_nan_ndp_terminate(struct sk_buff *skb,\n+\t\t\t\t     struct genl_info *info)\n+{\n+\tstruct cfg80211_registered_device *rdev = info-\u003euser_ptr[0];\n+\tstruct wireless_dev *wdev = info-\u003euser_ptr[1];\n+\tstruct nlattr *tb[NL80211_NAN_NDP_ATTR_MAX + 1];\n+\tstruct cfg80211_nan_ndp_terminate params = {};\n+\tint err;\n+\n+\tif (wdev-\u003eiftype != NL80211_IFTYPE_NAN) {\n+\t\tNL_SET_ERR_MSG(info-\u003eextack,\n+\t\t\t       \"NDP terminate requires NAN interface\");\n+\t\treturn -EOPNOTSUPP;\n+\t}\n+\n+\tif (!(rdev-\u003ewiphy.nan_capa.flags \u0026 WIPHY_NAN_FLAGS_OFFLOAD_NDP)) {\n+\t\tNL_SET_ERR_MSG(info-\u003eextack,\n+\t\t\t       \"NAN NDP offload not supported by driver\");\n+\t\treturn -EOPNOTSUPP;\n+\t}\n+\n+\tif (!info-\u003eattrs[NL80211_ATTR_MAC] ||\n+\t    !info-\u003eattrs[NL80211_ATTR_NAN_NDP]) {\n+\t\tNL_SET_ERR_MSG(info-\u003eextack,\n+\t\t\t       \"NDP terminate requires peer NMI and NDP params\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\terr = nla_parse_nested(tb, NL80211_NAN_NDP_ATTR_MAX,\n+\t\t\t       info-\u003eattrs[NL80211_ATTR_NAN_NDP],\n+\t\t\t       nl80211_nan_ndp_policy,\n+\t\t\t       info-\u003eextack);\n+\tif (err)\n+\t\treturn err;\n+\n+\tif (!tb[NL80211_NAN_NDP_ATTR_ID] ||\n+\t    !tb[NL80211_NAN_NDP_ATTR_INIT_NDI]) {\n+\t\tNL_SET_ERR_MSG(info-\u003eextack,\n+\t\t\t       \"NDP terminate requires NDP ID and INIT_NDI\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tparams.peer_nmi = nla_data(info-\u003eattrs[NL80211_ATTR_MAC]);\n+\tparams.ndp_id = nla_get_u8(tb[NL80211_NAN_NDP_ATTR_ID]);\n+\tparams.init_ndi = nla_data(tb[NL80211_NAN_NDP_ATTR_INIT_NDI]);\n+\n+\tif (tb[NL80211_NAN_NDP_ATTR_REASON])\n+\t\tparams.reason = nla_get_u8(tb[NL80211_NAN_NDP_ATTR_REASON]);\n+\n+\treturn rdev_nan_ndp_terminate(rdev, wdev, \u0026params);\n+}\n+\n+void cfg80211_nan_ndp_request(struct wireless_dev *wdev,\n+\t\t\t      struct cfg80211_nan_ndp_request_params *params,\n+\t\t\t      gfp_t gfp)\n+{\n+\tstruct wiphy *wiphy = wdev-\u003ewiphy;\n+\tstruct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);\n+\tstruct nlattr *ndp_attr;\n+\tstruct sk_buff *msg;\n+\tvoid *hdr;\n+\n+\tif (WARN_ON(!(wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_OFFLOAD_NDP)))\n+\t\treturn;\n+\n+\tif (!wdev-\u003eowner_nlportid)\n+\t\treturn;\n+\n+\tmsg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);\n+\tif (!msg)\n+\t\treturn;\n+\n+\thdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_NAN_NDP_REQUEST);\n+\tif (!hdr)\n+\t\tgoto nla_put_failure;\n+\n+\tif (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev-\u003ewiphy_idx) ||\n+\t    nla_put_u64_64bit(msg, NL80211_ATTR_WDEV, wdev_id(wdev),\n+\t\t\t      NL80211_ATTR_PAD) ||\n+\t    nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, params-\u003epeer_nmi))\n+\t\tgoto nla_put_failure;\n+\n+\tndp_attr = nla_nest_start(msg, NL80211_ATTR_NAN_NDP);\n+\tif (!ndp_attr)\n+\t\tgoto nla_put_failure;\n+\n+\tif (nla_put_u8(msg, NL80211_NAN_NDP_ATTR_ID, params-\u003endp_id) ||\n+\t    nla_put(msg, NL80211_NAN_NDP_ATTR_INIT_NDI, ETH_ALEN,\n+\t\t    params-\u003einit_ndi) ||\n+\t    nla_put_u8(msg, NL80211_NAN_NDP_ATTR_PUBLISH_ID,\n+\t\t       params-\u003epublish_id))\n+\t\tgoto nla_put_failure;\n+\n+\tif (params-\u003essi \u0026\u0026 params-\u003essi_len \u0026\u0026\n+\t    nla_put(msg, NL80211_NAN_NDP_ATTR_SSI, params-\u003essi_len,\n+\t\t    params-\u003essi))\n+\t\tgoto nla_put_failure;\n+\n+\tif (params-\u003ecipher_suite \u0026\u0026\n+\t    nla_put_u32(msg, NL80211_NAN_NDP_ATTR_CIPHER_SUITE,\n+\t\t\tparams-\u003ecipher_suite))\n+\t\tgoto nla_put_failure;\n+\n+\tif (params-\u003epmkid_set \u0026\u0026\n+\t    nla_put(msg, NL80211_NAN_NDP_ATTR_PMKID,\n+\t\t    NL80211_NAN_NDP_PMKID_LEN, params-\u003epmkid))\n+\t\tgoto nla_put_failure;\n+\n+\tif (params-\u003egtk_required \u0026\u0026\n+\t    nla_put_flag(msg, NL80211_NAN_NDP_ATTR_GTK_REQUIRED))\n+\t\tgoto nla_put_failure;\n+\n+\tif (params-\u003eipv6_intf_id_set \u0026\u0026\n+\t    nla_put(msg, NL80211_NAN_NDP_ATTR_IPV6_INTF_ID,\n+\t\t    NL80211_NAN_NDP_IPV6_INTF_ID_LEN, params-\u003eipv6_intf_id))\n+\t\tgoto nla_put_failure;\n+\n+\tif (params-\u003endpe \u0026\u0026\n+\t    nla_put_flag(msg, NL80211_NAN_NDP_ATTR_NDPE))\n+\t\tgoto nla_put_failure;\n+\n+\tnla_nest_end(msg, ndp_attr);\n+\tgenlmsg_end(msg, hdr);\n+\tgenlmsg_unicast(wiphy_net(wiphy), msg, wdev-\u003eowner_nlportid);\n+\treturn;\n+\n+nla_put_failure:\n+\tnlmsg_free(msg);\n+}\n+EXPORT_SYMBOL(cfg80211_nan_ndp_request);\n+\n+void cfg80211_nan_ndp_confirm(struct wireless_dev *wdev,\n+\t\t\t      struct cfg80211_nan_ndp_confirm_params *params,\n+\t\t\t      gfp_t gfp)\n+{\n+\tstruct wiphy *wiphy = wdev-\u003ewiphy;\n+\tstruct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);\n+\tstruct nlattr *ndp_attr;\n+\tstruct sk_buff *msg;\n+\tvoid *hdr;\n+\n+\tif (WARN_ON(!(wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_OFFLOAD_NDP)))\n+\t\treturn;\n+\n+\tif (!wdev-\u003eowner_nlportid)\n+\t\treturn;\n+\n+\tif (WARN_ON_ONCE(params-\u003eaccepted \u0026\u0026 !params-\u003eresp_ndi))\n+\t\treturn;\n+\n+\tmsg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);\n+\tif (!msg)\n+\t\treturn;\n+\n+\thdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_NAN_NDP_CONFIRM);\n+\tif (!hdr)\n+\t\tgoto nla_put_failure;\n+\n+\tif (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev-\u003ewiphy_idx) ||\n+\t    nla_put_u64_64bit(msg, NL80211_ATTR_WDEV, wdev_id(wdev),\n+\t\t\t      NL80211_ATTR_PAD) ||\n+\t    nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, params-\u003epeer_nmi))\n+\t\tgoto nla_put_failure;\n+\n+\tndp_attr = nla_nest_start(msg, NL80211_ATTR_NAN_NDP);\n+\tif (!ndp_attr)\n+\t\tgoto nla_put_failure;\n+\n+\tif (nla_put_u8(msg, NL80211_NAN_NDP_ATTR_ID, params-\u003endp_id) ||\n+\t    nla_put(msg, NL80211_NAN_NDP_ATTR_INIT_NDI, ETH_ALEN,\n+\t\t    params-\u003einit_ndi) ||\n+\t    nla_put_u8(msg, NL80211_NAN_NDP_ATTR_STATUS,\n+\t\t       params-\u003eaccepted ? NL80211_NAN_NDP_STATUS_ACCEPTED :\n+\t\t\t\t\t   NL80211_NAN_NDP_STATUS_REJECTED))\n+\t\tgoto nla_put_failure;\n+\n+\tif (params-\u003eaccepted \u0026\u0026 params-\u003eresp_ndi \u0026\u0026\n+\t    nla_put(msg, NL80211_NAN_NDP_ATTR_RESP_NDI, ETH_ALEN,\n+\t\t    params-\u003eresp_ndi))\n+\t\tgoto nla_put_failure;\n+\n+\tif (!params-\u003eaccepted \u0026\u0026\n+\t    nla_put_u8(msg, NL80211_NAN_NDP_ATTR_REASON, params-\u003ereason))\n+\t\tgoto nla_put_failure;\n+\n+\tif (params-\u003essi \u0026\u0026 params-\u003essi_len \u0026\u0026\n+\t    nla_put(msg, NL80211_NAN_NDP_ATTR_SSI, params-\u003essi_len,\n+\t\t    params-\u003essi))\n+\t\tgoto nla_put_failure;\n+\n+\tif (params-\u003eipv6_intf_id_set \u0026\u0026\n+\t    nla_put(msg, NL80211_NAN_NDP_ATTR_IPV6_INTF_ID,\n+\t\t    NL80211_NAN_NDP_IPV6_INTF_ID_LEN, params-\u003eipv6_intf_id))\n+\t\tgoto nla_put_failure;\n+\n+\tnla_nest_end(msg, ndp_attr);\n+\tgenlmsg_end(msg, hdr);\n+\tgenlmsg_unicast(wiphy_net(wiphy), msg, wdev-\u003eowner_nlportid);\n+\treturn;\n+\n+nla_put_failure:\n+\tnlmsg_free(msg);\n+}\n+EXPORT_SYMBOL(cfg80211_nan_ndp_confirm);\n+\n+void cfg80211_nan_ndp_terminated(struct wireless_dev *wdev,\n+\t\t\t\t struct cfg80211_nan_ndp_terminated_params *params,\n+\t\t\t\t gfp_t gfp)\n+{\n+\tstruct wiphy *wiphy = wdev-\u003ewiphy;\n+\tstruct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);\n+\tstruct nlattr *ndp_attr;\n+\tstruct sk_buff *msg;\n+\tvoid *hdr;\n+\n+\tif (WARN_ON(!(wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_OFFLOAD_NDP)))\n+\t\treturn;\n+\n+\tif (!wdev-\u003eowner_nlportid)\n+\t\treturn;\n+\n+\tmsg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);\n+\tif (!msg)\n+\t\treturn;\n+\n+\thdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_NAN_NDP_TERMINATED);\n+\tif (!hdr)\n+\t\tgoto nla_put_failure;\n+\n+\tif (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev-\u003ewiphy_idx) ||\n+\t    nla_put_u64_64bit(msg, NL80211_ATTR_WDEV, wdev_id(wdev),\n+\t\t\t      NL80211_ATTR_PAD) ||\n+\t    nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, params-\u003epeer_nmi))\n+\t\tgoto nla_put_failure;\n+\n+\tndp_attr = nla_nest_start(msg, NL80211_ATTR_NAN_NDP);\n+\tif (!ndp_attr)\n+\t\tgoto nla_put_failure;\n+\n+\tif (nla_put_u8(msg, NL80211_NAN_NDP_ATTR_ID, params-\u003endp_id) ||\n+\t    nla_put(msg, NL80211_NAN_NDP_ATTR_INIT_NDI, ETH_ALEN,\n+\t\t    params-\u003einit_ndi) ||\n+\t    nla_put_u8(msg, NL80211_NAN_NDP_ATTR_REASON, params-\u003ereason))\n+\t\tgoto nla_put_failure;\n+\n+\tnla_nest_end(msg, ndp_attr);\n+\tgenlmsg_end(msg, hdr);\n+\tgenlmsg_unicast(wiphy_net(wiphy), msg, wdev-\u003eowner_nlportid);\n+\treturn;\n+\n+nla_put_failure:\n+\tnlmsg_free(msg);\n+}\n+EXPORT_SYMBOL(cfg80211_nan_ndp_terminated);\n+\n static bool nl80211_nan_is_sched_empty(struct cfg80211_nan_local_sched *sched)\n {\n \tif (!sched-\u003en_channels)\n@@ -21350,6 +22154,24 @@ static const struct genl_small_ops nl80211_small_ops[] = {\n \t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_NETDEV_UP |\n \t\t\t\t\t NL80211_FLAG_NO_WIPHY_MTX),\n \t},\n+\t{\n+\t\t.cmd = NL80211_CMD_NAN_NDP_INITIATE,\n+\t\t.doit = nl80211_nan_ndp_initiate,\n+\t\t.flags = GENL_ADMIN_PERM,\n+\t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),\n+\t},\n+\t{\n+\t\t.cmd = NL80211_CMD_NAN_NDP_RESPOND,\n+\t\t.doit = nl80211_nan_ndp_respond,\n+\t\t.flags = GENL_ADMIN_PERM,\n+\t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),\n+\t},\n+\t{\n+\t\t.cmd = NL80211_CMD_NAN_NDP_TERMINATE,\n+\t\t.doit = nl80211_nan_ndp_terminate,\n+\t\t.flags = GENL_ADMIN_PERM,\n+\t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),\n+\t},\n };\n \n static struct genl_family nl80211_fam __ro_after_init = {\ndiff --git a/net/wireless/nl80211.h b/net/wireless/nl80211.h\nindex bdb065d140549..31a2c2eb62761 100644\n--- a/net/wireless/nl80211.h\n+++ b/net/wireless/nl80211.h\n@@ -126,6 +126,9 @@ void cfg80211_free_coalesce(struct cfg80211_coalesce *coalesce);\n /* peer measurement */\n int nl80211_pmsr_start(struct sk_buff *skb, struct genl_info *info);\n \n+extern const struct nla_policy\n+nl80211_pmsr_ftm_req_attr_policy[NL80211_PMSR_FTM_REQ_ATTR_MAX + 1];\n+\n void nl80211_mlo_reconf_add_done(struct net_device *dev,\n \t\t\t\t struct cfg80211_mlo_reconf_done_data *data);\n \ndiff --git a/net/wireless/pmsr.c b/net/wireless/pmsr.c\nindex 97449bcb9a225..bcf5390174e47 100644\n--- a/net/wireless/pmsr.c\n+++ b/net/wireless/pmsr.c\n@@ -306,11 +306,108 @@ static int pmsr_parse_ftm(struct cfg80211_registered_device *rdev,\n \treturn 0;\n }\n \n+static int pmsr_parse_ftm_nan(struct cfg80211_registered_device *rdev,\n+\t\t\t      struct nlattr *ftmreq,\n+\t\t\t      struct cfg80211_pmsr_request_peer *out,\n+\t\t\t      struct genl_info *info)\n+{\n+\tconst struct cfg80211_pmsr_capabilities *capa = rdev-\u003ewiphy.pmsr_capa;\n+\tstruct nlattr *tb[NL80211_PMSR_FTM_REQ_ATTR_MAX + 1];\n+\tint err;\n+\n+\terr = nla_parse_nested(tb, NL80211_PMSR_FTM_REQ_ATTR_MAX, ftmreq,\n+\t\t\t       nl80211_pmsr_ftm_req_attr_policy,\n+\t\t\t       info-\u003eextack);\n+\tif (err)\n+\t\treturn err;\n+\n+\tout-\u003eftm.requested = true;\n+\n+\t/* NAN ranging requires ASAP; reject if not set by userspace */\n+\tout-\u003eftm.asap = nla_get_flag(tb[NL80211_PMSR_FTM_REQ_ATTR_ASAP]);\n+\tif (!out-\u003eftm.asap) {\n+\t\tNL_SET_ERR_MSG(info-\u003eextack,\n+\t\t\t       \"FTM: NAN ranging requires ASAP mode\");\n+\t\treturn -EINVAL;\n+\t}\n+\tif (!capa-\u003eftm.asap) {\n+\t\tNL_SET_ERR_MSG(info-\u003eextack,\n+\t\t\t       \"FTM: NAN ASAP mode is not supported by device\");\n+\t\treturn -EOPNOTSUPP;\n+\t}\n+\n+\t/* NAN ranging requires single burst (num_bursts_exp must be 0) */\n+\tif (!tb[NL80211_PMSR_FTM_REQ_ATTR_NUM_BURSTS_EXP] ||\n+\t    nla_get_u8(tb[NL80211_PMSR_FTM_REQ_ATTR_NUM_BURSTS_EXP]) != 0) {\n+\t\tNL_SET_ERR_MSG(info-\u003eextack,\n+\t\t\t       \"FTM: NAN ranging requires single burst\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tout-\u003eftm.rsta = !!tb[NL80211_PMSR_FTM_REQ_ATTR_RSTA];\n+\tout-\u003eftm.range_report =\n+\t\t!!tb[NL80211_PMSR_FTM_REQ_ATTR_RANGE_REPORT];\n+\tif (out-\u003eftm.range_report \u0026\u0026 !out-\u003eftm.rsta) {\n+\t\tNL_SET_ERR_MSG_ATTR(info-\u003eextack,\n+\t\t\t\t    tb[NL80211_PMSR_FTM_REQ_ATTR_RANGE_REPORT],\n+\t\t\t\t    \"FTM: range report is valid only for NAN RSTA\");\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (tb[NL80211_PMSR_FTM_REQ_ATTR_PREAMBLE]) {\n+\t\tout-\u003eftm.preamble =\n+\t\t\tnla_get_u32(tb[NL80211_PMSR_FTM_REQ_ATTR_PREAMBLE]);\n+\t\tif (!(capa-\u003eftm.preambles \u0026 BIT(out-\u003eftm.preamble))) {\n+\t\t\tNL_SET_ERR_MSG_ATTR(info-\u003eextack,\n+\t\t\t\t\t    tb[NL80211_PMSR_FTM_REQ_ATTR_PREAMBLE],\n+\t\t\t\t\t    \"FTM: unsupported preamble for NAN ranging\");\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t}\n+\n+\tif (tb[NL80211_PMSR_FTM_REQ_ATTR_FTMS_PER_BURST]) {\n+\t\tout-\u003eftm.ftms_per_burst =\n+\t\t\tnla_get_u8(tb[NL80211_PMSR_FTM_REQ_ATTR_FTMS_PER_BURST]);\n+\t\tif (out-\u003eftm.ftms_per_burst \u003e 31) {\n+\t\t\tNL_SET_ERR_MSG_ATTR(info-\u003eextack,\n+\t\t\t\t\t    tb[NL80211_PMSR_FTM_REQ_ATTR_FTMS_PER_BURST],\n+\t\t\t\t\t    \"FTM: NAN FTMs per burst exceeds limit of 31\");\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t\tif (capa-\u003eftm.max_ftms_per_burst \u0026\u0026\n+\t\t    out-\u003eftm.ftms_per_burst \u003e capa-\u003eftm.max_ftms_per_burst) {\n+\t\t\tNL_SET_ERR_MSG_ATTR(info-\u003eextack,\n+\t\t\t\t\t    tb[NL80211_PMSR_FTM_REQ_ATTR_FTMS_PER_BURST],\n+\t\t\t\t\t    \"FTM: FTMs per burst exceeds device limit\");\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t}\n+\n+\tif (tb[NL80211_PMSR_FTM_REQ_ATTR_BURST_DURATION])\n+\t\tout-\u003eftm.burst_duration =\n+\t\t\tnla_get_u8(tb[NL80211_PMSR_FTM_REQ_ATTR_BURST_DURATION]);\n+\n+\tif (tb[NL80211_PMSR_FTM_REQ_ATTR_MIN_DELTA_FTM])\n+\t\tout-\u003eftm.min_delta_ftm =\n+\t\t\tnla_get_u8(tb[NL80211_PMSR_FTM_REQ_ATTR_MIN_DELTA_FTM]);\n+\n+\tif (tb[NL80211_PMSR_FTM_REQ_ATTR_INGRESS])\n+\t\tout-\u003eftm.ingress_distance =\n+\t\t\tnla_get_u64(tb[NL80211_PMSR_FTM_REQ_ATTR_INGRESS]);\n+\n+\tif (tb[NL80211_PMSR_FTM_REQ_ATTR_EGRESS])\n+\t\tout-\u003eftm.egress_distance =\n+\t\t\tnla_get_u64(tb[NL80211_PMSR_FTM_REQ_ATTR_EGRESS]);\n+\n+\treturn 0;\n+}\n+\n static int pmsr_parse_peer(struct cfg80211_registered_device *rdev,\n \t\t\t   struct nlattr *peer,\n \t\t\t   struct cfg80211_pmsr_request_peer *out,\n \t\t\t   struct genl_info *info)\n {\n+\tstruct wireless_dev *wdev = info-\u003euser_ptr[1];\n \tstruct nlattr *tb[NL80211_PMSR_PEER_ATTR_MAX + 1];\n \tstruct nlattr *req[NL80211_PMSR_REQ_ATTR_MAX + 1];\n \tbool have_measurement_type = false;\n@@ -344,6 +441,22 @@ static int pmsr_parse_peer(struct cfg80211_registered_device *rdev,\n \t\t\t\t    \"FTM: PD request type not supported by device\");\n \t\treturn -EINVAL;\n \t}\n+\n+\tif (out-\u003eftm.request_type == NL80211_PMSR_FTM_REQ_TYPE_NAN) {\n+\t\tif (!rdev-\u003ewiphy.pmsr_capa-\u003eftm.type.nan_support) {\n+\t\t\tNL_SET_ERR_MSG_ATTR(info-\u003eextack,\n+\t\t\t\t\t    tb[NL80211_PMSR_PEER_ATTR_REQ_TYPE],\n+\t\t\t\t\t    \"FTM: NAN ranging not supported by device\");\n+\t\t\treturn -EOPNOTSUPP;\n+\t\t}\n+\t\tif (wdev-\u003eiftype != NL80211_IFTYPE_NAN) {\n+\t\t\tNL_SET_ERR_MSG_ATTR(info-\u003eextack,\n+\t\t\t\t\t    tb[NL80211_PMSR_PEER_ATTR_REQ_TYPE],\n+\t\t\t\t\t    \"FTM: NAN ranging requires a NAN interface\");\n+\t\t\treturn -EOPNOTSUPP;\n+\t\t}\n+\t}\n+\n \t/* reuse info-\u003eattrs */\n \tmemset(info-\u003eattrs, 0, sizeof(*info-\u003eattrs) * (NL80211_ATTR_MAX + 1));\n \terr = nla_parse_nested_deprecated(info-\u003eattrs, NL80211_ATTR_MAX,\n@@ -390,7 +503,12 @@ static int pmsr_parse_peer(struct cfg80211_registered_device *rdev,\n \n \t\tswitch (nla_type(treq)) {\n \t\tcase NL80211_PMSR_TYPE_FTM:\n-\t\t\terr = pmsr_parse_ftm(rdev, treq, out, info);\n+\t\t\tif (out-\u003eftm.request_type ==\n+\t\t\t    NL80211_PMSR_FTM_REQ_TYPE_NAN)\n+\t\t\t\terr = pmsr_parse_ftm_nan(rdev, treq,\n+\t\t\t\t\t\t\t out, info);\n+\t\t\telse\n+\t\t\t\terr = pmsr_parse_ftm(rdev, treq, out, info);\n \t\t\tbreak;\n \t\tdefault:\n \t\t\tNL_SET_ERR_MSG_ATTR(info-\u003eextack, treq,\ndiff --git a/net/wireless/rdev-ops.h b/net/wireless/rdev-ops.h\nindex ae15cec9bf8b7..e4b57983d5913 100644\n--- a/net/wireless/rdev-ops.h\n+++ b/net/wireless/rdev-ops.h\n@@ -1183,6 +1183,54 @@ static inline void rdev_stop_pd(struct cfg80211_registered_device *rdev,\n \ttrace_rdev_return_void(\u0026rdev-\u003ewiphy);\n }\n \n+static inline int\n+rdev_nan_ndp_initiate(struct cfg80211_registered_device *rdev,\n+\t\t      struct wireless_dev *wdev,\n+\t\t      struct cfg80211_nan_ndp_initiate *params)\n+{\n+\tint ret;\n+\n+\tif (!rdev-\u003eops-\u003enan_ndp_initiate)\n+\t\treturn -EOPNOTSUPP;\n+\n+\ttrace_rdev_nan_ndp_initiate(\u0026rdev-\u003ewiphy, wdev, params);\n+\tret = rdev-\u003eops-\u003enan_ndp_initiate(\u0026rdev-\u003ewiphy, wdev, params);\n+\ttrace_rdev_return_int(\u0026rdev-\u003ewiphy, ret);\n+\treturn ret;\n+}\n+\n+static inline int\n+rdev_nan_ndp_respond(struct cfg80211_registered_device *rdev,\n+\t\t     struct wireless_dev *wdev,\n+\t\t     struct cfg80211_nan_ndp_respond *params)\n+{\n+\tint ret;\n+\n+\tif (!rdev-\u003eops-\u003enan_ndp_respond)\n+\t\treturn -EOPNOTSUPP;\n+\n+\ttrace_rdev_nan_ndp_respond(\u0026rdev-\u003ewiphy, wdev, params);\n+\tret = rdev-\u003eops-\u003enan_ndp_respond(\u0026rdev-\u003ewiphy, wdev, params);\n+\ttrace_rdev_return_int(\u0026rdev-\u003ewiphy, ret);\n+\treturn ret;\n+}\n+\n+static inline int\n+rdev_nan_ndp_terminate(struct cfg80211_registered_device *rdev,\n+\t\t       struct wireless_dev *wdev,\n+\t\t       struct cfg80211_nan_ndp_terminate *params)\n+{\n+\tint ret;\n+\n+\tif (!rdev-\u003eops-\u003enan_ndp_terminate)\n+\t\treturn -EOPNOTSUPP;\n+\n+\ttrace_rdev_nan_ndp_terminate(\u0026rdev-\u003ewiphy, wdev, params);\n+\tret = rdev-\u003eops-\u003enan_ndp_terminate(\u0026rdev-\u003ewiphy, wdev, params);\n+\ttrace_rdev_return_int(\u0026rdev-\u003ewiphy, ret);\n+\treturn ret;\n+}\n+\n static inline int rdev_set_mac_acl(struct cfg80211_registered_device *rdev,\n \t\t\t\t   struct net_device *dev,\n \t\t\t\t   struct cfg80211_acl_data *params)\ndiff --git a/net/wireless/trace.h b/net/wireless/trace.h\nindex 31000ffebe436..fbe3eb69cd147 100644\n--- a/net/wireless/trace.h\n+++ b/net/wireless/trace.h\n@@ -2552,6 +2552,76 @@ TRACE_EVENT(rdev_nan_set_non_evac_channels,\n \t\t\t\t__entry-\u003en_channels, sizeof(u32)))\n );\n \n+TRACE_EVENT(rdev_nan_ndp_initiate,\n+\tTP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,\n+\t\t struct cfg80211_nan_ndp_initiate *params),\n+\tTP_ARGS(wiphy, wdev, params),\n+\tTP_STRUCT__entry(\n+\t\tWIPHY_ENTRY\n+\t\tWDEV_ENTRY\n+\t\t__array(u8, peer_nmi, ETH_ALEN)\n+\t\t__field(u8, publish_id)\n+\t),\n+\tTP_fast_assign(\n+\t\tWIPHY_ASSIGN;\n+\t\tWDEV_ASSIGN;\n+\t\tmemcpy(__entry-\u003epeer_nmi, params-\u003epeer_nmi, ETH_ALEN);\n+\t\t__entry-\u003epublish_id = params-\u003epublish_id;\n+\t),\n+\tTP_printk(WIPHY_PR_FMT \", \" WDEV_PR_FMT\n+\t\t  \", peer: %pM, publish_id: %u\",\n+\t\t  WIPHY_PR_ARG, WDEV_PR_ARG,\n+\t\t  __entry-\u003epeer_nmi, __entry-\u003epublish_id)\n+);\n+\n+TRACE_EVENT(rdev_nan_ndp_respond,\n+\tTP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,\n+\t\t struct cfg80211_nan_ndp_respond *params),\n+\tTP_ARGS(wiphy, wdev, params),\n+\tTP_STRUCT__entry(\n+\t\tWIPHY_ENTRY\n+\t\tWDEV_ENTRY\n+\t\t__array(u8, peer_nmi, ETH_ALEN)\n+\t\t__field(u8, ndp_id)\n+\t\t__field(bool, accept)\n+\t),\n+\tTP_fast_assign(\n+\t\tWIPHY_ASSIGN;\n+\t\tWDEV_ASSIGN;\n+\t\tmemcpy(__entry-\u003epeer_nmi, params-\u003epeer_nmi, ETH_ALEN);\n+\t\t__entry-\u003endp_id = params-\u003endp_id;\n+\t\t__entry-\u003eaccept = params-\u003eaccept;\n+\t),\n+\tTP_printk(WIPHY_PR_FMT \", \" WDEV_PR_FMT\n+\t\t  \", peer: %pM, ndp_id: %u, accept: %d\",\n+\t\t  WIPHY_PR_ARG, WDEV_PR_ARG,\n+\t\t  __entry-\u003epeer_nmi, __entry-\u003endp_id, __entry-\u003eaccept)\n+);\n+\n+TRACE_EVENT(rdev_nan_ndp_terminate,\n+\tTP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,\n+\t\t struct cfg80211_nan_ndp_terminate *params),\n+\tTP_ARGS(wiphy, wdev, params),\n+\tTP_STRUCT__entry(\n+\t\tWIPHY_ENTRY\n+\t\tWDEV_ENTRY\n+\t\t__array(u8, peer_nmi, ETH_ALEN)\n+\t\t__field(u8, ndp_id)\n+\t\t__field(u8, reason)\n+\t),\n+\tTP_fast_assign(\n+\t\tWIPHY_ASSIGN;\n+\t\tWDEV_ASSIGN;\n+\t\tmemcpy(__entry-\u003epeer_nmi, params-\u003epeer_nmi, ETH_ALEN);\n+\t\t__entry-\u003endp_id = params-\u003endp_id;\n+\t\t__entry-\u003ereason = params-\u003ereason;\n+\t),\n+\tTP_printk(WIPHY_PR_FMT \", \" WDEV_PR_FMT\n+\t\t  \", peer: %pM, ndp_id: %u, reason: %u\",\n+\t\t  WIPHY_PR_ARG, WDEV_PR_ARG,\n+\t\t  __entry-\u003epeer_nmi, __entry-\u003endp_id, __entry-\u003ereason)\n+);\n+\n TRACE_EVENT(rdev_set_mac_acl,\n \tTP_PROTO(struct wiphy *wiphy, struct net_device *netdev,\n \t\t struct cfg80211_acl_data *params),\ndiff --git a/net/wireless/util.c b/net/wireless/util.c\nindex 9d5456defc90b..38fd97e8fac71 100644\n--- a/net/wireless/util.c\n+++ b/net/wireless/util.c\n@@ -2820,6 +2820,7 @@ void cfg80211_free_nan_func(struct cfg80211_nan_func *f)\n \tkfree(f-\u003eserv_spec_info);\n \tkfree(f-\u003esrf_bf);\n \tkfree(f-\u003esrf_macs);\n+\tkfree(f-\u003ecsids);\n \tfor (i = 0; i \u003c f-\u003enum_rx_filters; i++)\n \t\tkfree(f-\u003erx_filters[i].filter);\n \n"
}

2/1 2026/10/14 16:38 agent patch-evaluator
10m Model:
core

Args:
null

Results:
{
  "EnableConfigs": [
    "CFG80211",
    "MAC80211",
    "MAC80211_HWSIM"
  ],
  "FocusSymbols": [
    "nl80211_nan_ndp_initiate",
    "nl80211_nan_ndp_respond",
    "nl80211_nan_ndp_terminate",
    "nl80211_nan_add_func",
    "nl80211_pmsr_start",
    "pmsr_parse_peer",
    "pmsr_parse_ftm_nan",
    "cfg80211_nan_ndp_request",
    "cfg80211_nan_ndp_confirm",
    "cfg80211_nan_ndp_terminated",
    "cfg80211_nan_match",
    "cfg80211_free_nan_func"
  ],
  "Reasoning": "The patch series adds infrastructure for NAN Data Path (NDP) and NAN Ranging in cfg80211 and nl80211. It introduces three new netlink commands (NL80211_CMD_NAN_NDP_INITIATE, NL80211_CMD_NAN_NDP_RESPOND, NL80211_CMD_NAN_NDP_TERMINATE), adds new netlink policies and attributes, introduces defensive checks in nl80211_nan_add_func, and extends peer measurement (PMSR) parsing for NAN ranging. This code is in the core networking subsystem and directly accessible from userspace over Generic Netlink in standard virtualized environments supporting mac80211_hwsim.",
  "WorthFuzzing": true
}

Instruction:
You are an expert Linux kernel maintainer and security engineer.
Your job is to review a provided patch series and evaluate whether it warrants fuzzing with syzkaller.

IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on internal assumptions. You must actively use your code access
tools to inspect the actual source code, callers, and surrounding context.

================================================================================
1. CORE TRIAGE PHILOSOPHY
================================================================================
The goal of patch fuzzing is to discover crashes, regressions, exposed latent bugs,
and newly triggered assertions introduced by the patch series.

- REACHABILITY IS THE PRIMARY GATE:
  Fuzzing can only discover bugs in code that can actually execute in standard virtualized
  environments (GCE or QEMU, utilizing software-emulated devices like USB gadgets, netdev, tun/tap).
  If the modified code is structurally unreachable (see Section 2), it MUST NOT be fuzzed,
  regardless of whether it adds assertions or complex logic.

- DO NOT BLINDLY TRUST "NO FUNCTIONAL CHANGE" (NFCI) OR "REFACTORING" CLAIMS:
  Patch authors routinely label changes as "cleanups", "refactorings", or state
  "No functional change intended". Do NOT take these claims at face value.
  Code refactorings that rearrange logic, introduce helper functions, or alter state management
  in core subsystems frequently introduce subtle semantic shifts or uncover latent kernel bugs.
  If reachable executable code is modified or refactored, it MUST be fuzzed.

- NEW OR MODIFIED ASSERTIONS IN REACHABLE CODE MUST BE FUZZED:
  When a patch introduces or modifies runtime checks or assertions (e.g., WARN_ON*, VM_WARN_ON*,
  BUG_ON*, lockdep_assert*) in reachable code paths, it enforces new or stricter invariants.
  Even if the author believes the invariant always holds, fuzzing is essential to verify whether
  an unusual sequence of operations can violate it.

================================================================================
2. WHEN TO RETURN WorthFuzzing=false (NEGATIVE CRITERIA)
================================================================================
Return WorthFuzzing=false ONLY IF all modified code falls strictly into one or more of these categories:

- Non-kernel and non-executable changes:
  * Modifications to Documentation/, comments, or spelling fixes.
  * User-space directories, self-tests, samples, or scripts (e.g., tools/, samples/, scripts/, usr/)
    that do not affect the compiled kernel image (vmlinux) or kernel modules.
  * Purely decorative logging (e.g., message strings in pr_err, printk, dev_info) or tracepoints
    that do not alter control flow or data structures.
  * Build system or Kconfig changes that do not alter compiled C logic.
- Structurally unreachable hardware:
  * Vendor-specific PCIe switches, SmartNICs, or GPU drivers (e.g., mlxsw, pds_core, qed,
    ionic, amdgpu) requiring physical ASIC/PCIe cards not emulated in standard QEMU.
- Unreachable execution paths:
  * Driver teardown callbacks (.remove, .shutdown, pci_unregister_driver) executed only during
    physical PCI hot-unplug or manual sysfs driver unbinding.
  * Code paths exclusive to architectures other than the target architecture.

================================================================================
3. WHEN TO RETURN WorthFuzzing=true (POSITIVE CRITERIA)
================================================================================
Return WorthFuzzing=true whenever the patch touches reachable executable code, including:
- Core Subsystems:
  * Any logic modifications in memory management (mm/), synchronization/locking (kernel/locking/),
    BPF, scheduler, core networking, VFS, or syscall handling.
- Refactorings and Code Cleanups:
  * Any restructuring of reachable data structures, helper abstractions, or algorithm flows.
- Runtime Assertions and Defensive Checks:
  * Any introduction or alteration of assertions (WARN_ON*, VM_WARN_ON*, BUG_ON*, etc.) in reachable paths.
- Reachable Drivers and Protocols:
  * Drivers accessible via virtual buses (virtio, USB gadget, loopback, netlink, binder, sockets, etc.).

================================================================================
4. EXTRACTING FocusSymbols (PREVENTING DILUTION)
================================================================================
When WorthFuzzing=true, you must extract specific kernel functions into FocusSymbols to guide the fuzzer:

- AVOID UBIQUITOUS LIFECYCLE HOT-PATHS:
  Do NOT list generic, ubiquitous functions called by almost every program in the corpus
  (including, but not limited to: general memory allocators and deallocators, page fault
  and trap handlers, or core synchronization primitives; this is not an exhaustive list).
  Listing ubiquitous functions causes the fuzzer to classify thousands of unrelated tests as "focused",
  which severely dilutes fuzzing effort away from the actual changes.

- TARGET SPECIFIC FEATURE LOGIC AND ENTRYPOINTS:
  List functions that specifically implement the logic being added or altered, or direct API entrypoints
  for the subsystem feature under review.

- HANDLING STATIC INLINE FUNCTIONS IN HEADERS (.h):
  Compiler-inlined static functions (such as static inlines in mm/*.h or include/linux/*.h) lack
  distinct symbol addresses in vmlinux and cannot be targeted directly by symbol coverage filters.
  If the changes are primarily in static inline helpers, identify non-static, feature-specific caller
  functions in .c files that exercise them (avoiding ubiquitous lifecycle wrappers).

================================================================================
5. IDENTIFYING EnableConfigs
================================================================================
Identify any specific CONFIG_ options required to properly compile and reach the modified code:
- Inspect Kconfig files and #ifdef guards; do not make assumptions.
- Check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed.
- Strip any 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4").
Prefer calling several tools at the same time to save round-trips.


Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.

Prompt:
Target architecture: amd64

For your convenience, here is the diff of the changes:
commit e69ce378af275ac551b3277525fb9a976aef3381
Author: syz-cluster <triage@syzkaller.com>
Date:   Wed Oct 14 16:38:25 2026 +0000

    syz-cluster: applied patch under review

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index f773856c18181..8e0325501bcf4 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -4334,6 +4334,192 @@ struct cfg80211_nan_peer_sched {
 	struct cfg80211_nan_peer_map maps[CFG80211_NAN_MAX_PEER_MAPS];
 };
 
+/**
+ * struct cfg80211_nan_ndp_initiate - NAN NDP initiate parameters
+ *
+ * @peer_nmi: peer NMI address
+ * @publish_id: publisher's service instance ID
+ * @service_id: NAN service ID (%NL80211_NAN_FUNC_SERVICE_ID_LEN bytes)
+ * @init_ndi: initiator NDI MAC address. The corresponding
+ *	%NL80211_IFTYPE_NAN_DATA interface must exist.
+ * @ssi: service-specific info (may be NULL)
+ * @ssi_len: length of @ssi
+ * @cipher_suite: NAN cipher suite ID, 0 for open NDP
+ * @pmk: NAN Data Path PMK (%NL80211_NAN_NDP_PMK_LEN bytes,
+ *	valid when @pmk_set is true)
+ * @pmk_set: if true, @pmk contains a valid PMK
+ * @pmkid: PMKID (%NL80211_NAN_NDP_PMKID_LEN bytes,
+ *	valid when @pmkid_set is true)
+ * @pmkid_set: if true, @pmkid contains a valid PMKID
+ * @gtk_required: if true, GTK protection is required
+ * @gtk_cipher: GTK cipher suite ID (valid when @gtk_required is true)
+ * @ipv6_intf_id: IPv6 link-local interface identifier
+ *	(%NL80211_NAN_NDP_IPV6_INTF_ID_LEN bytes,
+ *	valid when @ipv6_intf_id_set is true)
+ * @ipv6_intf_id_set: if true, @ipv6_intf_id is valid
+ * @ndpe: if true, use NDPE attribute instead of NDP attribute
+ */
+struct cfg80211_nan_ndp_initiate {
+	const u8 *peer_nmi;
+	u8 publish_id;
+	u8 service_id[NL80211_NAN_FUNC_SERVICE_ID_LEN];
+	const u8 *init_ndi;
+	const u8 *ssi;
+	u8 ssi_len;
+	u32 cipher_suite;
+	u8 pmk[NL80211_NAN_NDP_PMK_LEN];
+	bool pmk_set;
+	u8 pmkid[NL80211_NAN_NDP_PMKID_LEN];
+	bool pmkid_set;
+	bool gtk_required;
+	u32 gtk_cipher;
+	u8 ipv6_intf_id[NL80211_NAN_NDP_IPV6_INTF_ID_LEN];
+	bool ipv6_intf_id_set;
+	bool ndpe;
+};
+
+/**
+ * struct cfg80211_nan_ndp_respond - NAN NDP respond parameters
+ *
+ * @peer_nmi: peer NMI address
+ * @ndp_id: NDP ID from the received NDP Request
+ * @init_ndi: initiator NDI MAC from the received NDP Request
+ * @resp_ndi: responder NDI MAC. The corresponding
+ *	%NL80211_IFTYPE_NAN_DATA interface must exist (if accepting).
+ * @accept: if true, accept the NDP; if false, reject it
+ * @reason: rejection reason code (valid when @accept is false)
+ * @ssi: response service-specific info (may be NULL)
+ * @ssi_len: length of @ssi
+ * @cipher_suite: NAN cipher suite ID (must match initiator's)
+ * @pmk: NAN Data Path PMK (%NL80211_NAN_NDP_PMK_LEN bytes,
+ *	valid when @pmk_set is true)
+ * @pmk_set: if true, @pmk contains a valid PMK
+ * @gtk_required: if true, GTK protection is required
+ * @gtk_cipher: GTK cipher suite ID
+ * @ipv6_intf_id: IPv6 link-local interface identifier
+ *	(%NL80211_NAN_NDP_IPV6_INTF_ID_LEN bytes,
+ *	valid when @ipv6_intf_id_set is true)
+ * @ipv6_intf_id_set: if true, @ipv6_intf_id is valid
+ * @ndpe: if true, use NDPE attribute instead of NDP attribute
+ */
+struct cfg80211_nan_ndp_respond {
+	const u8 *peer_nmi;
+	u8 ndp_id;
+	const u8 *init_ndi;
+	const u8 *resp_ndi;
+	bool accept;
+	u8 reason;
+	const u8 *ssi;
+	u8 ssi_len;
+	u32 cipher_suite;
+	u8 pmk[NL80211_NAN_NDP_PMK_LEN];
+	bool pmk_set;
+	bool gtk_required;
+	u32 gtk_cipher;
+	u8 ipv6_intf_id[NL80211_NAN_NDP_IPV6_INTF_ID_LEN];
+	bool ipv6_intf_id_set;
+	bool ndpe;
+};
+
+/**
+ * struct cfg80211_nan_ndp_terminate - NAN NDP terminate parameters
+ *
+ * @peer_nmi: peer NMI address
+ * @ndp_id: NDP ID to terminate
+ * @init_ndi: initiator NDI MAC address
+ * @reason: termination reason code
+ */
+struct cfg80211_nan_ndp_terminate {
+	const u8 *peer_nmi;
+	u8 ndp_id;
+	const u8 *init_ndi;
+	u8 reason;
+};
+
+/**
+ * struct cfg80211_nan_ndp_request_params - NAN NDP request event parameters
+ *
+ * Sent to userspace when the driver receives a NDP Request frame.
+ *
+ * @peer_nmi: peer NMI address
+ * @ndp_id: NDP ID from the received frame
+ * @init_ndi: initiator NDI MAC from the received frame
+ * @publish_id: publisher's service instance ID
+ * @ssi: service-specific info (may be NULL)
+ * @ssi_len: length of @ssi
+ * @cipher_suite: initiator's cipher suite ID
+ * @pmkid: PMKID from the peer's SCIA (%NL80211_NAN_NDP_PMKID_LEN bytes,
+ *	valid when @pmkid_set is true)
+ * @pmkid_set: if true, @pmkid is valid
+ * @gtk_required: if true, initiator requires GTK protection
+ * @ipv6_intf_id: initiator's IPv6 link-local interface identifier
+ *	(%NL80211_NAN_NDP_IPV6_INTF_ID_LEN bytes,
+ *	valid when @ipv6_intf_id_set is true)
+ * @ipv6_intf_id_set: if true, @ipv6_intf_id is valid
+ * @ndpe: if true, use NDPE attribute instead of NDP attribute
+ */
+struct cfg80211_nan_ndp_request_params {
+	const u8 *peer_nmi;
+	u8 ndp_id;
+	const u8 *init_ndi;
+	u8 publish_id;
+	const u8 *ssi;
+	u8 ssi_len;
+	u32 cipher_suite;
+	u8 pmkid[NL80211_NAN_NDP_PMKID_LEN];
+	bool pmkid_set;
+	bool gtk_required;
+	u8 ipv6_intf_id[NL80211_NAN_NDP_IPV6_INTF_ID_LEN];
+	bool ipv6_intf_id_set;
+	bool ndpe;
+};
+
+/**
+ * struct cfg80211_nan_ndp_confirm_params - NAN NDP confirm event parameters
+ *
+ * Sent to userspace after the driver completes NDP setup.
+ *
+ * @peer_nmi: peer NMI address
+ * @ndp_id: NDP ID
+ * @init_ndi: initiator NDI MAC address
+ * @resp_ndi: responder NDI MAC address (valid when @accepted is true)
+ * @accepted: if true, NDP was accepted; if false, rejected
+ * @reason: rejection reason (valid when @accepted is false)
+ * @ssi: response service-specific info (may be NULL)
+ * @ssi_len: length of @ssi
+ * @ipv6_intf_id: peer's IPv6 link-local interface identifier
+ *	(%NL80211_NAN_NDP_IPV6_INTF_ID_LEN bytes,
+ *	valid when @ipv6_intf_id_set is true)
+ * @ipv6_intf_id_set: if true, @ipv6_intf_id is valid
+ */
+struct cfg80211_nan_ndp_confirm_params {
+	const u8 *peer_nmi;
+	u8 ndp_id;
+	const u8 *init_ndi;
+	const u8 *resp_ndi;
+	bool accepted;
+	u8 reason;
+	const u8 *ssi;
+	u8 ssi_len;
+	u8 ipv6_intf_id[NL80211_NAN_NDP_IPV6_INTF_ID_LEN];
+	bool ipv6_intf_id_set;
+};
+
+/**
+ * struct cfg80211_nan_ndp_terminated_params - NAN NDP terminated event
+ *
+ * @peer_nmi: peer NMI address
+ * @ndp_id: NDP ID
+ * @init_ndi: initiator NDI MAC address
+ * @reason: termination reason code
+ */
+struct cfg80211_nan_ndp_terminated_params {
+	const u8 *peer_nmi;
+	u8 ndp_id;
+	const u8 *init_ndi;
+	u8 reason;
+};
+
 /**
  * enum cfg80211_nan_conf_changes - indicates changed fields in NAN
  * configuration
@@ -4392,6 +4578,34 @@ struct cfg80211_nan_func_filter {
  * @num_tx_filters: length of &tx_filters.
  * @instance_id: driver allocated id of the function.
  * @cookie: unique NAN function identifier.
+ * @sdea_ctrl: SDEA control field bitmask as defined in Wi-Fi Aware
+ *	specification Table 9-297. Bit 2: Data Path Required. Bit 6:
+ *	Security Required. Bit 10: GTK Required. The Security Required and
+ *	GTK Required bits require %NL80211_EXT_FEATURE_SECURE_NAN.
+ * @pairing_bootstrap_methods: bitmap of supported NAN pairing
+ *	bootstrapping methods per the Wi-Fi Aware Specification Table 9-321.
+ * @csids: array of u32 NAN Cipher Suite ID (CSID) selectors supported by
+ *	this service. See the Wi-Fi Aware Specification for cipher suite values.
+ * @num_csids: number of entries in @csids.
+ * @nd_pmk: pre-shared NAN Data Path PMK (%NL80211_NAN_NDP_PMK_LEN bytes).
+ * @nd_pmk_set: if true, @nd_pmk contains a valid pre-shared ND-PMK.
+ * @pairing_setup: if true, this service supports NAN pairing setup.
+ * @pairing_cache: if true, this service supports NAN pairing caching.
+ * @pairing_verify: if true, this service supports NAN pairing
+ *	verification using a cached NPK.
+ * @ranging_interval: interval in milliseconds between two consecutive
+ *	ranging measurements, or 0 if not specified.
+ * @ingress_distance: inner geofence threshold in millimetres, or 0 if
+ *	not specified.
+ * @egress_distance: outer geofence threshold in millimetres, or 0 if
+ *	not specified.
+ * @ftms_per_burst: number of FTM frames per burst, or 0 if not specified.
+ * @preamble: PHY preamble for FTM frames, see &enum nl80211_preamble,
+ *	or %NL80211_PREAMBLE_LEGACY if not specified.
+ * @chandef_valid: if true, @chandef is valid.
+ * @chandef: channel definition for FTM ranging.
+ * @range_report: if true, a NAN Ranging Report is required after the FTM
+ *	session.
  */
 struct cfg80211_nan_func {
 	enum nl80211_nan_function_type type;
@@ -4418,6 +4632,23 @@ struct cfg80211_nan_func {
 	u8 num_rx_filters;
 	u8 instance_id;
 	u64 cookie;
+	u16 sdea_ctrl;
+	u16 pairing_bootstrap_methods;
+	u32 *csids;
+	u8 num_csids;
+	u8 nd_pmk[NL80211_NAN_NDP_PMK_LEN];
+	bool nd_pmk_set;
+	bool pairing_setup;
+	bool pairing_cache;
+	bool pairing_verify;
+	u32 ranging_interval;
+	u32 ingress_distance;
+	u32 egress_distance;
+	u8 ftms_per_burst;
+	enum nl80211_preamble preamble;
+	bool chandef_valid;
+	struct cfg80211_chan_def chandef;
+	bool range_report;
 };
 
 /**
@@ -4702,6 +4933,8 @@ struct cfg80211_pmsr_result {
  *		 @trigger_based or @non_trigger_based is set.
  * @rsta: Operate as the RSTA in the measurement. Only valid if @lmr_feedback
  *	and either @trigger_based or @non_trigger_based is set.
+ *	Also valid when @range_report is set and @request_type is
+ *	%NL80211_PMSR_FTM_REQ_TYPE_NAN.
  * @bss_color: the bss color of the responder. Optional. Set to zero to
  *	indicate the driver should set the BSS color. Only valid if
  *	@non_trigger_based or @trigger_based is set.
@@ -4747,6 +4980,10 @@ struct cfg80211_pmsr_result {
  *	provide ranging services to a peer (e.g. in RSTA role) but does
  *	not report the measurement results to userspace. Only valid when
  *	@request_type is %NL80211_PMSR_FTM_REQ_TYPE_PD.
+ * @range_report: a NAN Ranging Report is required after the FTM session.
+ *	Only valid for a NAN RSTA request.
+ * @min_delta_ftm: NAN Min Delta FTM value in units of 100 microseconds.
+ *	Zero indicates no preference.
  *
  * See also nl80211 for the respective attribute documentation.
  */
@@ -4763,6 +5000,7 @@ struct cfg80211_pmsr_ftm_request_peer {
 	   rsta:1;
 	u8 num_bursts_exp;
 	u8 burst_duration;
+	u8 min_delta_ftm;
 	u8 ftms_per_burst;
 	u8 ftmr_retries;
 	u8 bss_color;
@@ -4775,7 +5013,8 @@ struct cfg80211_pmsr_ftm_request_peer {
 	u32 num_measurements;
 	u64 ingress_distance;
 	u64 egress_distance;
-	u8 pd_suppress_range_results:1;
+	u8 pd_suppress_range_results:1,
+	   range_report:1;
 };
 
 /**
@@ -5259,6 +5498,13 @@ struct mgmt_frame_regs {
  *	not included become evacuable again. All provided channels are
  *	guaranteed by cfg80211 to belong to the current local schedule.
  *
+ * @nan_ndp_initiate: Initiate a NAN Data Path session as the initiator.
+ *	Only valid if the driver has set %WIPHY_NAN_FLAGS_OFFLOAD_NDP.
+ * @nan_ndp_respond: Respond to an incoming NDP request as the responder.
+ *	Only valid if the driver has set %WIPHY_NAN_FLAGS_OFFLOAD_NDP.
+ * @nan_ndp_terminate: Terminate an established NDP session.
+ *	Only valid if the driver has set %WIPHY_NAN_FLAGS_OFFLOAD_NDP.
+ *
  * @set_multicast_to_unicast: configure multicast to unicast conversion for BSS
  *
  * @get_txq_stats: Get TXQ stats for interface or phy. If wdev is %NULL, this
@@ -5666,6 +5912,15 @@ struct cfg80211_ops {
 	int	(*nan_set_non_evac_channels)(struct wiphy *wiphy,
 					     struct wireless_dev *wdev,
 					     struct cfg80211_nan_non_evac_channels *channels);
+	int     (*nan_ndp_initiate)(struct wiphy *wiphy,
+				    struct wireless_dev *wdev,
+				    struct cfg80211_nan_ndp_initiate *params);
+	int	(*nan_ndp_respond)(struct wiphy *wiphy,
+				   struct wireless_dev *wdev,
+				   struct cfg80211_nan_ndp_respond *params);
+	int	(*nan_ndp_terminate)(struct wiphy *wiphy,
+				     struct wireless_dev *wdev,
+				     struct cfg80211_nan_ndp_terminate *params);
 	int	(*set_multicast_to_unicast)(struct wiphy *wiphy,
 					    struct net_device *dev,
 					    const bool enabled);
@@ -6215,6 +6470,8 @@ cfg80211_get_iftype_ext_capa(struct wiphy *wiphy, enum nl80211_iftype type);
  * @ftm.type.pd_support: supports peer-to-peer ranging as mentioned in the
  *	specification "PR Implementation Consideration Draft 1.9 rev 1" where
  *	PD stands for proximity detection
+ * @ftm.type.nan_support: supports NAN ranging as defined in
+ *	the "Wi-Fi Aware Specification v4.0, clause 8".
  * @ftm.concurrent_ista_rsta_support: indicates if the device can
  *	simultaneously act as initiator and responder in a multi-peer
  *	measurement request. Only valid if @ftm.rsta_support is set.
@@ -6265,7 +6522,8 @@ struct cfg80211_pmsr_capabilities {
 		u32 min_allowed_ranging_interval_ntb;
 		struct {
 			u8 infra_support:1,
-			   pd_support:1;
+			   pd_support:1,
+			   nan_support:1;
 		} type;
 		u8 concurrent_ista_rsta_support:1;
 		u32 pd_preambles;
@@ -6348,11 +6606,18 @@ struct wiphy_radio {
  * @WIPHY_NAN_FLAGS_USERSPACE_DE: Device doesn't support DE offload.
  * @WIPHY_NAN_FLAGS_INSTANT_COMM: Device can switch to Instant Communication
  *     (IC) mode. Can only be set along with %WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC.
+ * @WIPHY_NAN_FLAGS_OFFLOAD_NDP: Driver handles NAN Data Path (NDP) handshake
+ *	frames and data path key installation autonomously.
+ * @WIPHY_NAN_FLAGS_OFFLOAD_RANGING: Firmware supports fully offloaded NAN
+ *	ranging procedure, including ranging session setup, update, and
+ *	termination, FTM protocol and procedure, and ranging report.
  */
 enum wiphy_nan_flags {
 	WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC = BIT(0),
 	WIPHY_NAN_FLAGS_USERSPACE_DE   = BIT(1),
 	WIPHY_NAN_FLAGS_INSTANT_COMM = BIT(2),
+	WIPHY_NAN_FLAGS_OFFLOAD_NDP = BIT(3),
+	WIPHY_NAN_FLAGS_OFFLOAD_RANGING = BIT(4),
 };
 
 /**
@@ -10554,7 +10819,26 @@ void cfg80211_free_nan_func(struct cfg80211_nan_func *f);
  * @addr: the MAC address of the peer
  * @info_len: the length of the &info
  * @info: the Service Specific Info from the peer (if any)
+ * @extra_info_len: the length of @extra_info (Extended SSI)
+ * @extra_info: Extended Service Specific Info from the peer (if any)
+ * @ies_len: the length of @ies
+ * @ies: additional elements from the peer's Service Descriptor frame (if any)
+ * @sdea_ctrl: SDEA control field from the peer's SDEA attribute. Bit 2
+ *	indicates Data Path Required, bit 6 Security Required.
+ * @pairing_bootstrap_methods: bitmap of the peer's supported NAN pairing
+ *	bootstrapping methods.
+ * @csids: array of NAN cipher suite IDs advertised by the peer.
+ *	NULL if not present.
+ * @num_csids: number of entries in @csids.
+ * @pairing_setup: if true, the peer supports NAN pairing setup.
+ * @pairing_cache: if true, the peer supports NAN pairing NPK/NIK caching.
+ * @pairing_verify: if true, the peer supports NAN pairing re-verification.
+ * @rssi: received signal strength in dBm at the time of the match.
+ *	Only valid when @rssi_valid is true.
+ * @rssi_valid: if true, @rssi contains a valid RSSI measurement.
  * @cookie: unique identifier of the corresponding function
+ * @ranging_indication: bitmap indicating the type of ranging performed.
+ * @ranging_measurement: distance to the peer in millimetres.
  */
 struct cfg80211_nan_match_params {
 	enum nl80211_nan_function_type type;
@@ -10563,7 +10847,22 @@ struct cfg80211_nan_match_params {
 	const u8 *addr;
 	u8 info_len;
 	const u8 *info;
+	u8 extra_info_len;
+	const u8 *extra_info;
+	u16 ies_len;
+	const u8 *ies;
+	u16 sdea_ctrl;
+	u16 pairing_bootstrap_methods;
+	const u32 *csids;
+	u8 num_csids;
+	bool pairing_setup;
+	bool pairing_cache;
+	bool pairing_verify;
+	s32 rssi;
+	bool rssi_valid;
 	u64 cookie;
+	u8 ranging_indication;
+	s32 ranging_measurement;
 };
 
 /**
@@ -11099,6 +11398,46 @@ cfg80211_s1g_get_primary_sibling(struct wiphy *wiphy,
 }
 
 
+/**
+ * cfg80211_nan_ndp_request - notify userspace of a received NDP request
+ * @wdev: the wireless device reporting the event
+ * @params: NDP request parameters parsed from the received frame
+ * @gfp: allocation flags
+ *
+ * Notify userspace that a NAN Data Path request was received from a peer.
+ * Only valid when %WIPHY_NAN_FLAGS_OFFLOAD_NDP is set.
+ */
+void cfg80211_nan_ndp_request(struct wireless_dev *wdev,
+			      struct cfg80211_nan_ndp_request_params *params,
+			      gfp_t gfp);
+
+/**
+ * cfg80211_nan_ndp_confirm - notify userspace that NDP setup is complete
+ * @wdev: the wireless device reporting the event
+ * @params: NDP confirm parameters
+ * @gfp: allocation flags
+ *
+ * Notify userspace that NAN Data Path setup is complete. Includes the
+ * accept/reject status and, if accepted, the responder NDI. Only valid
+ * when %WIPHY_NAN_FLAGS_OFFLOAD_NDP is set.
+ */
+void cfg80211_nan_ndp_confirm(struct wireless_dev *wdev,
+			      struct cfg80211_nan_ndp_confirm_params *params,
+			      gfp_t gfp);
+
+/**
+ * cfg80211_nan_ndp_terminated - notify userspace that an NDP was terminated
+ * @wdev: the wireless device reporting the event
+ * @params: NDP termination parameters
+ * @gfp: allocation flags
+ *
+ * Notify userspace that a NAN Data Path was torn down. Only valid
+ * when %WIPHY_NAN_FLAGS_OFFLOAD_NDP is set.
+ */
+void cfg80211_nan_ndp_terminated(struct wireless_dev *wdev,
+				 struct cfg80211_nan_ndp_terminated_params *params,
+				 gfp_t gfp);
+
 /**
  * cfg80211_incumbent_signal_notify - Notify userspace of incumbent signal detection
  * @wiphy: the wiphy to use
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index b56a96f57bec2..71ed38992d334 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -1468,6 +1468,36 @@
  *	and multiple can be nested in %NL80211_ATTR_MLO_LINKS but then the
  *	update isn't atomic if any failures happen.
  *	Only supported with %NL80211_EXT_FEATURE_UPDATE_BEACON.
+ *
+ * @NL80211_CMD_NAN_NDP_INITIATE: Initiate NAN Data Path (NDP) setup
+ *	as the initiator. Requires %WIPHY_NAN_FLAGS_OFFLOAD_NDP. The NDI
+ *	interface specified in %NL80211_NAN_NDP_ATTR_INIT_NDI must already
+ *	exist as a %NL80211_IFTYPE_NAN_DATA interface. Carries
+ *	%NL80211_ATTR_NAN_NDP nested with %NL80211_NAN_NDP_ATTR_* fields.
+ * @NL80211_CMD_NAN_NDP_RESPOND: Respond to a received NDP request as
+ *	the responder. Requires %WIPHY_NAN_FLAGS_OFFLOAD_NDP. The NDI
+ *	interface specified in %NL80211_NAN_NDP_ATTR_RESP_NDI must already
+ *	exist as a %NL80211_IFTYPE_NAN_DATA interface. Carries
+ *	%NL80211_ATTR_NAN_NDP nested with %NL80211_NAN_NDP_ATTR_* fields.
+ * @NL80211_CMD_NAN_NDP_TERMINATE: Terminate an established NDP.
+ *	Requires %WIPHY_NAN_FLAGS_OFFLOAD_NDP. Carries %NL80211_ATTR_NAN_NDP
+ *	nested with %NL80211_NAN_NDP_ATTR_ID, %NL80211_NAN_NDP_ATTR_INIT_NDI
+ *	and optionally %NL80211_NAN_NDP_ATTR_REASON.
+ * @NL80211_CMD_NAN_NDP_REQUEST: Notification sent to userspace when
+ *	the driver receives a NDP Request frame from a peer. Carries
+ *	%NL80211_ATTR_MAC (peer NMI) and %NL80211_ATTR_NAN_NDP nested with
+ *	all parsed NDP request parameters. Userspace must ensure the NDI
+ *	interface is ready before calling %NL80211_CMD_NAN_NDP_RESPOND.
+ * @NL80211_CMD_NAN_NDP_CONFIRM: Notification sent to userspace after
+ *	the driver completes NDP setup and installs data path keys. Carries
+ *	%NL80211_ATTR_MAC (peer NMI) and %NL80211_ATTR_NAN_NDP nested with
+ *	the NDP confirm parameters including %NL80211_NAN_NDP_ATTR_RESP_NDI.
+ *	Userspace should call %NL80211_CMD_NEW_STATION on the NDI interface
+ *	to add the peer NDI station.
+ * @NL80211_CMD_NAN_NDP_TERMINATED: Notification sent to userspace
+ *	when an NDP is terminated. Carries %NL80211_ATTR_MAC (peer NMI)
+ *	and %NL80211_ATTR_NAN_NDP nested with the termination parameters.
+ *
  * @NL80211_CMD_MAX: highest used command number
  * @__NL80211_CMD_AFTER_LAST: internal use
  */
@@ -1750,6 +1780,13 @@ enum nl80211_commands {
 
 	NL80211_CMD_UPDATE_BEACON,
 
+	NL80211_CMD_NAN_NDP_INITIATE,
+	NL80211_CMD_NAN_NDP_RESPOND,
+	NL80211_CMD_NAN_NDP_TERMINATE,
+	NL80211_CMD_NAN_NDP_REQUEST,
+	NL80211_CMD_NAN_NDP_CONFIRM,
+	NL80211_CMD_NAN_NDP_TERMINATED,
+
 	/* add new commands above here */
 
 	/* used to define NL80211_CMD_MAX below */
@@ -3243,6 +3280,9 @@ enum nl80211_commands {
  * @NL80211_ATTR_ASSOC_PROTECTED_TWT: Enable protected TWT for the association,
  *	requires protected TWT support (flag attribute)
  *
+ * @NL80211_ATTR_NAN_NDP: nested attribute carrying NAN Data Path parameters.
+ *	See &enum nl80211_nan_ndp_attributes.
+ *
  * @NUM_NL80211_ATTR: total number of nl80211_attrs available
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -3850,6 +3890,8 @@ enum nl80211_attrs {
 
 	NL80211_ATTR_ASSOC_PROTECTED_TWT,
 
+	NL80211_ATTR_NAN_NDP,
+
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,
@@ -7715,6 +7757,8 @@ enum nl80211_nan_func_term_reason {
 #define NL80211_NAN_FUNC_SERVICE_SPEC_INFO_MAX_LEN 0xff
 #define NL80211_NAN_FUNC_SRF_MAX_LEN 0xff
 
+#define NL80211_NAN_NDP_PMK_LEN 32
+
 /**
  * enum nl80211_nan_func_attributes - NAN function attributes
  * @__NL80211_NAN_FUNC_INVALID: invalid
@@ -7753,6 +7797,40 @@ enum nl80211_nan_func_term_reason {
  *	Its type is u8 and it cannot be 0.
  * @NL80211_NAN_FUNC_TERM_REASON: NAN function termination reason.
  *	See &enum nl80211_nan_func_term_reason.
+ * @NL80211_NAN_FUNC_SDEA_CTRL: u16 Service Descriptor Extension Attribute
+ *	(SDEA) control field bitmask as defined in the Wi-Fi Aware Specification
+ *	Table 9-297. See &enum nl80211_nan_func_sdea_ctrl_flags for the
+ *	relevant bit definitions. The Security Required and GTK Required bits
+ *	require %NL80211_EXT_FEATURE_SECURE_NAN.
+ * @NL80211_NAN_FUNC_PAIRING_BOOTSTRAP_METHODS: u16 bitmap of supported
+ *	NAN pairing bootstrapping methods as defined in Wi-Fi Aware
+ *	specification Table 9-321. Each bit corresponds to one method.
+ * @NL80211_NAN_FUNC_CSIDS: a set of u32 NAN Cipher Suite ID (CSID)
+ *	selectors supported by this service. Requires
+ *	%NL80211_EXT_FEATURE_SECURE_NAN.
+ * @NL80211_NAN_FUNC_PAIRING_SETUP: flag attribute. This service supports
+ *	NAN pairing setup (new pairing).
+ * @NL80211_NAN_FUNC_PAIRING_CACHE: flag attribute. This service supports
+ *	NAN pairing caching (NPK caching).
+ * @NL80211_NAN_FUNC_PAIRING_VERIFY: flag attribute. This service supports
+ *	NAN pairing verification using a cached NPK.
+ * @NL80211_NAN_FUNC_ND_PMK: %NL80211_NAN_NDP_PMK_LEN-byte pre-shared NAN
+ *	Data Path PMK (ND-PMK).
+ *	Requires %NL80211_EXT_FEATURE_SECURE_NAN.
+ * @NL80211_NAN_FUNC_RANGING_INTERVAL: u32 attribute. Interval in
+ *	milliseconds between two consecutive ranging measurements.
+ * @NL80211_NAN_FUNC_INGRESS_DISTANCE: u32 attribute. Inner geofence
+ *	threshold in millimetres.
+ * @NL80211_NAN_FUNC_EGRESS_DISTANCE: u32 attribute. Outer geofence
+ *	threshold in millimetres.
+ * @NL80211_NAN_FUNC_FTMS_PER_BURST: u8 attribute. Number of FTM
+ *	frames per burst.
+ * @NL80211_NAN_FUNC_PREAMBLE: u32 attribute. PHY preamble type for
+ *	FTM frames (see &enum nl80211_preamble).
+ * @NL80211_NAN_FUNC_CHAN: channel definition for FTM ranging, nested,
+ *	using top-level attributes like %NL80211_ATTR_WIPHY_FREQ etc.
+ * @NL80211_NAN_FUNC_RANGE_REPORT: flag indicating that a NAN Ranging
+ *	Report is required after the FTM session.
  *
  * @NUM_NL80211_NAN_FUNC_ATTR: internal
  * @NL80211_NAN_FUNC_ATTR_MAX: highest NAN function attribute
@@ -7775,12 +7853,45 @@ enum nl80211_nan_func_attributes {
 	NL80211_NAN_FUNC_TX_MATCH_FILTER,
 	NL80211_NAN_FUNC_INSTANCE_ID,
 	NL80211_NAN_FUNC_TERM_REASON,
+	NL80211_NAN_FUNC_SDEA_CTRL,
+	NL80211_NAN_FUNC_PAIRING_BOOTSTRAP_METHODS,
+	NL80211_NAN_FUNC_CSIDS,
+	NL80211_NAN_FUNC_PAIRING_SETUP,
+	NL80211_NAN_FUNC_PAIRING_CACHE,
+	NL80211_NAN_FUNC_PAIRING_VERIFY,
+	NL80211_NAN_FUNC_ND_PMK,
+	NL80211_NAN_FUNC_RANGING_INTERVAL,
+	NL80211_NAN_FUNC_INGRESS_DISTANCE,
+	NL80211_NAN_FUNC_EGRESS_DISTANCE,
+	NL80211_NAN_FUNC_FTMS_PER_BURST,
+	NL80211_NAN_FUNC_PREAMBLE,
+	NL80211_NAN_FUNC_CHAN,
+	NL80211_NAN_FUNC_RANGE_REPORT,
 
 	/* keep last */
 	NUM_NL80211_NAN_FUNC_ATTR,
 	NL80211_NAN_FUNC_ATTR_MAX = NUM_NL80211_NAN_FUNC_ATTR - 1
 };
 
+/**
+ * enum nl80211_nan_func_sdea_ctrl_flags - NAN SDEA control field bit flags
+ *
+ * Bit definitions for the u16 SDEA control field carried in
+ * %NL80211_NAN_FUNC_SDEA_CTRL, as specified in the Wi-Fi Aware
+ * Specification Table 9-297.
+ *
+ * @NL80211_NAN_FUNC_SDEA_CTRL_DATAPATH_REQUIRED: bit 2 - Data Path Required.
+ * @NL80211_NAN_FUNC_SDEA_CTRL_SECURITY_REQUIRED: bit 6 - Security Required.
+ * @NL80211_NAN_FUNC_SDEA_CTRL_RANGING_REQUIRED: bit 7 - Ranging Required.
+ * @NL80211_NAN_FUNC_SDEA_CTRL_GTK_REQUIRED: bit 10 - GTK Required.
+ */
+enum nl80211_nan_func_sdea_ctrl_flags {
+	NL80211_NAN_FUNC_SDEA_CTRL_DATAPATH_REQUIRED	= 1 << 2,
+	NL80211_NAN_FUNC_SDEA_CTRL_SECURITY_REQUIRED	= 1 << 6,
+	NL80211_NAN_FUNC_SDEA_CTRL_RANGING_REQUIRED	= 1 << 7,
+	NL80211_NAN_FUNC_SDEA_CTRL_GTK_REQUIRED		= 1 << 10,
+};
+
 /**
  * enum nl80211_nan_srf_attributes - NAN Service Response filter attributes
  * @__NL80211_NAN_SRF_INVALID: invalid
@@ -7817,6 +7928,34 @@ enum nl80211_nan_srf_attributes {
  * @NL80211_NAN_MATCH_FUNC_PEER: the peer function
  *	that caused the match. This is a nested attribute.
  *	See &enum nl80211_nan_func_attributes.
+ * @NL80211_NAN_MATCH_SDEA_CTRL: u16 SDEA control field from the peer's
+ *	Service Descriptor Extension Attribute. Bit 2 indicates Data Path
+ *	Required, bit 6 Security Required, bit 7 Ranging Required, bit 10
+ *	GTK Required.
+ * @NL80211_NAN_MATCH_BOOTSTRAP_METHODS: u16 bitmap of the peer's
+ *	supported NAN pairing bootstrapping methods per the Wi-Fi Aware
+ *	Specification Table 9-321.
+ * @NL80211_NAN_MATCH_CIPHER_SUITES: a set of u32 values indicating the NAN
+ *	cipher suite selectors advertised by the peer.
+ * @NL80211_NAN_MATCH_PAIRING_SETUP: flag attribute. Set if the peer
+ *	supports NAN pairing setup.
+ * @NL80211_NAN_MATCH_PAIRING_CACHE: flag attribute. Set if the peer
+ *	supports NAN pairing NPK/NIK caching.
+ * @NL80211_NAN_MATCH_PAIRING_VERIFY: flag attribute. Set if the peer
+ *	supports NAN pairing re-verification.
+ * @NL80211_NAN_MATCH_EXTRA_INFO: binary attribute carrying the peer's
+ *	Extended Service Specific Info (Extended SSI), if present.
+ * @NL80211_NAN_MATCH_IES: binary attribute carrying additional elements from
+ *	the peer's Service Descriptor frame, if present.
+ * @NL80211_NAN_MATCH_RSSI: s32 attribute. Received signal strength in dBm
+ *	at the time of the match. Only present when the driver provides a
+ *	valid RSSI measurement.
+ * @NL80211_NAN_MATCH_RANGING_INDICATION: u8 attribute. Bitmap indicating
+ *	the type of ranging performed: bit 0: continuous ranging,
+ *	bit 1: ingress condition met, bit 2: egress condition met,
+ *	bit 1 and bit 2: both conditions met. Only present when non-zero.
+ * @NL80211_NAN_MATCH_RANGING_MEASUREMENT: s32 attribute. Distance to
+ *	the peer in millimetres measured via FTM.
  *
  * @NUM_NL80211_NAN_MATCH_ATTR: internal
  * @NL80211_NAN_MATCH_ATTR_MAX: highest NAN match attribute
@@ -7825,6 +7964,17 @@ enum nl80211_nan_match_attributes {
 	__NL80211_NAN_MATCH_INVALID,
 	NL80211_NAN_MATCH_FUNC_LOCAL,
 	NL80211_NAN_MATCH_FUNC_PEER,
+	NL80211_NAN_MATCH_SDEA_CTRL,
+	NL80211_NAN_MATCH_BOOTSTRAP_METHODS,
+	NL80211_NAN_MATCH_CIPHER_SUITES,
+	NL80211_NAN_MATCH_PAIRING_SETUP,
+	NL80211_NAN_MATCH_PAIRING_CACHE,
+	NL80211_NAN_MATCH_PAIRING_VERIFY,
+	NL80211_NAN_MATCH_EXTRA_INFO,
+	NL80211_NAN_MATCH_IES,
+	NL80211_NAN_MATCH_RSSI,
+	NL80211_NAN_MATCH_RANGING_INDICATION,
+	NL80211_NAN_MATCH_RANGING_MEASUREMENT,
 
 	/* keep last */
 	NUM_NL80211_NAN_MATCH_ATTR,
@@ -7938,6 +8088,100 @@ enum nl80211_nan_conf_attributes {
 	NL80211_NAN_CONF_ATTR_MAX = NUM_NL80211_NAN_CONF_ATTR - 1,
 };
 
+#define NL80211_NAN_NDP_PMKID_LEN		16
+#define NL80211_NAN_NDP_IPV6_INTF_ID_LEN	8
+
+/**
+ * enum nl80211_nan_ndp_attributes - NAN Data Path attributes
+ *
+ * Nested attributes used within %NL80211_ATTR_NAN_NDP for NDP setup
+ * commands and events.
+ *
+ * @__NL80211_NAN_NDP_ATTR_INVALID: Invalid.
+ * @NL80211_NAN_NDP_ATTR_ID: (u8) NDP ID (1-255). Allocated by the
+ *	initiator and echoed in all subsequent NDP messages.
+ * @NL80211_NAN_NDP_ATTR_PUBLISH_ID: (u8) Publisher's service instance
+ *	ID. Present in %NL80211_CMD_NAN_NDP_INITIATE and
+ *	%NL80211_CMD_NAN_NDP_REQUEST. Used to match the NDP to a service.
+ * @NL80211_NAN_NDP_ATTR_SERVICE_ID: binary (%NL80211_NAN_FUNC_SERVICE_ID_LEN
+ *	bytes). NAN service ID derived from the service name.
+ * @NL80211_NAN_NDP_ATTR_INIT_NDI: (%ETH_ALEN bytes) Initiator NDI MAC
+ *	address. The corresponding %NL80211_IFTYPE_NAN_DATA interface must
+ *	exist.
+ * @NL80211_NAN_NDP_ATTR_RESP_NDI: (%ETH_ALEN bytes) Responder NDI MAC
+ *	address. Present in %NL80211_CMD_NAN_NDP_RESPOND (if accepting) and
+ *	%NL80211_CMD_NAN_NDP_CONFIRM. The corresponding
+ *	%NL80211_IFTYPE_NAN_DATA interface must exist.
+ * @NL80211_NAN_NDP_ATTR_SSI: binary. Service-specific info carried in
+ *	the NDP setup frames.
+ * @NL80211_NAN_NDP_ATTR_CIPHER_SUITE: (u32) NAN cipher suite ID. 0 for
+ *	open (no security). See the Wi-Fi Aware Specification for values.
+ * @NL80211_NAN_NDP_ATTR_PMK: binary (%NL80211_NAN_NDP_PMK_LEN bytes).
+ *	NAN Data Path PMK.
+ *	The driver uses this to compute the PMKID and derive the PTK.
+ *	Requires %NL80211_EXT_FEATURE_SECURE_NAN.
+ * @NL80211_NAN_NDP_ATTR_PMKID: binary (%NL80211_NAN_NDP_PMKID_LEN bytes).
+ *	PMKID from the peer's
+ *	SCIA attribute. Present in %NL80211_CMD_NAN_NDP_REQUEST to allow
+ *	userspace to look up a cached PMK.
+ * @NL80211_NAN_NDP_ATTR_GTK_REQUIRED: flag. GTK/IGTK/BIGTK protection
+ *	required for group-addressed NDP frames.
+ * @NL80211_NAN_NDP_ATTR_GTK_CIPHER: (u32) GTK cipher suite ID. Required
+ *	if %NL80211_NAN_NDP_ATTR_GTK_REQUIRED is set.
+ * @NL80211_NAN_NDP_ATTR_IPV6_INTF_ID: binary (%NL80211_NAN_NDP_IPV6_INTF_ID_LEN
+ *	bytes). IPv6 link-local
+ *	interface identifier. Included as NDPE TLV type 0 when present.
+ * @NL80211_NAN_NDP_ATTR_NDPE: flag. Use NDPE attribute instead of NDP
+ *	attribute when peer supports NDPE.
+ * @NL80211_NAN_NDP_ATTR_ACCEPT: flag. If present in
+ *	%NL80211_CMD_NAN_NDP_RESPOND, the NDP is accepted. If absent, it is
+ *	rejected.
+ * @NL80211_NAN_NDP_ATTR_REASON: (u8) Termination or rejection reason
+ *	code (enum nan_reason from the Wi-Fi Aware Specification).
+ * @NL80211_NAN_NDP_ATTR_STATUS: (u8) NDP status in
+ *	%NL80211_CMD_NAN_NDP_CONFIRM, see &enum nl80211_nan_ndp_status.
+ * @__NL80211_NAN_NDP_ATTR_LAST: Internal.
+ * @NL80211_NAN_NDP_ATTR_MAX: Highest NDP attribute.
+ */
+enum nl80211_nan_ndp_attributes {
+	__NL80211_NAN_NDP_ATTR_INVALID,
+
+	NL80211_NAN_NDP_ATTR_ID,
+	NL80211_NAN_NDP_ATTR_PUBLISH_ID,
+	NL80211_NAN_NDP_ATTR_SERVICE_ID,
+	NL80211_NAN_NDP_ATTR_INIT_NDI,
+	NL80211_NAN_NDP_ATTR_RESP_NDI,
+	NL80211_NAN_NDP_ATTR_SSI,
+	NL80211_NAN_NDP_ATTR_CIPHER_SUITE,
+	NL80211_NAN_NDP_ATTR_PMK,
+	NL80211_NAN_NDP_ATTR_PMKID,
+	NL80211_NAN_NDP_ATTR_GTK_REQUIRED,
+	NL80211_NAN_NDP_ATTR_GTK_CIPHER,
+	NL80211_NAN_NDP_ATTR_IPV6_INTF_ID,
+	NL80211_NAN_NDP_ATTR_NDPE,
+	NL80211_NAN_NDP_ATTR_ACCEPT,
+	NL80211_NAN_NDP_ATTR_REASON,
+	NL80211_NAN_NDP_ATTR_STATUS,
+
+	/* keep last */
+	__NL80211_NAN_NDP_ATTR_LAST,
+	NL80211_NAN_NDP_ATTR_MAX = __NL80211_NAN_NDP_ATTR_LAST - 1,
+};
+
+/**
+ * enum nl80211_nan_ndp_status - NAN Data Path setup status
+ *
+ * Values for %NL80211_NAN_NDP_ATTR_STATUS reported in
+ * %NL80211_CMD_NAN_NDP_CONFIRM.
+ *
+ * @NL80211_NAN_NDP_STATUS_ACCEPTED: NDP setup was accepted by the peer.
+ * @NL80211_NAN_NDP_STATUS_REJECTED: NDP setup was rejected by the peer.
+ */
+enum nl80211_nan_ndp_status {
+	NL80211_NAN_NDP_STATUS_ACCEPTED,
+	NL80211_NAN_NDP_STATUS_REJECTED,
+};
+
 /**
  * enum nl80211_external_auth_action - Action to perform with external
  *     authentication request. Used by NL80211_ATTR_EXTERNAL_AUTH_ACTION.
@@ -8143,12 +8387,16 @@ enum nl80211_peer_measurement_resp {
  * @NL80211_PMSR_FTM_REQ_TYPE_PD: peer-to-peer ranging as defined in the
  *	Wi-Fi Alliance specification "Proximity Ranging (PR) Implementation
  *	Consideration Draft 1.9 Rev 1"
+ * @NL80211_PMSR_FTM_REQ_TYPE_NAN: NAN ranging between two NAN devices as
+ *	defined in the "Wi-Fi Aware Specification v4.0, clause 8".
+ *	Must be issued on a %NL80211_IFTYPE_NAN interface.
  * @NUM_NL80211_PMSR_FTM_REQ_TYPE: internal
  * @NL80211_PMSR_FTM_REQ_TYPE_MAX: highest request type value
  */
 enum nl80211_peer_measurement_ftm_req_type {
 	NL80211_PMSR_FTM_REQ_TYPE_INFRA,
 	NL80211_PMSR_FTM_REQ_TYPE_PD,
+	NL80211_PMSR_FTM_REQ_TYPE_NAN,
 
 	/* keep last */
 	NUM_NL80211_PMSR_FTM_REQ_TYPE,
@@ -8397,6 +8645,9 @@ enum nl80211_peer_measurement_ftm_capa {
  *	the device supports peer-to-peer ranging as mentioned in the
  *	specification "PR Implementation Consideration Draft 1.9 rev 1" where
  *	PD stands for proximity detection
+ * @NL80211_PMSR_FTM_TYPE_CAPA_ATTR_NAN_SUPPORT: flag attribute indicating
+ *	that the device supports NAN ranging between two NAN devices as
+ *	defined in the "Wi-Fi Aware Specification v4.0, clause 8".
  *
  * @NUM_NL80211_PMSR_FTM_TYPE_CAPA_ATTR: internal
  * @NL80211_PMSR_FTM_TYPE_CAPA_ATTR_MAX: highest attribute number
@@ -8406,6 +8657,7 @@ enum nl80211_peer_measurement_ftm_type_capa {
 
 	NL80211_PMSR_FTM_TYPE_CAPA_ATTR_INFRA_SUPPORT,
 	NL80211_PMSR_FTM_TYPE_CAPA_ATTR_PD_SUPPORT,
+	NL80211_PMSR_FTM_TYPE_CAPA_ATTR_NAN_SUPPORT,
 
 	/* keep last */
 	NUM_NL80211_PMSR_FTM_TYPE_CAPA_ATTR,
@@ -8512,6 +8764,11 @@ enum nl80211_peer_measurement_ftm_type_capa {
  *	but results are not reported to userspace, regardless of ranging role
  *	or type. Only valid when %NL80211_PMSR_PEER_ATTR_REQ_TYPE is set to
  *	%NL80211_PMSR_FTM_REQ_TYPE_PD.
+ * @NL80211_PMSR_FTM_REQ_ATTR_RANGE_REPORT: Flag indicating that a NAN
+ *	Ranging Report is required after the FTM session. Only valid for a NAN
+ *	RSTA request.
+ * @NL80211_PMSR_FTM_REQ_ATTR_MIN_DELTA_FTM: NAN Min Delta FTM value in units
+ *	of 100 microseconds (u8, 0-63). A value of 0 indicates no preference.
  *
  * @NUM_NL80211_PMSR_FTM_REQ_ATTR: internal
  * @NL80211_PMSR_FTM_REQ_ATTR_MAX: highest attribute number
@@ -8542,6 +8799,8 @@ enum nl80211_peer_measurement_ftm_req {
 	NL80211_PMSR_FTM_REQ_ATTR_INGRESS,
 	NL80211_PMSR_FTM_REQ_ATTR_EGRESS,
 	NL80211_PMSR_FTM_REQ_ATTR_PD_SUPPRESS_RESULTS,
+	NL80211_PMSR_FTM_REQ_ATTR_RANGE_REPORT,
+	NL80211_PMSR_FTM_REQ_ATTR_MIN_DELTA_FTM,
 
 	/* keep last */
 	NUM_NL80211_PMSR_FTM_REQ_ATTR,
@@ -9153,6 +9412,12 @@ enum nl80211_s1g_short_beacon_attrs {
  *	of the Wi-Fi Aware Specification v4.0. Can only be set if
  *	%NL80211_NAN_CAPA_CONFIGURABLE_SYNC is set. When IC is enabled, the IC
  *	schedule is expected to be configured by user space.
+ * @NL80211_NAN_CAPA_OFFLOAD_RANGING: flag attribute. Firmware supports the
+ *	fully offloaded NAN ranging procedure, including ranging session setup,
+ *	update, and termination, FTM protocol and procedure, and ranging reports.
+ * @NL80211_NAN_CAPA_OFFLOAD_NDP: flag attribute. Driver handles NAN Data
+ *	Path (NDP) handshake frames and data path key installation.
+
  * @__NL80211_NAN_CAPABILITIES_LAST: Internal
  * @NL80211_NAN_CAPABILITIES_MAX: Highest NAN capability attribute.
  */
@@ -9167,6 +9432,8 @@ enum nl80211_nan_capabilities {
 	NL80211_NAN_CAPA_CAPABILITIES,
 	NL80211_NAN_CAPA_PHY,
 	NL80211_NAN_CAPA_INSTANT_COMM,
+	NL80211_NAN_CAPA_OFFLOAD_RANGING,
+	NL80211_NAN_CAPA_OFFLOAD_NDP,
 	/* keep last */
 	__NL80211_NAN_CAPABILITIES_LAST,
 	NL80211_NAN_CAPABILITIES_MAX = __NL80211_NAN_CAPABILITIES_LAST - 1,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index d790e204aee36..e4b664bdf53df 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -557,7 +557,7 @@ nl80211_ftm_responder_policy[NL80211_FTM_RESP_ATTR_MAX + 1] = {
 					     .len = U8_MAX },
 };
 
-static const struct nla_policy
+const struct nla_policy
 nl80211_pmsr_ftm_req_attr_policy[NL80211_PMSR_FTM_REQ_ATTR_MAX + 1] = {
 	[NL80211_PMSR_FTM_REQ_ATTR_ASAP] = { .type = NLA_FLAG },
 	[NL80211_PMSR_FTM_REQ_ATTR_PREAMBLE] =
@@ -589,6 +589,9 @@ nl80211_pmsr_ftm_req_attr_policy[NL80211_PMSR_FTM_REQ_ATTR_MAX + 1] = {
 	[NL80211_PMSR_FTM_REQ_ATTR_INGRESS] = { .type = NLA_U64 },
 	[NL80211_PMSR_FTM_REQ_ATTR_EGRESS] = { .type = NLA_U64 },
 	[NL80211_PMSR_FTM_REQ_ATTR_PD_SUPPRESS_RESULTS] = { .type = NLA_FLAG },
+	[NL80211_PMSR_FTM_REQ_ATTR_RANGE_REPORT] = { .type = NLA_FLAG },
+	[NL80211_PMSR_FTM_REQ_ATTR_MIN_DELTA_FTM] =
+		NLA_POLICY_MAX(NLA_U8, 63),
 };
 
 static const struct nla_policy
@@ -769,6 +772,33 @@ nl80211_nan_peer_map_policy[NL80211_NAN_PEER_MAP_ATTR_MAX + 1] = {
 		NLA_POLICY_EXACT_LEN(CFG80211_NAN_SCHED_NUM_TIME_SLOTS),
 };
 
+static const struct nla_policy
+nl80211_nan_ndp_policy[NL80211_NAN_NDP_ATTR_MAX + 1] = {
+	[NL80211_NAN_NDP_ATTR_ID] = NLA_POLICY_RANGE(NLA_U8, 1, 255),
+	[NL80211_NAN_NDP_ATTR_PUBLISH_ID] = { .type = NLA_U8 },
+	[NL80211_NAN_NDP_ATTR_SERVICE_ID] =
+		NLA_POLICY_EXACT_LEN(NL80211_NAN_FUNC_SERVICE_ID_LEN),
+	[NL80211_NAN_NDP_ATTR_INIT_NDI] = NLA_POLICY_EXACT_LEN(ETH_ALEN),
+	[NL80211_NAN_NDP_ATTR_RESP_NDI] = NLA_POLICY_EXACT_LEN(ETH_ALEN),
+	[NL80211_NAN_NDP_ATTR_SSI] = {
+		.type = NLA_BINARY,
+		.len = NL80211_NAN_FUNC_SERVICE_SPEC_INFO_MAX_LEN
+	},
+	[NL80211_NAN_NDP_ATTR_CIPHER_SUITE] = { .type = NLA_U32 },
+	[NL80211_NAN_NDP_ATTR_PMK] =
+		NLA_POLICY_EXACT_LEN(NL80211_NAN_NDP_PMK_LEN),
+	[NL80211_NAN_NDP_ATTR_PMKID] =
+		NLA_POLICY_EXACT_LEN(NL80211_NAN_NDP_PMKID_LEN),
+	[NL80211_NAN_NDP_ATTR_GTK_REQUIRED] = { .type = NLA_FLAG },
+	[NL80211_NAN_NDP_ATTR_GTK_CIPHER] = { .type = NLA_U32 },
+	[NL80211_NAN_NDP_ATTR_IPV6_INTF_ID] =
+		NLA_POLICY_EXACT_LEN(NL80211_NAN_NDP_IPV6_INTF_ID_LEN),
+	[NL80211_NAN_NDP_ATTR_NDPE] = { .type = NLA_FLAG },
+	[NL80211_NAN_NDP_ATTR_ACCEPT] = { .type = NLA_FLAG },
+	[NL80211_NAN_NDP_ATTR_REASON] = { .type = NLA_U8 },
+	[NL80211_NAN_NDP_ATTR_STATUS] = { .type = NLA_U8 },
+};
+
 static const struct nla_policy
 nl80211_nan_conf_policy[NL80211_NAN_CONF_ATTR_MAX + 1] = {
 	[NL80211_NAN_CONF_CLUSTER_ID] =
@@ -1193,6 +1223,7 @@ static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
 	[NL80211_ATTR_NAN_MAX_CHAN_SWITCH_TIME] = { .type = NLA_U16 },
 	[NL80211_ATTR_NAN_PEER_MAPS] =
 		NLA_POLICY_NESTED_ARRAY(nl80211_nan_peer_map_policy),
+	[NL80211_ATTR_NAN_NDP] = NLA_POLICY_NESTED(nl80211_nan_ndp_policy),
 	[NL80211_ATTR_NPCA_PRIMARY_FREQ] = { .type = NLA_U32 },
 	[NL80211_ATTR_NPCA_PUNCT_BITMAP] =
 		NLA_POLICY_FULL_RANGE(NLA_U32, &nl80211_punct_bitmap_range),
@@ -1334,6 +1365,24 @@ nl80211_nan_func_policy[NL80211_NAN_FUNC_ATTR_MAX + 1] = {
 	[NL80211_NAN_FUNC_TX_MATCH_FILTER] = { .type = NLA_NESTED },
 	[NL80211_NAN_FUNC_INSTANCE_ID] = { .type = NLA_U8 },
 	[NL80211_NAN_FUNC_TERM_REASON] = { .type = NLA_U8 },
+	[NL80211_NAN_FUNC_SDEA_CTRL] = { .type = NLA_U16 },
+	[NL80211_NAN_FUNC_PAIRING_BOOTSTRAP_METHODS] = { .type = NLA_U16 },
+	[NL80211_NAN_FUNC_CSIDS] = { .type = NLA_BINARY,
+				     .len = U8_MAX * sizeof(u32) },
+	[NL80211_NAN_FUNC_ND_PMK] =
+		NLA_POLICY_EXACT_LEN(NL80211_NAN_NDP_PMK_LEN),
+	[NL80211_NAN_FUNC_PAIRING_SETUP] = { .type = NLA_FLAG },
+	[NL80211_NAN_FUNC_PAIRING_CACHE] = { .type = NLA_FLAG },
+	[NL80211_NAN_FUNC_PAIRING_VERIFY] = { .type = NLA_FLAG },
+	[NL80211_NAN_FUNC_RANGING_INTERVAL] = { .type = NLA_U32 },
+	[NL80211_NAN_FUNC_INGRESS_DISTANCE] = { .type = NLA_U32 },
+	[NL80211_NAN_FUNC_EGRESS_DISTANCE] = { .type = NLA_U32 },
+	[NL80211_NAN_FUNC_FTMS_PER_BURST] = { .type = NLA_U8 },
+	[NL80211_NAN_FUNC_PREAMBLE] =
+		NLA_POLICY_RANGE(NLA_U32, NL80211_PREAMBLE_LEGACY,
+				 NL80211_PREAMBLE_HE),
+	[NL80211_NAN_FUNC_CHAN] = { .type = NLA_NESTED },
+	[NL80211_NAN_FUNC_RANGE_REPORT] = { .type = NLA_FLAG },
 };
 
 /* policy for Service Response Filter attributes */
@@ -2730,7 +2779,8 @@ nl80211_send_pmsr_ftm_capa(const struct cfg80211_pmsr_capabilities *cap,
 			cap->ftm.min_allowed_ranging_interval_ntb))
 		return -ENOBUFS;
 
-	if (cap->ftm.type.infra_support || cap->ftm.type.pd_support) {
+	if (cap->ftm.type.infra_support || cap->ftm.type.pd_support ||
+	    cap->ftm.type.nan_support) {
 		struct nlattr *pd_caps;
 
 		pd_caps = nla_nest_start_noflag(msg,
@@ -2746,6 +2796,10 @@ nl80211_send_pmsr_ftm_capa(const struct cfg80211_pmsr_capabilities *cap,
 		    nla_put_flag(msg, NL80211_PMSR_FTM_TYPE_CAPA_ATTR_PD_SUPPORT))
 			return -ENOBUFS;
 
+		if (cap->ftm.type.nan_support &&
+		    nla_put_flag(msg, NL80211_PMSR_FTM_TYPE_CAPA_ATTR_NAN_SUPPORT))
+			return -ENOBUFS;
+
 		nla_nest_end(msg, pd_caps);
 	}
 
@@ -3138,6 +3192,14 @@ static int nl80211_put_nan_capa(struct wiphy *wiphy, struct sk_buff *msg)
 	    nla_put_flag(msg, NL80211_NAN_CAPA_INSTANT_COMM))
 		goto fail;
 
+	if ((wiphy->nan_capa.flags & WIPHY_NAN_FLAGS_OFFLOAD_RANGING) &&
+	    nla_put_flag(msg, NL80211_NAN_CAPA_OFFLOAD_RANGING))
+		goto fail;
+
+	if ((wiphy->nan_capa.flags & WIPHY_NAN_FLAGS_OFFLOAD_NDP) &&
+	    nla_put_flag(msg, NL80211_NAN_CAPA_OFFLOAD_NDP))
+		goto fail;
+
 	if (nla_put_u8(msg, NL80211_NAN_CAPA_OP_MODE,
 		       wiphy->nan_capa.op_mode) ||
 	    nla_put_u8(msg, NL80211_NAN_CAPA_NUM_ANTENNAS,
@@ -17383,6 +17445,12 @@ static int nl80211_nan_add_func(struct sk_buff *skb,
 	if (!wdev_running(wdev))
 		return -ENOTCONN;
 
+	if (wdev->wiphy->nan_capa.flags & WIPHY_NAN_FLAGS_USERSPACE_DE) {
+		NL_SET_ERR_MSG(info->extack,
+			       "NAN Discovery Engine is in userspace");
+		return -EOPNOTSUPP;
+	}
+
 	if (!info->attrs[NL80211_ATTR_NAN_FUNC])
 		return -EINVAL;
 
@@ -17558,6 +17626,189 @@ static int nl80211_nan_add_func(struct sk_buff *skb,
 			goto out;
 	}
 
+	if (tb[NL80211_NAN_FUNC_SDEA_CTRL]) {
+		u16 sdea = nla_get_u16(tb[NL80211_NAN_FUNC_SDEA_CTRL]);
+
+		if ((sdea & NL80211_NAN_FUNC_SDEA_CTRL_SECURITY_REQUIRED) &&
+		    !(sdea & NL80211_NAN_FUNC_SDEA_CTRL_DATAPATH_REQUIRED)) {
+			NL_SET_ERR_MSG(info->extack,
+				       "SDEA Security Required requires Data Path Required");
+			err = -EINVAL;
+			goto out;
+		}
+
+		if ((sdea & (NL80211_NAN_FUNC_SDEA_CTRL_SECURITY_REQUIRED |
+			     NL80211_NAN_FUNC_SDEA_CTRL_GTK_REQUIRED)) &&
+		    !wiphy_ext_feature_isset(wdev->wiphy,
+					     NL80211_EXT_FEATURE_SECURE_NAN)) {
+			NL_SET_ERR_MSG(info->extack,
+				       "SDEA security bits require SECURE_NAN");
+			err = -EOPNOTSUPP;
+			goto out;
+		}
+
+		if ((sdea & NL80211_NAN_FUNC_SDEA_CTRL_DATAPATH_REQUIRED) &&
+		    !(wdev->wiphy->nan_capa.flags &
+		      WIPHY_NAN_FLAGS_OFFLOAD_NDP)) {
+			NL_SET_ERR_MSG(info->extack,
+				       "SDEA Data Path bit requires OFFLOAD_NDP");
+			err = -EOPNOTSUPP;
+			goto out;
+		}
+		func->sdea_ctrl = sdea;
+	}
+
+	if (tb[NL80211_NAN_FUNC_PAIRING_BOOTSTRAP_METHODS] ||
+	    tb[NL80211_NAN_FUNC_PAIRING_SETUP] ||
+	    tb[NL80211_NAN_FUNC_PAIRING_CACHE] ||
+	    tb[NL80211_NAN_FUNC_PAIRING_VERIFY] ||
+	    tb[NL80211_NAN_FUNC_CSIDS] ||
+	    tb[NL80211_NAN_FUNC_ND_PMK]) {
+		if (!wiphy_ext_feature_isset(wdev->wiphy,
+					     NL80211_EXT_FEATURE_SECURE_NAN)) {
+			NL_SET_ERR_MSG(info->extack,
+				       "Security attributes require SECURE_NAN");
+			err = -EINVAL;
+			goto out;
+		}
+
+		if (tb[NL80211_NAN_FUNC_PAIRING_BOOTSTRAP_METHODS])
+			func->pairing_bootstrap_methods =
+				nla_get_u16(tb[NL80211_NAN_FUNC_PAIRING_BOOTSTRAP_METHODS]);
+
+		func->pairing_setup =
+			nla_get_flag(tb[NL80211_NAN_FUNC_PAIRING_SETUP]);
+		func->pairing_cache =
+			nla_get_flag(tb[NL80211_NAN_FUNC_PAIRING_CACHE]);
+		func->pairing_verify =
+			nla_get_flag(tb[NL80211_NAN_FUNC_PAIRING_VERIFY]);
+
+		if (tb[NL80211_NAN_FUNC_CSIDS]) {
+			int len = nla_len(tb[NL80211_NAN_FUNC_CSIDS]);
+			int n = len / sizeof(u32);
+
+			if (len % sizeof(u32)) {
+				NL_SET_ERR_MSG_ATTR(info->extack,
+						    tb[NL80211_NAN_FUNC_CSIDS],
+						    "CSIDs must be an array of u32 values");
+				err = -EINVAL;
+				goto out;
+			}
+
+			if (n > 0) {
+				func->csids =
+					kmemdup(nla_data(tb[NL80211_NAN_FUNC_CSIDS]),
+						len, GFP_KERNEL);
+				if (!func->csids) {
+					err = -ENOMEM;
+					goto out;
+				}
+				func->num_csids = n;
+			}
+		}
+
+		if (tb[NL80211_NAN_FUNC_ND_PMK]) {
+			memcpy(func->nd_pmk,
+			       nla_data(tb[NL80211_NAN_FUNC_ND_PMK]),
+			       sizeof(func->nd_pmk));
+			func->nd_pmk_set = true;
+		}
+	}
+
+	if (tb[NL80211_NAN_FUNC_RANGING_INTERVAL] ||
+	    tb[NL80211_NAN_FUNC_INGRESS_DISTANCE] ||
+	    tb[NL80211_NAN_FUNC_EGRESS_DISTANCE] ||
+	    tb[NL80211_NAN_FUNC_FTMS_PER_BURST] ||
+	    tb[NL80211_NAN_FUNC_PREAMBLE] ||
+	    tb[NL80211_NAN_FUNC_CHAN] ||
+	    tb[NL80211_NAN_FUNC_RANGE_REPORT]) {
+		const struct cfg80211_pmsr_capabilities *pmsr_capa =
+			rdev->wiphy.pmsr_capa;
+
+		/* SDEA Ranging Required bit must be set */
+		if (!(func->sdea_ctrl & NL80211_NAN_FUNC_SDEA_CTRL_RANGING_REQUIRED)) {
+			NL_SET_ERR_MSG(info->extack,
+				       "NAN ranging parameters require SDEA Ranging Required bit");
+			err = -EINVAL;
+			goto out;
+		}
+
+		if (!(wdev->wiphy->nan_capa.flags &
+		      WIPHY_NAN_FLAGS_OFFLOAD_RANGING) ||
+		    !pmsr_capa || !pmsr_capa->ftm.supported) {
+			NL_SET_ERR_MSG(info->extack,
+				       "NAN ranging not supported by device");
+			err = -EOPNOTSUPP;
+			goto out;
+		}
+
+		if (tb[NL80211_NAN_FUNC_RANGING_INTERVAL])
+			func->ranging_interval =
+				nla_get_u32(tb[NL80211_NAN_FUNC_RANGING_INTERVAL]);
+
+		if (tb[NL80211_NAN_FUNC_INGRESS_DISTANCE])
+			func->ingress_distance =
+				nla_get_u32(tb[NL80211_NAN_FUNC_INGRESS_DISTANCE]);
+
+		if (tb[NL80211_NAN_FUNC_EGRESS_DISTANCE])
+			func->egress_distance =
+				nla_get_u32(tb[NL80211_NAN_FUNC_EGRESS_DISTANCE]);
+
+		if (tb[NL80211_NAN_FUNC_FTMS_PER_BURST]) {
+			func->ftms_per_burst =
+				nla_get_u8(tb[NL80211_NAN_FUNC_FTMS_PER_BURST]);
+			if (func->ftms_per_burst > 31) {
+				NL_SET_ERR_MSG_ATTR(info->extack,
+						    tb[NL80211_NAN_FUNC_FTMS_PER_BURST],
+						    "NAN FTMs per burst exceeds limit of 31");
+				err = -EINVAL;
+				goto out;
+			}
+			if (pmsr_capa->ftm.max_ftms_per_burst &&
+			    func->ftms_per_burst > pmsr_capa->ftm.max_ftms_per_burst) {
+				NL_SET_ERR_MSG_ATTR(info->extack,
+						    tb[NL80211_NAN_FUNC_FTMS_PER_BURST],
+						    "NAN FTMs per burst exceeds device limit");
+				err = -EINVAL;
+				goto out;
+			}
+		}
+
+		if (tb[NL80211_NAN_FUNC_PREAMBLE]) {
+			func->preamble =
+				nla_get_u32(tb[NL80211_NAN_FUNC_PREAMBLE]);
+			if (!(pmsr_capa->ftm.preambles & BIT(func->preamble))) {
+				NL_SET_ERR_MSG_ATTR(info->extack,
+						    tb[NL80211_NAN_FUNC_PREAMBLE],
+						    "NAN ranging: unsupported preamble");
+				err = -EINVAL;
+				goto out;
+			}
+		}
+
+		if (tb[NL80211_NAN_FUNC_CHAN]) {
+			/* Reuse info->attrs for chandef parsing; the original contents
+			 * are no longer needed.
+			 */
+			memset(info->attrs, 0,
+			       sizeof(*info->attrs) * (NL80211_ATTR_MAX + 1));
+			err = nla_parse_nested(info->attrs, NL80211_ATTR_MAX,
+					       tb[NL80211_NAN_FUNC_CHAN],
+					       nl80211_policy, info->extack);
+			if (err)
+				goto out;
+			err = nl80211_parse_chandef(rdev, info->extack,
+						    info->attrs,
+						    &func->chandef, false);
+			if (err)
+				goto out;
+			func->chandef_valid = true;
+		}
+
+		func->range_report =
+			nla_get_flag(tb[NL80211_NAN_FUNC_RANGE_REPORT]);
+	}
+
 	msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
 	if (!msg) {
 		err = -ENOMEM;
@@ -17757,6 +18008,58 @@ void cfg80211_nan_match(struct wireless_dev *wdev,
 		goto nla_put_failure;
 
 	nla_nest_end(msg, peer_func_attr);
+
+	if (match->sdea_ctrl &&
+	    nla_put_u16(msg, NL80211_NAN_MATCH_SDEA_CTRL, match->sdea_ctrl))
+		goto nla_put_failure;
+
+	if (match->pairing_bootstrap_methods &&
+	    nla_put_u16(msg, NL80211_NAN_MATCH_BOOTSTRAP_METHODS,
+			match->pairing_bootstrap_methods))
+		goto nla_put_failure;
+
+	if (match->csids && match->num_csids &&
+	    nla_put(msg, NL80211_NAN_MATCH_CIPHER_SUITES,
+		    match->num_csids * sizeof(u32),
+		    match->csids))
+		goto nla_put_failure;
+
+	if (match->pairing_setup &&
+	    nla_put_flag(msg, NL80211_NAN_MATCH_PAIRING_SETUP))
+		goto nla_put_failure;
+
+	if (match->pairing_cache &&
+	    nla_put_flag(msg, NL80211_NAN_MATCH_PAIRING_CACHE))
+		goto nla_put_failure;
+
+	if (match->pairing_verify &&
+	    nla_put_flag(msg, NL80211_NAN_MATCH_PAIRING_VERIFY))
+		goto nla_put_failure;
+
+	if (match->extra_info && match->extra_info_len &&
+	    nla_put(msg, NL80211_NAN_MATCH_EXTRA_INFO, match->extra_info_len,
+		    match->extra_info))
+		goto nla_put_failure;
+
+	if (match->ies && match->ies_len &&
+	    nla_put(msg, NL80211_NAN_MATCH_IES, match->ies_len, match->ies))
+		goto nla_put_failure;
+
+	if (match->rssi_valid &&
+	    nla_put_s32(msg, NL80211_NAN_MATCH_RSSI, match->rssi))
+		goto nla_put_failure;
+
+	/* report ranging info only if ranging was indicated */
+	if (match->ranging_indication) {
+		if (nla_put_u8(msg, NL80211_NAN_MATCH_RANGING_INDICATION,
+			       match->ranging_indication))
+			goto nla_put_failure;
+
+		if (nla_put_s32(msg, NL80211_NAN_MATCH_RANGING_MEASUREMENT,
+				match->ranging_measurement))
+			goto nla_put_failure;
+	}
+
 	nla_nest_end(msg, match_attr);
 	genlmsg_end(msg, hdr);
 
@@ -18198,6 +18501,507 @@ static int nl80211_nan_set_peer_sched(struct sk_buff *skb,
 	return rdev_nan_set_peer_sched(rdev, wdev, &sched);
 }
 
+static int nl80211_nan_ndp_initiate(struct sk_buff *skb,
+				    struct genl_info *info)
+{
+	struct cfg80211_registered_device *rdev = info->user_ptr[0];
+	struct wireless_dev *wdev = info->user_ptr[1];
+	struct nlattr *tb[NL80211_NAN_NDP_ATTR_MAX + 1];
+	struct cfg80211_nan_ndp_initiate params = {};
+	int err;
+
+	if (wdev->iftype != NL80211_IFTYPE_NAN) {
+		NL_SET_ERR_MSG(info->extack,
+			       "NDP initiate requires NAN interface");
+		return -EOPNOTSUPP;
+	}
+
+	if (!(rdev->wiphy.nan_capa.flags & WIPHY_NAN_FLAGS_OFFLOAD_NDP)) {
+		NL_SET_ERR_MSG(info->extack,
+			       "NAN NDP offload not supported by driver");
+		return -EOPNOTSUPP;
+	}
+
+	if (!info->attrs[NL80211_ATTR_MAC] ||
+	    !info->attrs[NL80211_ATTR_NAN_NDP]) {
+		NL_SET_ERR_MSG(info->extack,
+			       "NDP initiate requires peer NMI and NDP params");
+		return -EINVAL;
+	}
+
+	err = nla_parse_nested(tb, NL80211_NAN_NDP_ATTR_MAX,
+			       info->attrs[NL80211_ATTR_NAN_NDP],
+			       nl80211_nan_ndp_policy,
+			       info->extack);
+	if (err)
+		return err;
+
+	if (!tb[NL80211_NAN_NDP_ATTR_INIT_NDI] ||
+	    !tb[NL80211_NAN_NDP_ATTR_PUBLISH_ID] ||
+	    !tb[NL80211_NAN_NDP_ATTR_SERVICE_ID]) {
+		NL_SET_ERR_MSG(info->extack,
+			       "NDP initiate requires INIT_NDI, PUBLISH_ID and SERVICE_ID");
+		return -EINVAL;
+	}
+
+	params.peer_nmi = nla_data(info->attrs[NL80211_ATTR_MAC]);
+	params.init_ndi = nla_data(tb[NL80211_NAN_NDP_ATTR_INIT_NDI]);
+	params.publish_id = nla_get_u8(tb[NL80211_NAN_NDP_ATTR_PUBLISH_ID]);
+	memcpy(params.service_id,
+	       nla_data(tb[NL80211_NAN_NDP_ATTR_SERVICE_ID]),
+	       NL80211_NAN_FUNC_SERVICE_ID_LEN);
+
+	if (tb[NL80211_NAN_NDP_ATTR_SSI]) {
+		params.ssi = nla_data(tb[NL80211_NAN_NDP_ATTR_SSI]);
+		params.ssi_len = nla_len(tb[NL80211_NAN_NDP_ATTR_SSI]);
+	}
+
+	if (tb[NL80211_NAN_NDP_ATTR_CIPHER_SUITE])
+		params.cipher_suite =
+			nla_get_u32(tb[NL80211_NAN_NDP_ATTR_CIPHER_SUITE]);
+
+	if (tb[NL80211_NAN_NDP_ATTR_PMK]) {
+		if (!wiphy_ext_feature_isset(&rdev->wiphy,
+					     NL80211_EXT_FEATURE_SECURE_NAN)) {
+			NL_SET_ERR_MSG_ATTR(info->extack,
+					    tb[NL80211_NAN_NDP_ATTR_PMK],
+					    "PMK requires SECURE_NAN feature");
+			return -EOPNOTSUPP;
+		}
+		memcpy(params.pmk,
+		       nla_data(tb[NL80211_NAN_NDP_ATTR_PMK]),
+		       NL80211_NAN_NDP_PMK_LEN);
+		params.pmk_set = true;
+	}
+
+	if (tb[NL80211_NAN_NDP_ATTR_PMKID]) {
+		if (!wiphy_ext_feature_isset(&rdev->wiphy,
+					     NL80211_EXT_FEATURE_SECURE_NAN)) {
+			NL_SET_ERR_MSG_ATTR(info->extack,
+					    tb[NL80211_NAN_NDP_ATTR_PMKID],
+					    "PMKID requires SECURE_NAN feature");
+			return -EOPNOTSUPP;
+		}
+		memcpy(params.pmkid,
+		       nla_data(tb[NL80211_NAN_NDP_ATTR_PMKID]),
+		       NL80211_NAN_NDP_PMKID_LEN);
+		params.pmkid_set = true;
+	}
+
+	if (tb[NL80211_NAN_NDP_ATTR_GTK_REQUIRED]) {
+		if (!wiphy_ext_feature_isset(&rdev->wiphy,
+					     NL80211_EXT_FEATURE_SECURE_NAN)) {
+			NL_SET_ERR_MSG_ATTR(info->extack,
+					    tb[NL80211_NAN_NDP_ATTR_GTK_REQUIRED],
+					    "GTK_REQUIRED requires SECURE_NAN feature");
+			return -EOPNOTSUPP;
+		}
+
+		if (!tb[NL80211_NAN_NDP_ATTR_GTK_CIPHER]) {
+			NL_SET_ERR_MSG_ATTR(info->extack,
+					    tb[NL80211_NAN_NDP_ATTR_GTK_REQUIRED],
+					    "GTK_CIPHER is required when GTK_REQUIRED is set");
+			return -EINVAL;
+		}
+
+		params.gtk_required = true;
+		params.gtk_cipher =
+			nla_get_u32(tb[NL80211_NAN_NDP_ATTR_GTK_CIPHER]);
+	} else if (tb[NL80211_NAN_NDP_ATTR_GTK_CIPHER]) {
+		NL_SET_ERR_MSG_ATTR(info->extack,
+				    tb[NL80211_NAN_NDP_ATTR_GTK_CIPHER],
+				    "GTK_CIPHER requires GTK_REQUIRED");
+		return -EINVAL;
+	}
+
+	if (tb[NL80211_NAN_NDP_ATTR_IPV6_INTF_ID]) {
+		memcpy(params.ipv6_intf_id,
+		       nla_data(tb[NL80211_NAN_NDP_ATTR_IPV6_INTF_ID]),
+		       NL80211_NAN_NDP_IPV6_INTF_ID_LEN);
+		params.ipv6_intf_id_set = true;
+	}
+
+	params.ndpe = nla_get_flag(tb[NL80211_NAN_NDP_ATTR_NDPE]);
+
+	return rdev_nan_ndp_initiate(rdev, wdev, &params);
+}
+
+static int nl80211_nan_ndp_respond(struct sk_buff *skb,
+				   struct genl_info *info)
+{
+	struct cfg80211_registered_device *rdev = info->user_ptr[0];
+	struct wireless_dev *wdev = info->user_ptr[1];
+	struct nlattr *tb[NL80211_NAN_NDP_ATTR_MAX + 1];
+	struct cfg80211_nan_ndp_respond params = {};
+	int err;
+
+	if (wdev->iftype != NL80211_IFTYPE_NAN) {
+		NL_SET_ERR_MSG(info->extack,
+			       "NDP respond requires NAN interface");
+		return -EOPNOTSUPP;
+	}
+
+	if (!(rdev->wiphy.nan_capa.flags & WIPHY_NAN_FLAGS_OFFLOAD_NDP)) {
+		NL_SET_ERR_MSG(info->extack,
+			       "NAN NDP offload not supported by driver");
+		return -EOPNOTSUPP;
+	}
+
+	if (!info->attrs[NL80211_ATTR_MAC] ||
+	    !info->attrs[NL80211_ATTR_NAN_NDP]) {
+		NL_SET_ERR_MSG(info->extack,
+			       "NDP respond requires peer NMI and NDP params");
+		return -EINVAL;
+	}
+
+	err = nla_parse_nested(tb, NL80211_NAN_NDP_ATTR_MAX,
+			       info->attrs[NL80211_ATTR_NAN_NDP],
+			       nl80211_nan_ndp_policy,
+			       info->extack);
+	if (err)
+		return err;
+
+	if (!tb[NL80211_NAN_NDP_ATTR_ID] ||
+	    !tb[NL80211_NAN_NDP_ATTR_INIT_NDI]) {
+		NL_SET_ERR_MSG(info->extack,
+			       "NDP respond requires NDP ID and INIT_NDI");
+		return -EINVAL;
+	}
+
+	params.peer_nmi = nla_data(info->attrs[NL80211_ATTR_MAC]);
+	params.ndp_id = nla_get_u8(tb[NL80211_NAN_NDP_ATTR_ID]);
+	params.init_ndi = nla_data(tb[NL80211_NAN_NDP_ATTR_INIT_NDI]);
+	params.accept = nla_get_flag(tb[NL80211_NAN_NDP_ATTR_ACCEPT]);
+
+	if (params.accept) {
+		if (!tb[NL80211_NAN_NDP_ATTR_RESP_NDI]) {
+			NL_SET_ERR_MSG(info->extack,
+				       "NDP accept requires RESP_NDI");
+			return -EINVAL;
+		}
+		params.resp_ndi = nla_data(tb[NL80211_NAN_NDP_ATTR_RESP_NDI]);
+	} else {
+		if (tb[NL80211_NAN_NDP_ATTR_REASON])
+			params.reason =
+				nla_get_u8(tb[NL80211_NAN_NDP_ATTR_REASON]);
+	}
+
+	if (tb[NL80211_NAN_NDP_ATTR_SSI]) {
+		params.ssi = nla_data(tb[NL80211_NAN_NDP_ATTR_SSI]);
+		params.ssi_len = nla_len(tb[NL80211_NAN_NDP_ATTR_SSI]);
+	}
+
+	if (tb[NL80211_NAN_NDP_ATTR_CIPHER_SUITE])
+		params.cipher_suite =
+			nla_get_u32(tb[NL80211_NAN_NDP_ATTR_CIPHER_SUITE]);
+
+	if (params.accept && tb[NL80211_NAN_NDP_ATTR_PMK]) {
+		if (!wiphy_ext_feature_isset(&rdev->wiphy,
+					     NL80211_EXT_FEATURE_SECURE_NAN)) {
+			NL_SET_ERR_MSG_ATTR(info->extack,
+					    tb[NL80211_NAN_NDP_ATTR_PMK],
+					    "PMK requires SECURE_NAN feature");
+			return -EOPNOTSUPP;
+		}
+		memcpy(params.pmk,
+		       nla_data(tb[NL80211_NAN_NDP_ATTR_PMK]),
+		       NL80211_NAN_NDP_PMK_LEN);
+		params.pmk_set = true;
+	}
+
+	if (params.accept && tb[NL80211_NAN_NDP_ATTR_GTK_REQUIRED]) {
+		if (!wiphy_ext_feature_isset(&rdev->wiphy,
+					     NL80211_EXT_FEATURE_SECURE_NAN)) {
+			NL_SET_ERR_MSG_ATTR(info->extack,
+					    tb[NL80211_NAN_NDP_ATTR_GTK_REQUIRED],
+					    "GTK_REQUIRED requires SECURE_NAN feature");
+			return -EOPNOTSUPP;
+		}
+
+		if (!tb[NL80211_NAN_NDP_ATTR_GTK_CIPHER]) {
+			NL_SET_ERR_MSG_ATTR(info->extack,
+					    tb[NL80211_NAN_NDP_ATTR_GTK_REQUIRED],
+					    "GTK_CIPHER is required when GTK_REQUIRED is set");
+			return -EINVAL;
+		}
+
+		params.gtk_required = true;
+		params.gtk_cipher =
+			nla_get_u32(tb[NL80211_NAN_NDP_ATTR_GTK_CIPHER]);
+	} else if (params.accept && tb[NL80211_NAN_NDP_ATTR_GTK_CIPHER]) {
+		NL_SET_ERR_MSG_ATTR(info->extack,
+				    tb[NL80211_NAN_NDP_ATTR_GTK_CIPHER],
+				    "GTK_CIPHER requires GTK_REQUIRED");
+		return -EINVAL;
+	}
+
+	if (tb[NL80211_NAN_NDP_ATTR_IPV6_INTF_ID]) {
+		memcpy(params.ipv6_intf_id,
+		       nla_data(tb[NL80211_NAN_NDP_ATTR_IPV6_INTF_ID]),
+		       NL80211_NAN_NDP_IPV6_INTF_ID_LEN);
+		params.ipv6_intf_id_set = true;
+	}
+
+	params.ndpe = nla_get_flag(tb[NL80211_NAN_NDP_ATTR_NDPE]);
+
+	return rdev_nan_ndp_respond(rdev, wdev, &params);
+}
+
+static int nl80211_nan_ndp_terminate(struct sk_buff *skb,
+				     struct genl_info *info)
+{
+	struct cfg80211_registered_device *rdev = info->user_ptr[0];
+	struct wireless_dev *wdev = info->user_ptr[1];
+	struct nlattr *tb[NL80211_NAN_NDP_ATTR_MAX + 1];
+	struct cfg80211_nan_ndp_terminate params = {};
+	int err;
+
+	if (wdev->iftype != NL80211_IFTYPE_NAN) {
+		NL_SET_ERR_MSG(info->extack,
+			       "NDP terminate requires NAN interface");
+		return -EOPNOTSUPP;
+	}
+
+	if (!(rdev->wiphy.nan_capa.flags & WIPHY_NAN_FLAGS_OFFLOAD_NDP)) {
+		NL_SET_ERR_MSG(info->extack,
+			       "NAN NDP offload not supported by driver");
+		return -EOPNOTSUPP;
+	}
+
+	if (!info->attrs[NL80211_ATTR_MAC] ||
+	    !info->attrs[NL80211_ATTR_NAN_NDP]) {
+		NL_SET_ERR_MSG(info->extack,
+			       "NDP terminate requires peer NMI and NDP params");
+		return -EINVAL;
+	}
+
+	err = nla_parse_nested(tb, NL80211_NAN_NDP_ATTR_MAX,
+			       info->attrs[NL80211_ATTR_NAN_NDP],
+			       nl80211_nan_ndp_policy,
+			       info->extack);
+	if (err)
+		return err;
+
+	if (!tb[NL80211_NAN_NDP_ATTR_ID] ||
+	    !tb[NL80211_NAN_NDP_ATTR_INIT_NDI]) {
+		NL_SET_ERR_MSG(info->extack,
+			       "NDP terminate requires NDP ID and INIT_NDI");
+		return -EINVAL;
+	}
+
+	params.peer_nmi = nla_data(info->attrs[NL80211_ATTR_MAC]);
+	params.ndp_id = nla_get_u8(tb[NL80211_NAN_NDP_ATTR_ID]);
+	params.init_ndi = nla_data(tb[NL80211_NAN_NDP_ATTR_INIT_NDI]);
+
+	if (tb[NL80211_NAN_NDP_ATTR_REASON])
+		params.reason = nla_get_u8(tb[NL80211_NAN_NDP_ATTR_REASON]);
+
+	return rdev_nan_ndp_terminate(rdev, wdev, &params);
+}
+
+void cfg80211_nan_ndp_request(struct wireless_dev *wdev,
+			      struct cfg80211_nan_ndp_request_params *params,
+			      gfp_t gfp)
+{
+	struct wiphy *wiphy = wdev->wiphy;
+	struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
+	struct nlattr *ndp_attr;
+	struct sk_buff *msg;
+	void *hdr;
+
+	if (WARN_ON(!(wiphy->nan_capa.flags & WIPHY_NAN_FLAGS_OFFLOAD_NDP)))
+		return;
+
+	if (!wdev->owner_nlportid)
+		return;
+
+	msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
+	if (!msg)
+		return;
+
+	hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_NAN_NDP_REQUEST);
+	if (!hdr)
+		goto nla_put_failure;
+
+	if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
+	    nla_put_u64_64bit(msg, NL80211_ATTR_WDEV, wdev_id(wdev),
+			      NL80211_ATTR_PAD) ||
+	    nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, params->peer_nmi))
+		goto nla_put_failure;
+
+	ndp_attr = nla_nest_start(msg, NL80211_ATTR_NAN_NDP);
+	if (!ndp_attr)
+		goto nla_put_failure;
+
+	if (nla_put_u8(msg, NL80211_NAN_NDP_ATTR_ID, params->ndp_id) ||
+	    nla_put(msg, NL80211_NAN_NDP_ATTR_INIT_NDI, ETH_ALEN,
+		    params->init_ndi) ||
+	    nla_put_u8(msg, NL80211_NAN_NDP_ATTR_PUBLISH_ID,
+		       params->publish_id))
+		goto nla_put_failure;
+
+	if (params->ssi && params->ssi_len &&
+	    nla_put(msg, NL80211_NAN_NDP_ATTR_SSI, params->ssi_len,
+		    params->ssi))
+		goto nla_put_failure;
+
+	if (params->cipher_suite &&
+	    nla_put_u32(msg, NL80211_NAN_NDP_ATTR_CIPHER_SUITE,
+			params->cipher_suite))
+		goto nla_put_failure;
+
+	if (params->pmkid_set &&
+	    nla_put(msg, NL80211_NAN_NDP_ATTR_PMKID,
+		    NL80211_NAN_NDP_PMKID_LEN, params->pmkid))
+		goto nla_put_failure;
+
+	if (params->gtk_required &&
+	    nla_put_flag(msg, NL80211_NAN_NDP_ATTR_GTK_REQUIRED))
+		goto nla_put_failure;
+
+	if (params->ipv6_intf_id_set &&
+	    nla_put(msg, NL80211_NAN_NDP_ATTR_IPV6_INTF_ID,
+		    NL80211_NAN_NDP_IPV6_INTF_ID_LEN, params->ipv6_intf_id))
+		goto nla_put_failure;
+
+	if (params->ndpe &&
+	    nla_put_flag(msg, NL80211_NAN_NDP_ATTR_NDPE))
+		goto nla_put_failure;
+
+	nla_nest_end(msg, ndp_attr);
+	genlmsg_end(msg, hdr);
+	genlmsg_unicast(wiphy_net(wiphy), msg, wdev->owner_nlportid);
+	return;
+
+nla_put_failure:
+	nlmsg_free(msg);
+}
+EXPORT_SYMBOL(cfg80211_nan_ndp_request);
+
+void cfg80211_nan_ndp_confirm(struct wireless_dev *wdev,
+			      struct cfg80211_nan_ndp_confirm_params *params,
+			      gfp_t gfp)
+{
+	struct wiphy *wiphy = wdev->wiphy;
+	struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
+	struct nlattr *ndp_attr;
+	struct sk_buff *msg;
+	void *hdr;
+
+	if (WARN_ON(!(wiphy->nan_capa.flags & WIPHY_NAN_FLAGS_OFFLOAD_NDP)))
+		return;
+
+	if (!wdev->owner_nlportid)
+		return;
+
+	if (WARN_ON_ONCE(params->accepted && !params->resp_ndi))
+		return;
+
+	msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
+	if (!msg)
+		return;
+
+	hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_NAN_NDP_CONFIRM);
+	if (!hdr)
+		goto nla_put_failure;
+
+	if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
+	    nla_put_u64_64bit(msg, NL80211_ATTR_WDEV, wdev_id(wdev),
+			      NL80211_ATTR_PAD) ||
+	    nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, params->peer_nmi))
+		goto nla_put_failure;
+
+	ndp_attr = nla_nest_start(msg, NL80211_ATTR_NAN_NDP);
+	if (!ndp_attr)
+		goto nla_put_failure;
+
+	if (nla_put_u8(msg, NL80211_NAN_NDP_ATTR_ID, params->ndp_id) ||
+	    nla_put(msg, NL80211_NAN_NDP_ATTR_INIT_NDI, ETH_ALEN,
+		    params->init_ndi) ||
+	    nla_put_u8(msg, NL80211_NAN_NDP_ATTR_STATUS,
+		       params->accepted ? NL80211_NAN_NDP_STATUS_ACCEPTED :
+					   NL80211_NAN_NDP_STATUS_REJECTED))
+		goto nla_put_failure;
+
+	if (params->accepted && params->resp_ndi &&
+	    nla_put(msg, NL80211_NAN_NDP_ATTR_RESP_NDI, ETH_ALEN,
+		    params->resp_ndi))
+		goto nla_put_failure;
+
+	if (!params->accepted &&
+	    nla_put_u8(msg, NL80211_NAN_NDP_ATTR_REASON, params->reason))
+		goto nla_put_failure;
+
+	if (params->ssi && params->ssi_len &&
+	    nla_put(msg, NL80211_NAN_NDP_ATTR_SSI, params->ssi_len,
+		    params->ssi))
+		goto nla_put_failure;
+
+	if (params->ipv6_intf_id_set &&
+	    nla_put(msg, NL80211_NAN_NDP_ATTR_IPV6_INTF_ID,
+		    NL80211_NAN_NDP_IPV6_INTF_ID_LEN, params->ipv6_intf_id))
+		goto nla_put_failure;
+
+	nla_nest_end(msg, ndp_attr);
+	genlmsg_end(msg, hdr);
+	genlmsg_unicast(wiphy_net(wiphy), msg, wdev->owner_nlportid);
+	return;
+
+nla_put_failure:
+	nlmsg_free(msg);
+}
+EXPORT_SYMBOL(cfg80211_nan_ndp_confirm);
+
+void cfg80211_nan_ndp_terminated(struct wireless_dev *wdev,
+				 struct cfg80211_nan_ndp_terminated_params *params,
+				 gfp_t gfp)
+{
+	struct wiphy *wiphy = wdev->wiphy;
+	struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
+	struct nlattr *ndp_attr;
+	struct sk_buff *msg;
+	void *hdr;
+
+	if (WARN_ON(!(wiphy->nan_capa.flags & WIPHY_NAN_FLAGS_OFFLOAD_NDP)))
+		return;
+
+	if (!wdev->owner_nlportid)
+		return;
+
+	msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
+	if (!msg)
+		return;
+
+	hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_NAN_NDP_TERMINATED);
+	if (!hdr)
+		goto nla_put_failure;
+
+	if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
+	    nla_put_u64_64bit(msg, NL80211_ATTR_WDEV, wdev_id(wdev),
+			      NL80211_ATTR_PAD) ||
+	    nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, params->peer_nmi))
+		goto nla_put_failure;
+
+	ndp_attr = nla_nest_start(msg, NL80211_ATTR_NAN_NDP);
+	if (!ndp_attr)
+		goto nla_put_failure;
+
+	if (nla_put_u8(msg, NL80211_NAN_NDP_ATTR_ID, params->ndp_id) ||
+	    nla_put(msg, NL80211_NAN_NDP_ATTR_INIT_NDI, ETH_ALEN,
+		    params->init_ndi) ||
+	    nla_put_u8(msg, NL80211_NAN_NDP_ATTR_REASON, params->reason))
+		goto nla_put_failure;
+
+	nla_nest_end(msg, ndp_attr);
+	genlmsg_end(msg, hdr);
+	genlmsg_unicast(wiphy_net(wiphy), msg, wdev->owner_nlportid);
+	return;
+
+nla_put_failure:
+	nlmsg_free(msg);
+}
+EXPORT_SYMBOL(cfg80211_nan_ndp_terminated);
+
 static bool nl80211_nan_is_sched_empty(struct cfg80211_nan_local_sched *sched)
 {
 	if (!sched->n_channels)
@@ -21350,6 +22154,24 @@ static const struct genl_small_ops nl80211_small_ops[] = {
 		.internal_flags = IFLAGS(NL80211_FLAG_NEED_NETDEV_UP |
 					 NL80211_FLAG_NO_WIPHY_MTX),
 	},
+	{
+		.cmd = NL80211_CMD_NAN_NDP_INITIATE,
+		.doit = nl80211_nan_ndp_initiate,
+		.flags = GENL_ADMIN_PERM,
+		.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),
+	},
+	{
+		.cmd = NL80211_CMD_NAN_NDP_RESPOND,
+		.doit = nl80211_nan_ndp_respond,
+		.flags = GENL_ADMIN_PERM,
+		.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),
+	},
+	{
+		.cmd = NL80211_CMD_NAN_NDP_TERMINATE,
+		.doit = nl80211_nan_ndp_terminate,
+		.flags = GENL_ADMIN_PERM,
+		.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),
+	},
 };
 
 static struct genl_family nl80211_fam __ro_after_init = {
diff --git a/net/wireless/nl80211.h b/net/wireless/nl80211.h
index bdb065d140549..31a2c2eb62761 100644
--- a/net/wireless/nl80211.h
+++ b/net/wireless/nl80211.h
@@ -126,6 +126,9 @@ void cfg80211_free_coalesce(struct cfg80211_coalesce *coalesce);
 /* peer measurement */
 int nl80211_pmsr_start(struct sk_buff *skb, struct genl_info *info);
 
+extern const struct nla_policy
+nl80211_pmsr_ftm_req_attr_policy[NL80211_PMSR_FTM_REQ_ATTR_MAX + 1];
+
 void nl80211_mlo_reconf_add_done(struct net_device *dev,
 				 struct cfg80211_mlo_reconf_done_data *data);
 
diff --git a/net/wireless/pmsr.c b/net/wireless/pmsr.c
index 97449bcb9a225..bcf5390174e47 100644
--- a/net/wireless/pmsr.c
+++ b/net/wireless/pmsr.c
@@ -306,11 +306,108 @@ static int pmsr_parse_ftm(struct cfg80211_registered_device *rdev,
 	return 0;
 }
 
+static int pmsr_parse_ftm_nan(struct cfg80211_registered_device *rdev,
+			      struct nlattr *ftmreq,
+			      struct cfg80211_pmsr_request_peer *out,
+			      struct genl_info *info)
+{
+	const struct cfg80211_pmsr_capabilities *capa = rdev->wiphy.pmsr_capa;
+	struct nlattr *tb[NL80211_PMSR_FTM_REQ_ATTR_MAX + 1];
+	int err;
+
+	err = nla_parse_nested(tb, NL80211_PMSR_FTM_REQ_ATTR_MAX, ftmreq,
+			       nl80211_pmsr_ftm_req_attr_policy,
+			       info->extack);
+	if (err)
+		return err;
+
+	out->ftm.requested = true;
+
+	/* NAN ranging requires ASAP; reject if not set by userspace */
+	out->ftm.asap = nla_get_flag(tb[NL80211_PMSR_FTM_REQ_ATTR_ASAP]);
+	if (!out->ftm.asap) {
+		NL_SET_ERR_MSG(info->extack,
+			       "FTM: NAN ranging requires ASAP mode");
+		return -EINVAL;
+	}
+	if (!capa->ftm.asap) {
+		NL_SET_ERR_MSG(info->extack,
+			       "FTM: NAN ASAP mode is not supported by device");
+		return -EOPNOTSUPP;
+	}
+
+	/* NAN ranging requires single burst (num_bursts_exp must be 0) */
+	if (!tb[NL80211_PMSR_FTM_REQ_ATTR_NUM_BURSTS_EXP] ||
+	    nla_get_u8(tb[NL80211_PMSR_FTM_REQ_ATTR_NUM_BURSTS_EXP]) != 0) {
+		NL_SET_ERR_MSG(info->extack,
+			       "FTM: NAN ranging requires single burst");
+		return -EINVAL;
+	}
+
+	out->ftm.rsta = !!tb[NL80211_PMSR_FTM_REQ_ATTR_RSTA];
+	out->ftm.range_report =
+		!!tb[NL80211_PMSR_FTM_REQ_ATTR_RANGE_REPORT];
+	if (out->ftm.range_report && !out->ftm.rsta) {
+		NL_SET_ERR_MSG_ATTR(info->extack,
+				    tb[NL80211_PMSR_FTM_REQ_ATTR_RANGE_REPORT],
+				    "FTM: range report is valid only for NAN RSTA");
+		return -EINVAL;
+	}
+
+	if (tb[NL80211_PMSR_FTM_REQ_ATTR_PREAMBLE]) {
+		out->ftm.preamble =
+			nla_get_u32(tb[NL80211_PMSR_FTM_REQ_ATTR_PREAMBLE]);
+		if (!(capa->ftm.preambles & BIT(out->ftm.preamble))) {
+			NL_SET_ERR_MSG_ATTR(info->extack,
+					    tb[NL80211_PMSR_FTM_REQ_ATTR_PREAMBLE],
+					    "FTM: unsupported preamble for NAN ranging");
+			return -EINVAL;
+		}
+	}
+
+	if (tb[NL80211_PMSR_FTM_REQ_ATTR_FTMS_PER_BURST]) {
+		out->ftm.ftms_per_burst =
+			nla_get_u8(tb[NL80211_PMSR_FTM_REQ_ATTR_FTMS_PER_BURST]);
+		if (out->ftm.ftms_per_burst > 31) {
+			NL_SET_ERR_MSG_ATTR(info->extack,
+					    tb[NL80211_PMSR_FTM_REQ_ATTR_FTMS_PER_BURST],
+					    "FTM: NAN FTMs per burst exceeds limit of 31");
+			return -EINVAL;
+		}
+		if (capa->ftm.max_ftms_per_burst &&
+		    out->ftm.ftms_per_burst > capa->ftm.max_ftms_per_burst) {
+			NL_SET_ERR_MSG_ATTR(info->extack,
+					    tb[NL80211_PMSR_FTM_REQ_ATTR_FTMS_PER_BURST],
+					    "FTM: FTMs per burst exceeds device limit");
+			return -EINVAL;
+		}
+	}
+
+	if (tb[NL80211_PMSR_FTM_REQ_ATTR_BURST_DURATION])
+		out->ftm.burst_duration =
+			nla_get_u8(tb[NL80211_PMSR_FTM_REQ_ATTR_BURST_DURATION]);
+
+	if (tb[NL80211_PMSR_FTM_REQ_ATTR_MIN_DELTA_FTM])
+		out->ftm.min_delta_ftm =
+			nla_get_u8(tb[NL80211_PMSR_FTM_REQ_ATTR_MIN_DELTA_FTM]);
+
+	if (tb[NL80211_PMSR_FTM_REQ_ATTR_INGRESS])
+		out->ftm.ingress_distance =
+			nla_get_u64(tb[NL80211_PMSR_FTM_REQ_ATTR_INGRESS]);
+
+	if (tb[NL80211_PMSR_FTM_REQ_ATTR_EGRESS])
+		out->ftm.egress_distance =
+			nla_get_u64(tb[NL80211_PMSR_FTM_REQ_ATTR_EGRESS]);
+
+	return 0;
+}
+
 static int pmsr_parse_peer(struct cfg80211_registered_device *rdev,
 			   struct nlattr *peer,
 			   struct cfg80211_pmsr_request_peer *out,
 			   struct genl_info *info)
 {
+	struct wireless_dev *wdev = info->user_ptr[1];
 	struct nlattr *tb[NL80211_PMSR_PEER_ATTR_MAX + 1];
 	struct nlattr *req[NL80211_PMSR_REQ_ATTR_MAX + 1];
 	bool have_measurement_type = false;
@@ -344,6 +441,22 @@ static int pmsr_parse_peer(struct cfg80211_registered_device *rdev,
 				    "FTM: PD request type not supported by device");
 		return -EINVAL;
 	}
+
+	if (out->ftm.request_type == NL80211_PMSR_FTM_REQ_TYPE_NAN) {
+		if (!rdev->wiphy.pmsr_capa->ftm.type.nan_support) {
+			NL_SET_ERR_MSG_ATTR(info->extack,
+					    tb[NL80211_PMSR_PEER_ATTR_REQ_TYPE],
+					    "FTM: NAN ranging not supported by device");
+			return -EOPNOTSUPP;
+		}
+		if (wdev->iftype != NL80211_IFTYPE_NAN) {
+			NL_SET_ERR_MSG_ATTR(info->extack,
+					    tb[NL80211_PMSR_PEER_ATTR_REQ_TYPE],
+					    "FTM: NAN ranging requires a NAN interface");
+			return -EOPNOTSUPP;
+		}
+	}
+
 	/* reuse info->attrs */
 	memset(info->attrs, 0, sizeof(*info->attrs) * (NL80211_ATTR_MAX + 1));
 	err = nla_parse_nested_deprecated(info->attrs, NL80211_ATTR_MAX,
@@ -390,7 +503,12 @@ static int pmsr_parse_peer(struct cfg80211_registered_device *rdev,
 
 		switch (nla_type(treq)) {
 		case NL80211_PMSR_TYPE_FTM:
-			err = pmsr_parse_ftm(rdev, treq, out, info);
+			if (out->ftm.request_type ==
+			    NL80211_PMSR_FTM_REQ_TYPE_NAN)
+				err = pmsr_parse_ftm_nan(rdev, treq,
+							 out, info);
+			else
+				err = pmsr_parse_ftm(rdev, treq, out, info);
 			break;
 		default:
 			NL_SET_ERR_MSG_ATTR(info->extack, treq,
diff --git a/net/wireless/rdev-ops.h b/net/wireless/rdev-ops.h
index ae15cec9bf8b7..e4b57983d5913 100644
--- a/net/wireless/rdev-ops.h
+++ b/net/wireless/rdev-ops.h
@@ -1183,6 +1183,54 @@ static inline void rdev_stop_pd(struct cfg80211_registered_device *rdev,
 	trace_rdev_return_void(&rdev->wiphy);
 }
 
+static inline int
+rdev_nan_ndp_initiate(struct cfg80211_registered_device *rdev,
+		      struct wireless_dev *wdev,
+		      struct cfg80211_nan_ndp_initiate *params)
+{
+	int ret;
+
+	if (!rdev->ops->nan_ndp_initiate)
+		return -EOPNOTSUPP;
+
+	trace_rdev_nan_ndp_initiate(&rdev->wiphy, wdev, params);
+	ret = rdev->ops->nan_ndp_initiate(&rdev->wiphy, wdev, params);
+	trace_rdev_return_int(&rdev->wiphy, ret);
+	return ret;
+}
+
+static inline int
+rdev_nan_ndp_respond(struct cfg80211_registered_device *rdev,
+		     struct wireless_dev *wdev,
+		     struct cfg80211_nan_ndp_respond *params)
+{
+	int ret;
+
+	if (!rdev->ops->nan_ndp_respond)
+		return -EOPNOTSUPP;
+
+	trace_rdev_nan_ndp_respond(&rdev->wiphy, wdev, params);
+	ret = rdev->ops->nan_ndp_respond(&rdev->wiphy, wdev, params);
+	trace_rdev_return_int(&rdev->wiphy, ret);
+	return ret;
+}
+
+static inline int
+rdev_nan_ndp_terminate(struct cfg80211_registered_device *rdev,
+		       struct wireless_dev *wdev,
+		       struct cfg80211_nan_ndp_terminate *params)
+{
+	int ret;
+
+	if (!rdev->ops->nan_ndp_terminate)
+		return -EOPNOTSUPP;
+
+	trace_rdev_nan_ndp_terminate(&rdev->wiphy, wdev, params);
+	ret = rdev->ops->nan_ndp_terminate(&rdev->wiphy, wdev, params);
+	trace_rdev_return_int(&rdev->wiphy, ret);
+	return ret;
+}
+
 static inline int rdev_set_mac_acl(struct cfg80211_registered_device *rdev,
 				   struct net_device *dev,
 				   struct cfg80211_acl_data *params)
diff --git a/net/wireless/trace.h b/net/wireless/trace.h
index 31000ffebe436..fbe3eb69cd147 100644
--- a/net/wireless/trace.h
+++ b/net/wireless/trace.h
@@ -2552,6 +2552,76 @@ TRACE_EVENT(rdev_nan_set_non_evac_channels,
 				__entry->n_channels, sizeof(u32)))
 );
 
+TRACE_EVENT(rdev_nan_ndp_initiate,
+	TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,
+		 struct cfg80211_nan_ndp_initiate *params),
+	TP_ARGS(wiphy, wdev, params),
+	TP_STRUCT__entry(
+		WIPHY_ENTRY
+		WDEV_ENTRY
+		__array(u8, peer_nmi, ETH_ALEN)
+		__field(u8, publish_id)
+	),
+	TP_fast_assign(
+		WIPHY_ASSIGN;
+		WDEV_ASSIGN;
+		memcpy(__entry->peer_nmi, params->peer_nmi, ETH_ALEN);
+		__entry->publish_id = params->publish_id;
+	),
+	TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT
+		  ", peer: %pM, publish_id: %u",
+		  WIPHY_PR_ARG, WDEV_PR_ARG,
+		  __entry->peer_nmi, __entry->publish_id)
+);
+
+TRACE_EVENT(rdev_nan_ndp_respond,
+	TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,
+		 struct cfg80211_nan_ndp_respond *params),
+	TP_ARGS(wiphy, wdev, params),
+	TP_STRUCT__entry(
+		WIPHY_ENTRY
+		WDEV_ENTRY
+		__array(u8, peer_nmi, ETH_ALEN)
+		__field(u8, ndp_id)
+		__field(bool, accept)
+	),
+	TP_fast_assign(
+		WIPHY_ASSIGN;
+		WDEV_ASSIGN;
+		memcpy(__entry->peer_nmi, params->peer_nmi, ETH_ALEN);
+		__entry->ndp_id = params->ndp_id;
+		__entry->accept = params->accept;
+	),
+	TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT
+		  ", peer: %pM, ndp_id: %u, accept: %d",
+		  WIPHY_PR_ARG, WDEV_PR_ARG,
+		  __entry->peer_nmi, __entry->ndp_id, __entry->accept)
+);
+
+TRACE_EVENT(rdev_nan_ndp_terminate,
+	TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,
+		 struct cfg80211_nan_ndp_terminate *params),
+	TP_ARGS(wiphy, wdev, params),
+	TP_STRUCT__entry(
+		WIPHY_ENTRY
+		WDEV_ENTRY
+		__array(u8, peer_nmi, ETH_ALEN)
+		__field(u8, ndp_id)
+		__field(u8, reason)
+	),
+	TP_fast_assign(
+		WIPHY_ASSIGN;
+		WDEV_ASSIGN;
+		memcpy(__entry->peer_nmi, params->peer_nmi, ETH_ALEN);
+		__entry->ndp_id = params->ndp_id;
+		__entry->reason = params->reason;
+	),
+	TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT
+		  ", peer: %pM, ndp_id: %u, reason: %u",
+		  WIPHY_PR_ARG, WDEV_PR_ARG,
+		  __entry->peer_nmi, __entry->ndp_id, __entry->reason)
+);
+
 TRACE_EVENT(rdev_set_mac_acl,
 	TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
 		 struct cfg80211_acl_data *params),
diff --git a/net/wireless/util.c b/net/wireless/util.c
index 9d5456defc90b..38fd97e8fac71 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -2820,6 +2820,7 @@ void cfg80211_free_nan_func(struct cfg80211_nan_func *f)
 	kfree(f->serv_spec_info);
 	kfree(f->srf_bf);
 	kfree(f->srf_macs);
+	kfree(f->csids);
 	for (i = 0; i < f->num_rx_filters; i++)
 		kfree(f->rx_filters[i].filter);
 

3/2 2026/10/14 16:38 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 37426
							output: 22
							thoughts: 1468
						

Thoughts:
**Analyzing the NAN/NDP/Ranging Patch for Fuzzing Potential**

Okay, let's break this down. My initial assessment is whether this new NAN (Neighbor Awareness Networking), NDP (NAN Data Path), and Ranging support in `cfg80211`/`nl80211` is a good target for syzkaller.

First, I need to understand what's actually being added. From what I can tell, this patch introduces a whole suite of new functionality: new functions like `cfg80211_nan_ndp_*`, extensions to `cfg80211_nan_func`, new commands (`NL80211_CMD_NAN_NDP_*`) and attributes in the netlink interface, and implementations in `nl80211.c` and `pmsr.c`. Specifically, new function hooks, policies, and parsing routines.

The immediate thing that jumps out is the potential for interesting interaction with netlink. Syzkaller is great at fuzzing netlink interfaces, and this patch adds a lot of new netlink commands and attributes, and that's exactly what I'm looking for.

I'm zeroing in on this reuse of `info->attrs` within `nl80211_nan_add_func`. The code clears `info->attrs` to parse a channel definition. Now, reusing attributes like this, especially after zeroing, is *classic* memory corruption potential! This is the kind of pattern that gets my attention immediately. I need to understand this flow in detail!

But before I get too excited, I need to make sure this code is even *reachable*. I need to determine if and how these new nl80211 commands are triggered in a standard syzkaller setup, or can be emulated in QEMU. Can I use `mac80211_hwsim` to fuzz this? I need to check.  Yes, `mac80211_hwsim` is a good target. It's often fuzzed with syzkaller, which is great news.

The key questions here are:  Can syzkaller, with its user namespaces and `CAP_NET_ADMIN` privileges, send these `nl80211` messages?  Can I construct netlink messages to reach `nl80211_nan_add_func`, `nl80211_nan_ndp_initiate`, `pmsr_parse_ftm_nan`, and potentially trigger that `info->attrs` reuse issue? I'm going to dig into the `mac80211_hwsim` code and see if it sets any NAN-related flags, specifically checking if the driver sets `WIPHY_NAN_FLAGS_OFFLOAD_NDP`, and if the hardware is *required* for this code path. I need to quickly identify if the code paths are dependent on hardware capabilities.

This has solid potential. The new netlink commands, the attribute reuse... this looks like a good candidate for some focused fuzzing.



4/2 2026/10/14 16:39 tool grepper
0m Args:
{
  "Expression": "WIPHY_NAN_FLAGS_"
}

Results:
{
  "Output": "\nFull output is too long, showing 200 out of 248 lines.\nUse more precise expression or PathPrefixes if possible.\n\nNumber of matching lines per file (12 files in total):\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c:2\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c:2\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:3\ninclude/net/cfg80211.h:17\ninclude/uapi/linux/nl80211.h:3\nnet/mac80211/cfg.c:4\nnet/mac80211/ieee80211_i.h:1\nnet/mac80211/iface.c:2\nnet/mac80211/main.c:1\nnet/mac80211/util.c:1\nnet/wireless/core.c:3\nnet/wireless/nl80211.c:19\n\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c=268=static void iwl_mld_hw_set_nan(struct iwl_mld *mld)\n--\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-279-\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c:280:\thw-\u003ewiphy-\u003enan_capa.flags = WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC |\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c:281:\t\t\t\t    WIPHY_NAN_FLAGS_USERSPACE_DE;\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-282-\n--\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c=751=int mt792x_init_wiphy(struct ieee80211_hw *hw)\n--\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c-801-\t\t\t\t\t      BIT(NL80211_BAND_5GHZ);\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c:802:\t\twiphy-\u003enan_capa.flags = WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC |\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c:803:\t\t\t\t\tWIPHY_NAN_FLAGS_USERSPACE_DE;\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c-804-\t\twiphy-\u003enan_capa.op_mode = NAN_OP_MODE_PHY_MODE_MASK;\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c=5722=static int mac80211_hwsim_new_radio(struct genl_info *info,\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-5846-\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:5847:\t\thw-\u003ewiphy-\u003enan_capa.flags = WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC |\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:5848:\t\t\t\t\t    WIPHY_NAN_FLAGS_USERSPACE_DE |\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:5849:\t\t\t\t\t    WIPHY_NAN_FLAGS_INSTANT_COMM;\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-5850-\t\thw-\u003ewiphy-\u003enan_capa.op_mode = NAN_OP_MODE_PHY_MODE_MASK |\n--\ninclude/net/cfg80211.h=5112=struct mgmt_frame_regs {\n--\ninclude/net/cfg80211.h-5501- * @nan_ndp_initiate: Initiate a NAN Data Path session as the initiator.\ninclude/net/cfg80211.h:5502: *\tOnly valid if the driver has set %WIPHY_NAN_FLAGS_OFFLOAD_NDP.\ninclude/net/cfg80211.h-5503- * @nan_ndp_respond: Respond to an incoming NDP request as the responder.\ninclude/net/cfg80211.h:5504: *\tOnly valid if the driver has set %WIPHY_NAN_FLAGS_OFFLOAD_NDP.\ninclude/net/cfg80211.h-5505- * @nan_ndp_terminate: Terminate an established NDP session.\ninclude/net/cfg80211.h:5506: *\tOnly valid if the driver has set %WIPHY_NAN_FLAGS_OFFLOAD_NDP.\ninclude/net/cfg80211.h-5507- *\n--\ninclude/net/cfg80211.h=6591=struct wiphy_radio {\n--\ninclude/net/cfg80211.h-6603- *\ninclude/net/cfg80211.h:6604: * @WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC: Device supports NAN configurable\ninclude/net/cfg80211.h-6605- *     synchronization.\ninclude/net/cfg80211.h:6606: * @WIPHY_NAN_FLAGS_USERSPACE_DE: Device doesn't support DE offload.\ninclude/net/cfg80211.h:6607: * @WIPHY_NAN_FLAGS_INSTANT_COMM: Device can switch to Instant Communication\ninclude/net/cfg80211.h:6608: *     (IC) mode. Can only be set along with %WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC.\ninclude/net/cfg80211.h:6609: * @WIPHY_NAN_FLAGS_OFFLOAD_NDP: Driver handles NAN Data Path (NDP) handshake\ninclude/net/cfg80211.h-6610- *\tframes and data path key installation autonomously.\ninclude/net/cfg80211.h:6611: * @WIPHY_NAN_FLAGS_OFFLOAD_RANGING: Firmware supports fully offloaded NAN\ninclude/net/cfg80211.h-6612- *\tranging procedure, including ranging session setup, update, and\n--\ninclude/net/cfg80211.h=6615=enum wiphy_nan_flags {\ninclude/net/cfg80211.h:6616:\tWIPHY_NAN_FLAGS_CONFIGURABLE_SYNC = BIT(0),\ninclude/net/cfg80211.h:6617:\tWIPHY_NAN_FLAGS_USERSPACE_DE   = BIT(1),\ninclude/net/cfg80211.h:6618:\tWIPHY_NAN_FLAGS_INSTANT_COMM = BIT(2),\ninclude/net/cfg80211.h:6619:\tWIPHY_NAN_FLAGS_OFFLOAD_NDP = BIT(3),\ninclude/net/cfg80211.h:6620:\tWIPHY_NAN_FLAGS_OFFLOAD_RANGING = BIT(4),\ninclude/net/cfg80211.h-6621-};\n--\ninclude/net/cfg80211.h=11376=cfg80211_s1g_get_primary_sibling(struct wiphy *wiphy,\n--\ninclude/net/cfg80211.h-11407- * Notify userspace that a NAN Data Path request was received from a peer.\ninclude/net/cfg80211.h:11408: * Only valid when %WIPHY_NAN_FLAGS_OFFLOAD_NDP is set.\ninclude/net/cfg80211.h-11409- */\ninclude/net/cfg80211.h=11410=void cfg80211_nan_ndp_request(struct wireless_dev *wdev,\n--\ninclude/net/cfg80211.h-11421- * accept/reject status and, if accepted, the responder NDI. Only valid\ninclude/net/cfg80211.h:11422: * when %WIPHY_NAN_FLAGS_OFFLOAD_NDP is set.\ninclude/net/cfg80211.h-11423- */\ninclude/net/cfg80211.h=11424=void cfg80211_nan_ndp_confirm(struct wireless_dev *wdev,\n--\ninclude/net/cfg80211.h-11434- * Notify userspace that a NAN Data Path was torn down. Only valid\ninclude/net/cfg80211.h:11435: * when %WIPHY_NAN_FLAGS_OFFLOAD_NDP is set.\ninclude/net/cfg80211.h-11436- */\n--\ninclude/uapi/linux/nl80211.h-1472- * @NL80211_CMD_NAN_NDP_INITIATE: Initiate NAN Data Path (NDP) setup\ninclude/uapi/linux/nl80211.h:1473: *\tas the initiator. Requires %WIPHY_NAN_FLAGS_OFFLOAD_NDP. The NDI\ninclude/uapi/linux/nl80211.h-1474- *\tinterface specified in %NL80211_NAN_NDP_ATTR_INIT_NDI must already\n--\ninclude/uapi/linux/nl80211.h-1477- * @NL80211_CMD_NAN_NDP_RESPOND: Respond to a received NDP request as\ninclude/uapi/linux/nl80211.h:1478: *\tthe responder. Requires %WIPHY_NAN_FLAGS_OFFLOAD_NDP. The NDI\ninclude/uapi/linux/nl80211.h-1479- *\tinterface specified in %NL80211_NAN_NDP_ATTR_RESP_NDI must already\n--\ninclude/uapi/linux/nl80211.h-1482- * @NL80211_CMD_NAN_NDP_TERMINATE: Terminate an established NDP.\ninclude/uapi/linux/nl80211.h:1483: *\tRequires %WIPHY_NAN_FLAGS_OFFLOAD_NDP. Carries %NL80211_ATTR_NAN_NDP\ninclude/uapi/linux/nl80211.h-1484- *\tnested with %NL80211_NAN_NDP_ATTR_ID, %NL80211_NAN_NDP_ATTR_INIT_NDI\n--\nnet/mac80211/cfg.c=493=static int ieee80211_add_nan_func(struct wiphy *wiphy,\n--\nnet/mac80211/cfg.c-505-\nnet/mac80211/cfg.c:506:\tif (WARN_ON(wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_USERSPACE_DE))\nnet/mac80211/cfg.c-507-\t\treturn -EOPNOTSUPP;\n--\nnet/mac80211/cfg.c=551=static void ieee80211_del_nan_func(struct wiphy *wiphy,\n--\nnet/mac80211/cfg.c-561-\nnet/mac80211/cfg.c:562:\tif (WARN_ON(wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_USERSPACE_DE))\nnet/mac80211/cfg.c-563-\t\treturn;\n--\nnet/mac80211/cfg.c=5546=void ieee80211_nan_func_terminated(struct ieee80211_vif *vif,\n--\nnet/mac80211/cfg.c-5558-\tif (WARN_ON(sdata-\u003elocal-\u003ehw.wiphy-\u003enan_capa.flags \u0026\nnet/mac80211/cfg.c:5559:\t\t    WIPHY_NAN_FLAGS_USERSPACE_DE))\nnet/mac80211/cfg.c-5560-\t\treturn;\n--\nnet/mac80211/cfg.c=5582=void ieee80211_nan_func_match(struct ieee80211_vif *vif,\n--\nnet/mac80211/cfg.c-5592-\tif (WARN_ON(sdata-\u003elocal-\u003ehw.wiphy-\u003enan_capa.flags \u0026\nnet/mac80211/cfg.c:5593:\t\t    WIPHY_NAN_FLAGS_USERSPACE_DE))\nnet/mac80211/cfg.c-5594-\t\treturn;\n--\nnet/mac80211/ieee80211_i.h=1000=struct ieee80211_if_mntr {\n--\nnet/mac80211/ieee80211_i.h-1011- * @started: true iff NAN is started\nnet/mac80211/ieee80211_i.h:1012: * @de: Discovery Engine state (only valid if !WIPHY_NAN_FLAGS_USERSPACE_DE)\nnet/mac80211/ieee80211_i.h-1013- * @de.func_lock: lock for @de.function_inst_ids\n--\nnet/mac80211/iface.c=479=static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_down)\n--\nnet/mac80211/iface.c-647-\t\tif (!(local-\u003ehw.wiphy-\u003enan_capa.flags \u0026\nnet/mac80211/iface.c:648:\t\t      WIPHY_NAN_FLAGS_USERSPACE_DE)) {\nnet/mac80211/iface.c-649-\t\t\tspin_lock_bh(\u0026sdata-\u003eu.nan.de.func_lock);\n--\nnet/mac80211/iface.c=1914=static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata,\n--\nnet/mac80211/iface.c-1989-\t\tif (!(sdata-\u003elocal-\u003ehw.wiphy-\u003enan_capa.flags \u0026\nnet/mac80211/iface.c:1990:\t\t      WIPHY_NAN_FLAGS_USERSPACE_DE)) {\nnet/mac80211/iface.c-1991-\t\t\tidr_init(\u0026sdata-\u003eu.nan.de.function_inst_ids);\n--\nnet/mac80211/main.c=1142=int ieee80211_register_hw(struct ieee80211_hw *hw)\n--\nnet/mac80211/main.c-1168-\t\t    ((!local-\u003eops-\u003estart_nan || !local-\u003eops-\u003estop_nan) ||\nnet/mac80211/main.c:1169:\t\t     (local-\u003ehw.wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_USERSPACE_DE \u0026\u0026\nnet/mac80211/main.c-1170-\t\t     (local-\u003eops-\u003eadd_nan_func || local-\u003eops-\u003edel_nan_func)))))\n--\nnet/mac80211/util.c=1806=static int ieee80211_reconfig_nan(struct ieee80211_sub_if_data *sdata)\n--\nnet/mac80211/util.c-1816-\nnet/mac80211/util.c:1817:\tif (!(sdata-\u003elocal-\u003ehw.wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_USERSPACE_DE))\nnet/mac80211/util.c-1818-\t\treturn ieee80211_reconfig_nan_offload_de(sdata);\n--\nnet/wireless/core.c=904=int wiphy_register(struct wiphy *wiphy)\n--\nnet/wireless/core.c-941-\nnet/wireless/core.c:942:\tif (WARN_ON((wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_INSTANT_COMM) \u0026\u0026\nnet/wireless/core.c-943-\t\t    !(wiphy-\u003enan_capa.flags \u0026\nnet/wireless/core.c:944:\t\t      WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC)))\nnet/wireless/core.c-945-\t\treturn -EINVAL;\n--\nnet/wireless/core.c-947-\t/* Instant Communication requires user space to track NAN beacons */\nnet/wireless/core.c:948:\tif (WARN_ON((wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_INSTANT_COMM) \u0026\u0026\nnet/wireless/core.c-949-\t\t    (!wiphy-\u003emgmt_stypes ||\n--\nnet/wireless/nl80211.c=3175=static int nl80211_put_nan_capa(struct wiphy *wiphy, struct sk_buff *msg)\n--\nnet/wireless/nl80211.c-3182-\nnet/wireless/nl80211.c:3183:\tif (wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC \u0026\u0026\nnet/wireless/nl80211.c-3184-\t    nla_put_flag(msg, NL80211_NAN_CAPA_CONFIGURABLE_SYNC))\n--\nnet/wireless/nl80211.c-3186-\nnet/wireless/nl80211.c:3187:\tif ((wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_USERSPACE_DE) \u0026\u0026\nnet/wireless/nl80211.c-3188-\t    nla_put_flag(msg, NL80211_NAN_CAPA_USERSPACE_DE))\n--\nnet/wireless/nl80211.c-3190-\nnet/wireless/nl80211.c:3191:\tif ((wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_INSTANT_COMM) \u0026\u0026\nnet/wireless/nl80211.c-3192-\t    nla_put_flag(msg, NL80211_NAN_CAPA_INSTANT_COMM))\n--\nnet/wireless/nl80211.c-3194-\nnet/wireless/nl80211.c:3195:\tif ((wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_OFFLOAD_RANGING) \u0026\u0026\nnet/wireless/nl80211.c-3196-\t    nla_put_flag(msg, NL80211_NAN_CAPA_OFFLOAD_RANGING))\n--\nnet/wireless/nl80211.c-3198-\nnet/wireless/nl80211.c:3199:\tif ((wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_OFFLOAD_NDP) \u0026\u0026\nnet/wireless/nl80211.c-3200-\t    nla_put_flag(msg, NL80211_NAN_CAPA_OFFLOAD_NDP))\n--\nnet/wireless/nl80211.c=15287=static int nl80211_register_mgmt(struct sk_buff *skb, struct genl_info *info)\n--\nnet/wireless/nl80211.c-15313-\t\t    !(wdev-\u003ewiphy-\u003enan_capa.flags \u0026\nnet/wireless/nl80211.c:15314:\t\t      WIPHY_NAN_FLAGS_USERSPACE_DE))\nnet/wireless/nl80211.c-15315-\t\t\treturn -EOPNOTSUPP;\n--\nnet/wireless/nl80211.c=15361=static int nl80211_tx_mgmt(struct sk_buff *skb, struct genl_info *info)\n--\nnet/wireless/nl80211.c-15398-\t\t    !(wdev-\u003ewiphy-\u003enan_capa.flags \u0026\nnet/wireless/nl80211.c:15399:\t\t      WIPHY_NAN_FLAGS_USERSPACE_DE))\nnet/wireless/nl80211.c-15400-\t\t\treturn -EOPNOTSUPP;\n--\nnet/wireless/nl80211.c=17151=static int nl80211_parse_nan_conf(struct wiphy *wiphy,\n--\nnet/wireless/nl80211.c-17275-\tif (conf-\u003einstant_comm) {\nnet/wireless/nl80211.c:17276:\t\tif (!(wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_INSTANT_COMM)) {\nnet/wireless/nl80211.c-17277-\t\t\tNL_SET_ERR_MSG_ATTR(info-\u003eextack,\n--\nnet/wireless/nl80211.c=17431=static int nl80211_nan_add_func(struct sk_buff *skb,\n--\nnet/wireless/nl80211.c-17447-\nnet/wireless/nl80211.c:17448:\tif (wdev-\u003ewiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_USERSPACE_DE) {\nnet/wireless/nl80211.c-17449-\t\tNL_SET_ERR_MSG(info-\u003eextack,\n--\nnet/wireless/nl80211.c-17651-\t\t    !(wdev-\u003ewiphy-\u003enan_capa.flags \u0026\nnet/wireless/nl80211.c:17652:\t\t      WIPHY_NAN_FLAGS_OFFLOAD_NDP)) {\nnet/wireless/nl80211.c-17653-\t\t\tNL_SET_ERR_MSG(info-\u003eextack,\n--\nnet/wireless/nl80211.c-17736-\t\tif (!(wdev-\u003ewiphy-\u003enan_capa.flags \u0026\nnet/wireless/nl80211.c:17737:\t\t      WIPHY_NAN_FLAGS_OFFLOAD_RANGING) ||\nnet/wireless/nl80211.c-17738-\t\t    !pmsr_capa || !pmsr_capa-\u003eftm.supported) {\n\n"
}

5/2 2026/10/14 16:39 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 45566
							output: 21
							thoughts: 75
						

Thoughts:
Okay, let's dive into this. Here's how I'm approaching this, reflecting my thought process:

**Investigating NAN NDP Offload Capabilities in the Codebase**

Alright, I need to get a handle on how Network Aware Networking (NAN) NDP offload is implemented within this codebase. My initial thought is to identify the drivers that are actually *using* this functionality. I'll need to figure out which ones are setting flags related to NDP offloading, specifically `WIPHY_NAN_FLAGS_OFFLOAD_NDP` or `WIPHY_NAN_FLAGS_OFFLOAD_RANGING`. Those flags will be a good starting point.

Beyond those flags, I should also look for drivers that *initiate* the NAN NDP process. I'll need to locate where `nan_ndp_initiate` is implemented. That function name is probably key, so I'll utilize `grepper` to search the entire codebase for that exact string. Once I have the results, I can start to understand how the offload functionality is architected and identify which drivers are actively participating. This will provide a focused view of the relevant components and the overall implementation strategy for this feature.



6/2 2026/10/14 16:39 tool grepper
0m Args:
{
  "Expression": "nan_ndp_initiate"
}

Results:
{
  "Output": "include/net/cfg80211.h=4325=struct cfg80211_nan_peer_sched {\n--\ninclude/net/cfg80211.h-4337-/**\ninclude/net/cfg80211.h:4338: * struct cfg80211_nan_ndp_initiate - NAN NDP initiate parameters\ninclude/net/cfg80211.h-4339- *\n--\ninclude/net/cfg80211.h-4361- */\ninclude/net/cfg80211.h:4362:struct cfg80211_nan_ndp_initiate {\ninclude/net/cfg80211.h-4363-\tconst u8 *peer_nmi;\n--\ninclude/net/cfg80211.h=5112=struct mgmt_frame_regs {\n--\ninclude/net/cfg80211.h-5500- *\ninclude/net/cfg80211.h:5501: * @nan_ndp_initiate: Initiate a NAN Data Path session as the initiator.\ninclude/net/cfg80211.h-5502- *\tOnly valid if the driver has set %WIPHY_NAN_FLAGS_OFFLOAD_NDP.\n--\ninclude/net/cfg80211.h=5582=struct cfg80211_ops {\n--\ninclude/net/cfg80211.h-5914-\t\t\t\t\t     struct cfg80211_nan_non_evac_channels *channels);\ninclude/net/cfg80211.h:5915:\tint     (*nan_ndp_initiate)(struct wiphy *wiphy,\ninclude/net/cfg80211.h-5916-\t\t\t\t    struct wireless_dev *wdev,\ninclude/net/cfg80211.h:5917:\t\t\t\t    struct cfg80211_nan_ndp_initiate *params);\ninclude/net/cfg80211.h-5918-\tint\t(*nan_ndp_respond)(struct wiphy *wiphy,\n--\nnet/wireless/nl80211.c=18356=static int nl80211_nan_set_peer_sched(struct sk_buff *skb,\n--\nnet/wireless/nl80211.c-18503-\nnet/wireless/nl80211.c:18504:static int nl80211_nan_ndp_initiate(struct sk_buff *skb,\nnet/wireless/nl80211.c-18505-\t\t\t\t    struct genl_info *info)\n--\nnet/wireless/nl80211.c-18509-\tstruct nlattr *tb[NL80211_NAN_NDP_ATTR_MAX + 1];\nnet/wireless/nl80211.c:18510:\tstruct cfg80211_nan_ndp_initiate params = {};\nnet/wireless/nl80211.c-18511-\tint err;\n--\nnet/wireless/nl80211.c-18625-\nnet/wireless/nl80211.c:18626:\treturn rdev_nan_ndp_initiate(rdev, wdev, \u0026params);\nnet/wireless/nl80211.c-18627-}\n--\nnet/wireless/nl80211.c=21266=static const struct genl_small_ops nl80211_small_ops[] = {\n--\nnet/wireless/nl80211.c-22158-\t\t.cmd = NL80211_CMD_NAN_NDP_INITIATE,\nnet/wireless/nl80211.c:22159:\t\t.doit = nl80211_nan_ndp_initiate,\nnet/wireless/nl80211.c-22160-\t\t.flags = GENL_ADMIN_PERM,\n--\nnet/wireless/rdev-ops.h=1186=static inline int\nnet/wireless/rdev-ops.h:1187:rdev_nan_ndp_initiate(struct cfg80211_registered_device *rdev,\nnet/wireless/rdev-ops.h-1188-\t\t      struct wireless_dev *wdev,\nnet/wireless/rdev-ops.h:1189:\t\t      struct cfg80211_nan_ndp_initiate *params)\nnet/wireless/rdev-ops.h-1190-{\n--\nnet/wireless/rdev-ops.h-1192-\nnet/wireless/rdev-ops.h:1193:\tif (!rdev-\u003eops-\u003enan_ndp_initiate)\nnet/wireless/rdev-ops.h-1194-\t\treturn -EOPNOTSUPP;\nnet/wireless/rdev-ops.h-1195-\nnet/wireless/rdev-ops.h:1196:\ttrace_rdev_nan_ndp_initiate(\u0026rdev-\u003ewiphy, wdev, params);\nnet/wireless/rdev-ops.h:1197:\tret = rdev-\u003eops-\u003enan_ndp_initiate(\u0026rdev-\u003ewiphy, wdev, params);\nnet/wireless/rdev-ops.h-1198-\ttrace_rdev_return_int(\u0026rdev-\u003ewiphy, ret);\n--\nnet/wireless/trace.h=2530=TRACE_EVENT(rdev_nan_set_non_evac_channels,\n--\nnet/wireless/trace.h-2554-\nnet/wireless/trace.h:2555:TRACE_EVENT(rdev_nan_ndp_initiate,\nnet/wireless/trace.h-2556-\tTP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,\nnet/wireless/trace.h:2557:\t\t struct cfg80211_nan_ndp_initiate *params),\nnet/wireless/trace.h-2558-\tTP_ARGS(wiphy, wdev, params),\n"
}

7/2 2026/10/14 16:39 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 47512
							output: 25
							thoughts: 62
						

Thoughts:
**Investigating NaN Support in the Linux Wireless Stack**

Okay, so I need to get a handle on the current state of NaN (Neighbor Awareness Networking) support within the Linux wireless stack. I'm thinking, where are the likely places to find this? My first instinct is to check the existing drivers, see if any of them explicitly mention or implement NaN capabilities. Specifically, I'll be looking at whether any existing drivers utilize or declare support for `nan` or something equivalent. Then, I wonder if the `mac80211_hwsim` module has any relevant features related to NaN. I should also check `mac80211` itself, the core wireless networking framework, to see if it provides any fundamental support or infrastructure for NaN operations. Finally, I'll do a quick scan of the kernel tree to see which drivers actually use NaN. My best bet to get started? I'll grep the source code for the macro `NL80211_IFTYPE_NAN`. That should quickly highlight any code that's explicitly dealing with the NaN interface type. Hopefully, this will get me a decent overview of where things stand.



8/2 2026/10/14 16:39 tool grepper
0m Args:
{
  "Expression": "NL80211_IFTYPE_NAN"
}

Results:
{
  "Output": "\nFull output is too long, showing 200 out of 1372 lines.\nUse more precise expression or PathPrefixes if possible.\n\nNumber of matching lines per file (44 files in total):\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c:14\ndrivers/net/wireless/intel/iwlwifi/mld/iface.h:2\ndrivers/net/wireless/intel/iwlwifi/mld/key.c:4\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c:13\ndrivers/net/wireless/intel/iwlwifi/mld/nan.c:1\ndrivers/net/wireless/intel/iwlwifi/mld/sta.c:4\ndrivers/net/wireless/intel/iwlwifi/mld/stats.c:2\ndrivers/net/wireless/intel/iwlwifi/mld/tlc.c:2\ndrivers/net/wireless/intel/iwlwifi/mld/tx.c:6\ndrivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c:6\ndrivers/net/wireless/mediatek/mt76/mt7925/init.c:1\ndrivers/net/wireless/mediatek/mt76/mt7925/main.c:7\ndrivers/net/wireless/mediatek/mt76/mt7925/mcu.c:4\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c:6\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:15\ndrivers/net/wireless/virtual/mac80211_hwsim_nan.c:10\ninclude/net/cfg80211.h:7\ninclude/uapi/linux/nl80211.h:9\nnet/mac80211/agg-tx.c:1\nnet/mac80211/cfg.c:17\nnet/mac80211/chan.c:8\nnet/mac80211/debugfs_netdev.c:1\nnet/mac80211/driver-ops.c:1\nnet/mac80211/he.c:1\nnet/mac80211/ht.c:3\nnet/mac80211/ieee80211_i.h:1\nnet/mac80211/iface.c:21\nnet/mac80211/key.c:2\nnet/mac80211/main.c:4\nnet/mac80211/nan.c:3\nnet/mac80211/offchannel.c:7\nnet/mac80211/rx.c:6\nnet/mac80211/sta_info.c:3\nnet/mac80211/status.c:1\nnet/mac80211/tx.c:7\nnet/mac80211/util.c:10\nnet/mac80211/vht.c:1\nnet/wireless/chan.c:4\nnet/wireless/core.c:16\nnet/wireless/mlme.c:4\nnet/wireless/nl80211.c:45\nnet/wireless/pmsr.c:1\nnet/wireless/reg.c:6\nnet/wireless/util.c:9\n\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c=20=void iwl_mld_cleanup_vif(void *data, u8 *mac, struct ieee80211_vif *vif)\n--\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c-58-\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c:59:\tif (vif-\u003etype == NL80211_IFTYPE_NAN) {\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c-60-\t\tmld_vif-\u003enan.mac_added = false;\n--\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c-72-\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c:73:\tif (vif-\u003etype == NL80211_IFTYPE_NAN_DATA \u0026\u0026\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c-74-\t    mld_vif-\u003enan.mcast_data_sta.sta_id != IWL_INVALID_STA)\n--\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c=103=static int iwl_mld_mac80211_iftype_to_fw(const struct ieee80211_vif *vif)\n--\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c-115-\t\treturn FW_MAC_TYPE_IBSS;\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c:116:\tcase NL80211_IFTYPE_NAN:\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c-117-\t\treturn FW_MAC_TYPE_NAN;\n--\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c=388=static int iwl_mld_fill_mac_cmd_nan(struct iwl_mld *mld,\n--\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c-408-\tfor_each_active_interface(iter, mld-\u003ehw) {\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c:409:\t\tif (iter-\u003etype != NL80211_IFTYPE_NAN_DATA)\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c-410-\t\t\tcontinue;\n--\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c=437=__iwl_mld_mac_fw_action(struct iwl_mld *mld, struct ieee80211_vif *vif,\n--\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c-445-\t/* NAN_DATA interface type is not known to FW */\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c:446:\tif (WARN_ON(vif-\u003etype == NL80211_IFTYPE_NAN_DATA))\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c-447-\t\treturn -EINVAL;\n--\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c-450-\tif (WARN_ON(ndi_being_added \u0026\u0026\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c:451:\t\t    (vif-\u003etype != NL80211_IFTYPE_NAN || action != FW_CTXT_ACTION_MODIFY)))\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c-452-\t\treturn -EINVAL;\n--\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c-479-\t\tbreak;\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c:480:\tcase NL80211_IFTYPE_NAN:\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c-481-\t\tret = iwl_mld_fill_mac_cmd_nan(mld, vif, ndi_being_added, \u0026cmd);\n--\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c=514=iwl_mld_init_vif(struct iwl_mld *mld, struct ieee80211_vif *vif)\n--\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c-536-\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c:537:\tif (vif-\u003etype == NL80211_IFTYPE_NAN) {\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c-538-\t\tfor (int i = 0; i \u003c ARRAY_SIZE(mld_vif-\u003enan.links); i++) {\n--\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c-544-\t\tiwl_mld_init_internal_sta(\u0026mld_vif-\u003enan.mgmt_sta);\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c:545:\t} else if (vif-\u003etype == NL80211_IFTYPE_NAN_DATA) {\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c-546-\t\tiwl_mld_init_internal_sta(\u0026mld_vif-\u003enan.mcast_data_sta);\n--\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c=570=int iwl_mld_add_vif(struct iwl_mld *mld, struct ieee80211_vif *vif)\n--\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c-579-\t/* NAN MACs are added to FW only when a schedule is set */\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c:580:\tif (vif-\u003etype == NL80211_IFTYPE_NAN)\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c-581-\t\treturn 0;\n--\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c-583-\t/* NAN_DATA interface type is not known to FW, but we need to update NAN MAC */\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c:584:\tif (vif-\u003etype == NL80211_IFTYPE_NAN_DATA)\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c-585-\t\treturn iwl_mld_update_nan_mac(mld, vif);\n--\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c=598=int iwl_mld_add_nan_vif(struct iwl_mld *mld, struct ieee80211_vif *vif)\n--\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c-604-\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c:605:\tif (WARN_ON(vif-\u003etype != NL80211_IFTYPE_NAN))\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c-606-\t\treturn -EINVAL;\n--\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c=623=void iwl_mld_rm_vif(struct iwl_mld *mld, struct ieee80211_vif *vif)\n--\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c-628-\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c:629:\tif (vif-\u003etype == NL80211_IFTYPE_NAN_DATA) {\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c-630-\t\tiwl_mld_update_nan_mac(mld, NULL);\n--\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c-640-\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c:641:\tif (vif-\u003etype == NL80211_IFTYPE_NAN)\ndrivers/net/wireless/intel/iwlwifi/mld/iface.c-642-\t\tmld_vif-\u003enan.mac_added = false;\n--\ndrivers/net/wireless/intel/iwlwifi/mld/iface.h=226=static inline bool iwl_mld_vif_fw_id_valid(struct iwl_mld_vif *mld_vif)\n--\ndrivers/net/wireless/intel/iwlwifi/mld/iface.h-230-\tswitch (vif-\u003etype) {\ndrivers/net/wireless/intel/iwlwifi/mld/iface.h:231:\tcase NL80211_IFTYPE_NAN_DATA:\ndrivers/net/wireless/intel/iwlwifi/mld/iface.h-232-\t\treturn false;\ndrivers/net/wireless/intel/iwlwifi/mld/iface.h:233:\tcase NL80211_IFTYPE_NAN:\ndrivers/net/wireless/intel/iwlwifi/mld/iface.h-234-\t\tif (!mld_vif-\u003enan.mac_added)\n--\ndrivers/net/wireless/intel/iwlwifi/mld/key.c=61=static u32 iwl_mld_get_key_sta_mask(struct iwl_mld *mld,\n--\ndrivers/net/wireless/intel/iwlwifi/mld/key.c-71-\ndrivers/net/wireless/intel/iwlwifi/mld/key.c:72:\tif (vif-\u003etype == NL80211_IFTYPE_NAN_DATA \u0026\u0026 !sta) {\ndrivers/net/wireless/intel/iwlwifi/mld/key.c-73-\t\t/* Older firmware versions do not support transmission of\n--\ndrivers/net/wireless/intel/iwlwifi/mld/key.c-85-\ndrivers/net/wireless/intel/iwlwifi/mld/key.c:86:\tif (vif-\u003etype == NL80211_IFTYPE_NAN \u0026\u0026 !sta) {\ndrivers/net/wireless/intel/iwlwifi/mld/key.c-87-\t\t/* Older firmware versions do not support installation of\n--\ndrivers/net/wireless/intel/iwlwifi/mld/key.c=214=iwl_mld_get_igtk_ptr(struct ieee80211_vif *vif,\n--\ndrivers/net/wireless/intel/iwlwifi/mld/key.c-239-\t\treturn \u0026mld_ap_link_sta-\u003erx_igtk;\ndrivers/net/wireless/intel/iwlwifi/mld/key.c:240:\tcase NL80211_IFTYPE_NAN:\ndrivers/net/wireless/intel/iwlwifi/mld/key.c-241-\t\tif (sta) {\n--\ndrivers/net/wireless/intel/iwlwifi/mld/key.c=285=int iwl_mld_add_key(struct iwl_mld *mld,\n--\ndrivers/net/wireless/intel/iwlwifi/mld/key.c-298-\t\t/* for NAN (GTK) indicate SW-only, it's not used at all */\ndrivers/net/wireless/intel/iwlwifi/mld/key.c:299:\t\tif (vif-\u003etype == NL80211_IFTYPE_NAN_DATA \u0026\u0026 !sta \u0026\u0026\ndrivers/net/wireless/intel/iwlwifi/mld/key.c-300-\t\t    !iwl_mld_nan_use_nan_stations(mld))\n--\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c=63=static const struct ieee80211_iface_limit iwl_mld_limits_nan[] = {\n--\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-69-\t\t.max = 1,\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c:70:\t\t.types = BIT(NL80211_IFTYPE_NAN),\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-71-\t},\n--\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-73-\t\t.max = 2,\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c:74:\t\t.types = BIT(NL80211_IFTYPE_NAN_DATA),\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-75-\t},\n--\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c=268=static void iwl_mld_hw_set_nan(struct iwl_mld *mld)\n--\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-271-\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c:272:\thw-\u003ewiphy-\u003einterface_modes |= BIT(NL80211_IFTYPE_NAN);\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c:273:\thw-\u003ewiphy-\u003einterface_modes |= BIT(NL80211_IFTYPE_NAN_DATA);\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-274-\n--\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c=659=int iwl_mld_mac80211_add_interface(struct ieee80211_hw *hw,\n--\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-671-\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c:672:\tif (vif-\u003etype == NL80211_IFTYPE_NAN_DATA) {\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-673-\t\tif (WARN_ON(!mld-\u003enan_device_vif)) {\n--\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-697-\t */\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c:698:\tif (vif-\u003etype != NL80211_IFTYPE_NAN \u0026\u0026 !ieee80211_vif_is_mld(vif)) {\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-699-\t\tret = iwl_mld_add_link(mld, \u0026vif-\u003ebss_conf);\n--\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-729-\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c:730:\tif (vif-\u003etype == NL80211_IFTYPE_NAN)\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-731-\t\tmld-\u003enan_device_vif = vif;\n--\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c=741=void iwl_mld_mac80211_remove_interface(struct ieee80211_hw *hw,\n--\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-759-\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c:760:\tif (vif-\u003etype == NL80211_IFTYPE_NAN) {\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-761-\t\tmld-\u003enan_device_vif = NULL;\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c:762:\t} else if (vif-\u003etype != NL80211_IFTYPE_NAN_DATA) {\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-763-\t\tiwl_mld_remove_link(mld, \u0026vif-\u003ebss_conf);\n--\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c=1390=iwl_mld_mac80211_link_info_changed(struct ieee80211_hw *hw,\n--\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-1413-\t\tbreak;\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c:1414:\tcase NL80211_IFTYPE_NAN:\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c:1415:\tcase NL80211_IFTYPE_NAN_DATA:\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-1416-\t\t/* NAN has no links */\n--\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c=1434=void iwl_mld_mac80211_vif_cfg_changed(struct ieee80211_hw *hw,\n--\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-1442-\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c:1443:\tif (vif-\u003etype == NL80211_IFTYPE_NAN) {\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-1444-\t\tiwl_mld_nan_vif_cfg_changed(mld, vif, changes);\n--\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c=1630=iwl_mld_mac80211_conf_tx(struct ieee80211_hw *hw,\n--\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-1640-\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c:1641:\tif (vif-\u003etype == NL80211_IFTYPE_NAN || vif-\u003etype == NL80211_IFTYPE_NAN_DATA)\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-1642-\t\treturn 0;\n--\ndrivers/net/wireless/intel/iwlwifi/mld/nan.c=654=static void iwl_mld_nan_set_mcast_data_links(struct ieee80211_vif *vif)\n--\ndrivers/net/wireless/intel/iwlwifi/mld/nan.c-657-\ndrivers/net/wireless/intel/iwlwifi/mld/nan.c:658:\tif (vif-\u003etype != NL80211_IFTYPE_NAN_DATA)\ndrivers/net/wireless/intel/iwlwifi/mld/nan.c-659-\t\treturn;\n--\ndrivers/net/wireless/intel/iwlwifi/mld/sta.c=461=int iwl_mld_add_modify_sta_cmd(struct iwl_mld *mld,\n--\ndrivers/net/wireless/intel/iwlwifi/mld/sta.c-540-\t/* In NAN, there is no association request so no initial SMPS info */\ndrivers/net/wireless/intel/iwlwifi/mld/sta.c:541:\tif (mld_sta-\u003evif-\u003etype == NL80211_IFTYPE_NAN_DATA) {\ndrivers/net/wireless/intel/iwlwifi/mld/sta.c-542-\t\tcmd.mimo = cpu_to_le32(1);\n--\ndrivers/net/wireless/intel/iwlwifi/mld/sta.c=820=int iwl_mld_add_sta(struct iwl_mld *mld, struct ieee80211_sta *sta,\n--\ndrivers/net/wireless/intel/iwlwifi/mld/sta.c-829-\tswitch (vif-\u003etype) {\ndrivers/net/wireless/intel/iwlwifi/mld/sta.c:830:\tcase NL80211_IFTYPE_NAN:\ndrivers/net/wireless/intel/iwlwifi/mld/sta.c-831-\t\ttype = STATION_TYPE_NAN_PEER_NMI;\ndrivers/net/wireless/intel/iwlwifi/mld/sta.c-832-\t\tbreak;\ndrivers/net/wireless/intel/iwlwifi/mld/sta.c:833:\tcase NL80211_IFTYPE_NAN_DATA:\ndrivers/net/wireless/intel/iwlwifi/mld/sta.c-834-\t\ttype = STATION_TYPE_NAN_PEER_NDI;\n--\ndrivers/net/wireless/intel/iwlwifi/mld/sta.c=1281=void iwl_mld_remove_aux_sta(struct iwl_mld *mld,\n--\ndrivers/net/wireless/intel/iwlwifi/mld/sta.c-1287-\t\t    vif-\u003etype != NL80211_IFTYPE_STATION \u0026\u0026\ndrivers/net/wireless/intel/iwlwifi/mld/sta.c:1288:\t\t    vif-\u003etype != NL80211_IFTYPE_NAN))\ndrivers/net/wireless/intel/iwlwifi/mld/sta.c-1289-\t\treturn;\n--\ndrivers/net/wireless/intel/iwlwifi/mld/stats.c=314=static void iwl_mld_sta_stats_fill_beacon_signal_avg(struct ieee80211_vif *vif,\n--\ndrivers/net/wireless/intel/iwlwifi/mld/stats.c-324-\t/* TODO: support statistics for NAN */\ndrivers/net/wireless/intel/iwlwifi/mld/stats.c:325:\tif (vif-\u003etype == NL80211_IFTYPE_NAN ||\ndrivers/net/wireless/intel/iwlwifi/mld/stats.c:326:\t    vif-\u003etype == NL80211_IFTYPE_NAN_DATA)\ndrivers/net/wireless/intel/iwlwifi/mld/stats.c-327-\t\treturn;\n--\ndrivers/net/wireless/intel/iwlwifi/mld/tlc.c=721=void iwl_mld_config_tlc_link(struct iwl_mld *mld,\n--\ndrivers/net/wireless/intel/iwlwifi/mld/tlc.c-736-\ndrivers/net/wireless/intel/iwlwifi/mld/tlc.c:737:\tif (vif-\u003etype == NL80211_IFTYPE_NAN)\ndrivers/net/wireless/intel/iwlwifi/mld/tlc.c-738-\t\treturn;\ndrivers/net/wireless/intel/iwlwifi/mld/tlc.c-739-\n\n"
}

9/2 2026/10/14 16:39 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 54849
							output: 26
							thoughts: 178
						

Thoughts:
**Investigating mac80211_hwsim's Nan Capabilities and Ranging Support**

Okay, let's dive into what `mac80211_hwsim` actually offers. I'm going to start by looking at its NAN (Neighbor Awareness Networking) capabilities, specifically within `drivers/net/wireless/virtual/mac80211_hwsim_main.c`. Ah, there it is: `hw->wiphy->nan_capa.flags` seems to be the key. It looks like it supports configurable synchronization, user-space device operation, and instant communication. Interesting.

Now, a more pressing question arises: does `mac80211_hwsim` or any related driver actually handle offloading NDP (Neighbor Discovery Protocol) or ranging operations? I need to check the code. I'm going to start with a function that sounds relevant: `pmsr_parse_peer`. Hmm, now I need to figure out which commands actually call `pmsr_parse_peer`. Let's search for calls to both `pmsr_parse_peer` and `nl80211_pmsr_start`, which seems like a likely entry point for these kinds of processes. This is where I'll find my answers.



10/2 2026/10/14 16:39 tool grepper
0m Args:
{
  "Expression": "nl80211_pmsr_start"
}

Results:
{
  "Output": "net/wireless/nl80211.c=21266=static const struct genl_small_ops nl80211_small_ops[] = {\n--\nnet/wireless/nl80211.c-22021-\t\t.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,\nnet/wireless/nl80211.c:22022:\t\t.doit = nl80211_pmsr_start,\nnet/wireless/nl80211.c-22023-\t\t.flags = GENL_UNS_ADMIN_PERM,\n--\nnet/wireless/nl80211.h=124=void cfg80211_free_coalesce(struct cfg80211_coalesce *coalesce);\n--\nnet/wireless/nl80211.h-126-/* peer measurement */\nnet/wireless/nl80211.h:127:int nl80211_pmsr_start(struct sk_buff *skb, struct genl_info *info);\nnet/wireless/nl80211.h-128-\n--\nnet/wireless/pmsr.c=405=static int pmsr_parse_peer(struct cfg80211_registered_device *rdev,\n--\nnet/wireless/pmsr.c-531-\nnet/wireless/pmsr.c:532:int nl80211_pmsr_start(struct sk_buff *skb, struct genl_info *info)\nnet/wireless/pmsr.c-533-{\n"
}

11/2 2026/10/14 16:39 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 55764
							output: 37
							thoughts: 30
						

Thoughts:
Okay, here's my take on those thoughts, tailored for an expert audience, presented in the first person:

**Diving into `nl80211_pmsr_start`**

Right, let's take a look at `nl80211_pmsr_start` in `net/wireless/pmsr.c`. I'm going to want to understand exactly how the power management state reporting mechanism gets initiated. Specifically, I'm thinking about the nitty-gritty of the Netlink message handling. What's the initial validation like? What parameters are being extracted from the NL message, and how are they being used to configure the PMSR behavior? Are there any subtle race conditions or concurrency issues to consider here, especially if multiple userspace processes are initiating PMSR sessions simultaneously? I'm particularly curious about how it interacts with the lower layers of the wireless stack – the mac80211 framework, specifically – and how the driver is notified to begin reporting this data. Let's see how the PMSR state is being initialized.



12/2 2026/10/14 16:40 tool read-file
0m Args:
{
  "File": "net/wireless/pmsr.c",
  "FirstLine": 530,
  "LineCount": 80
}

Results:
{
  "Contents": " 530:\t}\n 531:\t\n 532:\tint nl80211_pmsr_start(struct sk_buff *skb, struct genl_info *info)\n 533:\t{\n 534:\t\tstruct nlattr *reqattr = info-\u003eattrs[NL80211_ATTR_PEER_MEASUREMENTS];\n 535:\t\tstruct cfg80211_registered_device *rdev = info-\u003euser_ptr[0];\n 536:\t\tint count, rem, err, idx, peer_count;\n 537:\t\tstruct wireless_dev *wdev = info-\u003euser_ptr[1];\n 538:\t\tconst struct cfg80211_pmsr_capabilities *capa;\n 539:\t\tstruct cfg80211_pmsr_request *req;\n 540:\t\tstruct nlattr *peers, *peer;\n 541:\t\tu64 cookie;\n 542:\t\n 543:\t\tcapa = rdev-\u003ewiphy.pmsr_capa;\n 544:\t\n 545:\t\tif (!capa)\n 546:\t\t\treturn -EOPNOTSUPP;\n 547:\t\n 548:\t\tif (!reqattr)\n 549:\t\t\treturn -EINVAL;\n 550:\t\n 551:\t\tpeers = nla_find(nla_data(reqattr), nla_len(reqattr),\n 552:\t\t\t\t NL80211_PMSR_ATTR_PEERS);\n 553:\t\tif (!peers)\n 554:\t\t\treturn -EINVAL;\n 555:\t\n 556:\t\tcount = 0;\n 557:\t\tnla_for_each_nested(peer, peers, rem) {\n 558:\t\t\tcount++;\n 559:\t\n 560:\t\t\tif (count \u003e capa-\u003emax_peers) {\n 561:\t\t\t\tNL_SET_ERR_MSG_ATTR(info-\u003eextack, peer,\n 562:\t\t\t\t\t\t    \"Too many peers used\");\n 563:\t\t\t\treturn -EINVAL;\n 564:\t\t\t}\n 565:\t\t}\n 566:\t\n 567:\t\tif (!count) {\n 568:\t\t\tNL_SET_ERR_MSG_ATTR(info-\u003eextack, peers, \"No peers specified\");\n 569:\t\t\treturn -EINVAL;\n 570:\t\t}\n 571:\t\n 572:\t\treq = kzalloc_flex(*req, peers, count);\n 573:\t\tif (!req)\n 574:\t\t\treturn -ENOMEM;\n 575:\t\treq-\u003en_peers = count;\n 576:\t\n 577:\t\tif (info-\u003eattrs[NL80211_ATTR_TIMEOUT])\n 578:\t\t\treq-\u003etimeout = nla_get_u32(info-\u003eattrs[NL80211_ATTR_TIMEOUT]);\n 579:\t\n 580:\t\tif (info-\u003eattrs[NL80211_ATTR_MAC]) {\n 581:\t\t\tif (!capa-\u003erandomize_mac_addr) {\n 582:\t\t\t\tNL_SET_ERR_MSG_ATTR(info-\u003eextack,\n 583:\t\t\t\t\t\t    info-\u003eattrs[NL80211_ATTR_MAC],\n 584:\t\t\t\t\t\t    \"device cannot randomize MAC address\");\n 585:\t\t\t\terr = -EINVAL;\n 586:\t\t\t\tgoto out_err;\n 587:\t\t\t}\n 588:\t\n 589:\t\t\terr = nl80211_parse_random_mac(info-\u003eattrs, req-\u003emac_addr,\n 590:\t\t\t\t\t\t       req-\u003emac_addr_mask);\n 591:\t\t\tif (err)\n 592:\t\t\t\tgoto out_err;\n 593:\t\t} else {\n 594:\t\t\tmemcpy(req-\u003emac_addr, wdev_address(wdev), ETH_ALEN);\n 595:\t\t\teth_broadcast_addr(req-\u003emac_addr_mask);\n 596:\t\t}\n 597:\t\n 598:\t\tidx = 0;\n 599:\t\tnla_for_each_nested(peer, peers, rem) {\n 600:\t\t\t/* NB: this reuses info-\u003eattrs, but we no longer need it */\n 601:\t\t\terr = pmsr_parse_peer(rdev, peer, \u0026req-\u003epeers[idx], info);\n 602:\t\t\tif (err)\n 603:\t\t\t\tgoto out_err;\n 604:\t\t\tidx++;\n 605:\t\t}\n 606:\t\n 607:\t\t/* Validate per-role peer limits if advertised */\n 608:\t\tif (capa-\u003eftm.ista.max_peers) {\n 609:\t\t\tpeer_count = 0;\n"
}

13/2 2026/10/14 16:40 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 57323
							output: 26
							thoughts: 45
						

Thoughts:
Okay, here's the summary, framed as my internal thought process, tailored for an expert audience:

**Diving into the NAN Addition Function**

Right, let's get down to brass tacks. I need to understand what's actually happening when a NAN (Neighbor Awareness Networking) service is added via `nl80211`. Time to trace the execution path. My first move? A quick grep for `nl80211_nan_add_func`. This will give me a clear picture of all the potential entry points, showing which commands or functions ultimately call into the `nl80211_nan_add_func` itself. This should allow me to start tracing how the call to it is initiated.



14/2 2026/10/14 16:40 tool grepper
0m Args:
{
  "Expression": "nl80211_nan_add_func"
}

Results:
{
  "Output": "net/wireless/nl80211.c=17384=static int handle_nan_filter(struct nlattr *attr_filter,\n--\nnet/wireless/nl80211.c-17430-\nnet/wireless/nl80211.c:17431:static int nl80211_nan_add_func(struct sk_buff *skb,\nnet/wireless/nl80211.c-17432-\t\t\t\tstruct genl_info *info)\n--\nnet/wireless/nl80211.c=21266=static const struct genl_small_ops nl80211_small_ops[] = {\n--\nnet/wireless/nl80211.c-21826-\t\t.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,\nnet/wireless/nl80211.c:21827:\t\t.doit = nl80211_nan_add_func,\nnet/wireless/nl80211.c-21828-\t\t.flags = GENL_ADMIN_PERM,\n"
}

15/2 2026/10/14 16:40 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 57855
							output: 42
							thoughts: 30
						

Thoughts:
Okay, here's my interpretation of that thought process, tailored for an expert audience, and written in the first person:

**Analyzing the `nl80211_nan_add_func` Trigger**

Alright, let's dive into this. My immediate focus is to pinpoint the exact command within the `nl80211` subsystem that ultimately *triggers* the `nl80211_nan_add_func` function call, specifically around line 21826. Knowing the initiating command is key for understanding the broader context of what's happening. I need to trace back from that function call to the specific Netlink message or action that sets things in motion. Is it a regulatory setting, a NAN configuration request, a station setup, or something completely different? Knowing the triggering command unlocks a lot. I'm thinking I'll start with a code search or maybe a debugger to quickly identify which Netlink message or structure is likely the culprit.



16/2 2026/10/14 16:41 tool read-file
0m Args:
{
  "File": "net/wireless/nl80211.c",
  "FirstLine": 21820,
  "LineCount": 20
}

Results:
{
  "Contents": "21820:\t\t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP |\n21821:\t\t\t\t\t\t NL80211_FLAG_NO_WIPHY_MTX |\n21822:\t\t\t\t\t\t NL80211_FLAG_NEED_RTNL),\n21823:\t\t},\n21824:\t\t{\n21825:\t\t\t.cmd = NL80211_CMD_ADD_NAN_FUNCTION,\n21826:\t\t\t.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,\n21827:\t\t\t.doit = nl80211_nan_add_func,\n21828:\t\t\t.flags = GENL_ADMIN_PERM,\n21829:\t\t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),\n21830:\t\t},\n21831:\t\t{\n21832:\t\t\t.cmd = NL80211_CMD_DEL_NAN_FUNCTION,\n21833:\t\t\t.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,\n21834:\t\t\t.doit = nl80211_nan_del_func,\n21835:\t\t\t.flags = GENL_ADMIN_PERM,\n21836:\t\t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),\n21837:\t\t},\n21838:\t\t{\n21839:\t\t\t.cmd = NL80211_CMD_CHANGE_NAN_CONFIG,\n"
}

17/2 2026/10/14 16:41 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 58577
							output: 20
							thoughts: 357
						

Thoughts:
**My Analysis of NAN Function Addition**

Okay, so I'm looking at the `NL80211_CMD_ADD_NAN_FUNCTION` command and how it's handled. The core of it, the `doit` function, points to `nl80211_nan_add_func`. Now, there's this critical check within that function, specifically this:

```c
	if (wdev->wiphy->nan_capa.flags & WIPHY_NAN_FLAGS_USERSPACE_DE) {
		NL_SET_ERR_MSG(info->extack,
			       "NAN Discovery Engine is in userspace");
		return -EOPNOTSUPP;
	}
```

It's immediately clear that if the `WIPHY_NAN_FLAGS_USERSPACE_DE` flag is set in the `nan_capa.flags` for a wireless device (`wdev`), then the function returns `-EOPNOTSUPP`. That's not ideal for the device, and I need to consider why this is in place. It implies the NAN Discovery Engine is somehow being handled in userspace for that device. I need to understand the implications of this.

The immediate question that springs to mind is, what devices *don't* have this flag set? My next step is to examine the kernel source. I need to identify which devices in the kernel tree actually support NAN, and then cross-reference those against the usage of `nan_capa.flags`. I want to quickly understand which device drivers are *not* using this userspace DE.

I'm going to search the entire kernel tree for all instances of `nan_capa.flags`. This should give me a quick overview of how this flag is used across the various drivers. Hopefully, that will give me some insight into the intent of this check.



18/2 2026/10/14 16:41 tool grepper
0m Args:
{
  "Expression": "nan_capa\\.flags"
}

Results:
{
  "Output": "drivers/net/wireless/intel/iwlwifi/mld/mac80211.c=268=static void iwl_mld_hw_set_nan(struct iwl_mld *mld)\n--\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-279-\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c:280:\thw-\u003ewiphy-\u003enan_capa.flags = WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC |\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-281-\t\t\t\t    WIPHY_NAN_FLAGS_USERSPACE_DE;\n--\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c=751=int mt792x_init_wiphy(struct ieee80211_hw *hw)\n--\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c-801-\t\t\t\t\t      BIT(NL80211_BAND_5GHZ);\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c:802:\t\twiphy-\u003enan_capa.flags = WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC |\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c-803-\t\t\t\t\tWIPHY_NAN_FLAGS_USERSPACE_DE;\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c=5722=static int mac80211_hwsim_new_radio(struct genl_info *info,\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-5846-\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:5847:\t\thw-\u003ewiphy-\u003enan_capa.flags = WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC |\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-5848-\t\t\t\t\t    WIPHY_NAN_FLAGS_USERSPACE_DE |\n--\nnet/mac80211/cfg.c=493=static int ieee80211_add_nan_func(struct wiphy *wiphy,\n--\nnet/mac80211/cfg.c-505-\nnet/mac80211/cfg.c:506:\tif (WARN_ON(wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_USERSPACE_DE))\nnet/mac80211/cfg.c-507-\t\treturn -EOPNOTSUPP;\n--\nnet/mac80211/cfg.c=551=static void ieee80211_del_nan_func(struct wiphy *wiphy,\n--\nnet/mac80211/cfg.c-561-\nnet/mac80211/cfg.c:562:\tif (WARN_ON(wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_USERSPACE_DE))\nnet/mac80211/cfg.c-563-\t\treturn;\n--\nnet/mac80211/cfg.c=5546=void ieee80211_nan_func_terminated(struct ieee80211_vif *vif,\n--\nnet/mac80211/cfg.c-5557-\nnet/mac80211/cfg.c:5558:\tif (WARN_ON(sdata-\u003elocal-\u003ehw.wiphy-\u003enan_capa.flags \u0026\nnet/mac80211/cfg.c-5559-\t\t    WIPHY_NAN_FLAGS_USERSPACE_DE))\n--\nnet/mac80211/cfg.c=5582=void ieee80211_nan_func_match(struct ieee80211_vif *vif,\n--\nnet/mac80211/cfg.c-5591-\nnet/mac80211/cfg.c:5592:\tif (WARN_ON(sdata-\u003elocal-\u003ehw.wiphy-\u003enan_capa.flags \u0026\nnet/mac80211/cfg.c-5593-\t\t    WIPHY_NAN_FLAGS_USERSPACE_DE))\n--\nnet/mac80211/iface.c=479=static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_down)\n--\nnet/mac80211/iface.c-646-\t\t/* clean all the functions */\nnet/mac80211/iface.c:647:\t\tif (!(local-\u003ehw.wiphy-\u003enan_capa.flags \u0026\nnet/mac80211/iface.c-648-\t\t      WIPHY_NAN_FLAGS_USERSPACE_DE)) {\n--\nnet/mac80211/iface.c=1914=static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata,\n--\nnet/mac80211/iface.c-1988-\tcase NL80211_IFTYPE_NAN:\nnet/mac80211/iface.c:1989:\t\tif (!(sdata-\u003elocal-\u003ehw.wiphy-\u003enan_capa.flags \u0026\nnet/mac80211/iface.c-1990-\t\t      WIPHY_NAN_FLAGS_USERSPACE_DE)) {\n--\nnet/mac80211/main.c=1142=int ieee80211_register_hw(struct ieee80211_hw *hw)\n--\nnet/mac80211/main.c-1168-\t\t    ((!local-\u003eops-\u003estart_nan || !local-\u003eops-\u003estop_nan) ||\nnet/mac80211/main.c:1169:\t\t     (local-\u003ehw.wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_USERSPACE_DE \u0026\u0026\nnet/mac80211/main.c-1170-\t\t     (local-\u003eops-\u003eadd_nan_func || local-\u003eops-\u003edel_nan_func)))))\n--\nnet/mac80211/util.c=1806=static int ieee80211_reconfig_nan(struct ieee80211_sub_if_data *sdata)\n--\nnet/mac80211/util.c-1816-\nnet/mac80211/util.c:1817:\tif (!(sdata-\u003elocal-\u003ehw.wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_USERSPACE_DE))\nnet/mac80211/util.c-1818-\t\treturn ieee80211_reconfig_nan_offload_de(sdata);\n--\nnet/wireless/core.c=904=int wiphy_register(struct wiphy *wiphy)\n--\nnet/wireless/core.c-941-\nnet/wireless/core.c:942:\tif (WARN_ON((wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_INSTANT_COMM) \u0026\u0026\nnet/wireless/core.c:943:\t\t    !(wiphy-\u003enan_capa.flags \u0026\nnet/wireless/core.c-944-\t\t      WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC)))\n--\nnet/wireless/core.c-947-\t/* Instant Communication requires user space to track NAN beacons */\nnet/wireless/core.c:948:\tif (WARN_ON((wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_INSTANT_COMM) \u0026\u0026\nnet/wireless/core.c-949-\t\t    (!wiphy-\u003emgmt_stypes ||\n--\nnet/wireless/nl80211.c=3175=static int nl80211_put_nan_capa(struct wiphy *wiphy, struct sk_buff *msg)\n--\nnet/wireless/nl80211.c-3182-\nnet/wireless/nl80211.c:3183:\tif (wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC \u0026\u0026\nnet/wireless/nl80211.c-3184-\t    nla_put_flag(msg, NL80211_NAN_CAPA_CONFIGURABLE_SYNC))\n--\nnet/wireless/nl80211.c-3186-\nnet/wireless/nl80211.c:3187:\tif ((wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_USERSPACE_DE) \u0026\u0026\nnet/wireless/nl80211.c-3188-\t    nla_put_flag(msg, NL80211_NAN_CAPA_USERSPACE_DE))\n--\nnet/wireless/nl80211.c-3190-\nnet/wireless/nl80211.c:3191:\tif ((wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_INSTANT_COMM) \u0026\u0026\nnet/wireless/nl80211.c-3192-\t    nla_put_flag(msg, NL80211_NAN_CAPA_INSTANT_COMM))\n--\nnet/wireless/nl80211.c-3194-\nnet/wireless/nl80211.c:3195:\tif ((wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_OFFLOAD_RANGING) \u0026\u0026\nnet/wireless/nl80211.c-3196-\t    nla_put_flag(msg, NL80211_NAN_CAPA_OFFLOAD_RANGING))\n--\nnet/wireless/nl80211.c-3198-\nnet/wireless/nl80211.c:3199:\tif ((wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_OFFLOAD_NDP) \u0026\u0026\nnet/wireless/nl80211.c-3200-\t    nla_put_flag(msg, NL80211_NAN_CAPA_OFFLOAD_NDP))\n--\nnet/wireless/nl80211.c=15287=static int nl80211_register_mgmt(struct sk_buff *skb, struct genl_info *info)\n--\nnet/wireless/nl80211.c-15312-\t\t\t\t\t     NL80211_EXT_FEATURE_SECURE_NAN) \u0026\u0026\nnet/wireless/nl80211.c:15313:\t\t    !(wdev-\u003ewiphy-\u003enan_capa.flags \u0026\nnet/wireless/nl80211.c-15314-\t\t      WIPHY_NAN_FLAGS_USERSPACE_DE))\n--\nnet/wireless/nl80211.c=15361=static int nl80211_tx_mgmt(struct sk_buff *skb, struct genl_info *info)\n--\nnet/wireless/nl80211.c-15397-\t\t\t\t\t     NL80211_EXT_FEATURE_SECURE_NAN) \u0026\u0026\nnet/wireless/nl80211.c:15398:\t\t    !(wdev-\u003ewiphy-\u003enan_capa.flags \u0026\nnet/wireless/nl80211.c-15399-\t\t      WIPHY_NAN_FLAGS_USERSPACE_DE))\n--\nnet/wireless/nl80211.c=17151=static int nl80211_parse_nan_conf(struct wiphy *wiphy,\n--\nnet/wireless/nl80211.c-17275-\tif (conf-\u003einstant_comm) {\nnet/wireless/nl80211.c:17276:\t\tif (!(wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_INSTANT_COMM)) {\nnet/wireless/nl80211.c-17277-\t\t\tNL_SET_ERR_MSG_ATTR(info-\u003eextack,\n--\nnet/wireless/nl80211.c=17431=static int nl80211_nan_add_func(struct sk_buff *skb,\n--\nnet/wireless/nl80211.c-17447-\nnet/wireless/nl80211.c:17448:\tif (wdev-\u003ewiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_USERSPACE_DE) {\nnet/wireless/nl80211.c-17449-\t\tNL_SET_ERR_MSG(info-\u003eextack,\n--\nnet/wireless/nl80211.c-17650-\t\tif ((sdea \u0026 NL80211_NAN_FUNC_SDEA_CTRL_DATAPATH_REQUIRED) \u0026\u0026\nnet/wireless/nl80211.c:17651:\t\t    !(wdev-\u003ewiphy-\u003enan_capa.flags \u0026\nnet/wireless/nl80211.c-17652-\t\t      WIPHY_NAN_FLAGS_OFFLOAD_NDP)) {\n--\nnet/wireless/nl80211.c-17735-\nnet/wireless/nl80211.c:17736:\t\tif (!(wdev-\u003ewiphy-\u003enan_capa.flags \u0026\nnet/wireless/nl80211.c-17737-\t\t      WIPHY_NAN_FLAGS_OFFLOAD_RANGING) ||\n--\nnet/wireless/nl80211.c=17945=void cfg80211_nan_match(struct wireless_dev *wdev,\n--\nnet/wireless/nl80211.c-17953-\nnet/wireless/nl80211.c:17954:\tif (WARN_ON(wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_USERSPACE_DE))\nnet/wireless/nl80211.c-17955-\t\treturn;\n--\nnet/wireless/nl80211.c=18080=void cfg80211_nan_func_terminated(struct wireless_dev *wdev,\n--\nnet/wireless/nl80211.c-18090-\nnet/wireless/nl80211.c:18091:\tif (WARN_ON(wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_USERSPACE_DE))\nnet/wireless/nl80211.c-18092-\t\treturn;\n--\nnet/wireless/nl80211.c=18504=static int nl80211_nan_ndp_initiate(struct sk_buff *skb,\n--\nnet/wireless/nl80211.c-18518-\nnet/wireless/nl80211.c:18519:\tif (!(rdev-\u003ewiphy.nan_capa.flags \u0026 WIPHY_NAN_FLAGS_OFFLOAD_NDP)) {\nnet/wireless/nl80211.c-18520-\t\tNL_SET_ERR_MSG(info-\u003eextack,\n--\nnet/wireless/nl80211.c=18629=static int nl80211_nan_ndp_respond(struct sk_buff *skb,\n--\nnet/wireless/nl80211.c-18643-\nnet/wireless/nl80211.c:18644:\tif (!(rdev-\u003ewiphy.nan_capa.flags \u0026 WIPHY_NAN_FLAGS_OFFLOAD_NDP)) {\nnet/wireless/nl80211.c-18645-\t\tNL_SET_ERR_MSG(info-\u003eextack,\n--\nnet/wireless/nl80211.c=18750=static int nl80211_nan_ndp_terminate(struct sk_buff *skb,\n--\nnet/wireless/nl80211.c-18764-\nnet/wireless/nl80211.c:18765:\tif (!(rdev-\u003ewiphy.nan_capa.flags \u0026 WIPHY_NAN_FLAGS_OFFLOAD_NDP)) {\nnet/wireless/nl80211.c-18766-\t\tNL_SET_ERR_MSG(info-\u003eextack,\n--\nnet/wireless/nl80211.c=18802=void cfg80211_nan_ndp_request(struct wireless_dev *wdev,\n--\nnet/wireless/nl80211.c-18811-\nnet/wireless/nl80211.c:18812:\tif (WARN_ON(!(wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_OFFLOAD_NDP)))\nnet/wireless/nl80211.c-18813-\t\treturn;\n--\nnet/wireless/nl80211.c=18881=void cfg80211_nan_ndp_confirm(struct wireless_dev *wdev,\n--\nnet/wireless/nl80211.c-18890-\nnet/wireless/nl80211.c:18891:\tif (WARN_ON(!(wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_OFFLOAD_NDP)))\nnet/wireless/nl80211.c-18892-\t\treturn;\n--\nnet/wireless/nl80211.c=18955=void cfg80211_nan_ndp_terminated(struct wireless_dev *wdev,\n--\nnet/wireless/nl80211.c-18964-\nnet/wireless/nl80211.c:18965:\tif (WARN_ON(!(wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_OFFLOAD_NDP)))\nnet/wireless/nl80211.c-18966-\t\treturn;\n"
}

19/2 2026/10/14 16:41 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 64027
							output: 18
							thoughts: 427
						

Thoughts:
**NAN Capabilities - A Deep Dive**

Okay, hold on a second. I need to take a closer look at how Wi-Fi drivers are setting the `wiphy->nan_capa.flags` field.  I see a few suspects: `iwl_mld_hw_set_nan` in the Intel iwlwifi driver, `mt792x_init_wiphy` from Mediatek's mt76, and `mac80211_hwsim_new_radio` for mac80211_hwsim. Interesting. Now, I need to know which drivers utilize those specific offload flags.

Wait.  I need to verify something really quickly, let's see which drivers are actually using the `WIPHY_NAN_FLAGS_OFFLOAD_NDP` flag?  ...Hmm, *none*! Okay, now how about `WIPHY_NAN_FLAGS_OFFLOAD_RANGING`? Same result, *none*!

But, what about other drivers setting the `wiphy->nan_capa.flags` *without* including `WIPHY_NAN_FLAGS_USERSPACE_DE`?  That's the key. I need to understand if anyone is deviating from that common pattern.  Let me explicitly check for that specific case.  Does *any* driver fail to set `WIPHY_NAN_FLAGS_USERSPACE_DE`?

Okay, let's drill down into the specific drivers.  In `iwl_mld_hw_set_nan`, I see the standard: `hw->wiphy->nan_capa.flags = WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC | WIPHY_NAN_FLAGS_USERSPACE_DE;`.  `mt792x_init_wiphy` does the same: `wiphy->nan_capa.flags = WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC | WIPHY_NAN_FLAGS_USERSPACE_DE;`.  And in `mac80211_hwsim_new_radio`, it's: `hw->wiphy->nan_capa.flags = WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC | WIPHY_NAN_FLAGS_USERSPACE_DE | WIPHY_NAN_FLAGS_INSTANT_COMM;`.

Aha!  So the standard pattern is pretty consistent.  But, I can't be *completely* sure. There could be others. I need to perform a full scan. Is there *any* other driver setting the `nan_capa` field?  Let's do a comprehensive search of the codebase.



20/2 2026/10/14 16:41 tool grepper
0m Args:
{
  "Expression": "nan_capa"
}

Results:
{
  "Output": "\nFull output is too long, showing 200 out of 315 lines.\nUse more precise expression or PathPrefixes if possible.\n\nNumber of matching lines per file (13 files in total):\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c:8\ndrivers/net/wireless/intel/iwlwifi/mld/tlc.c:1\ndrivers/net/wireless/mediatek/mt76/mt7925/init.c:3\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c:5\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:7\ninclude/net/cfg80211.h:4\ninclude/uapi/linux/nl80211.h:3\nnet/mac80211/cfg.c:7\nnet/mac80211/iface.c:2\nnet/mac80211/main.c:1\nnet/mac80211/util.c:1\nnet/wireless/core.c:4\nnet/wireless/nl80211.c:29\n\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c=268=static void iwl_mld_hw_set_nan(struct iwl_mld *mld)\n--\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-279-\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c:280:\thw-\u003ewiphy-\u003enan_capa.flags = WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC |\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-281-\t\t\t\t    WIPHY_NAN_FLAGS_USERSPACE_DE;\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-282-\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c:283:\thw-\u003ewiphy-\u003enan_capa.op_mode = NAN_OP_MODE_PHY_MODE_VHT |\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-284-\t\t\t\t      NAN_OP_MODE_PHY_MODE_HE |\n--\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-286-\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c:287:\thw-\u003ewiphy-\u003enan_capa.n_antennas =\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-288-\t\t(hweight32(hw-\u003ewiphy-\u003eavailable_antennas_tx) \u0026\n--\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-295-\tif (mld-\u003efw-\u003eucode_capa.nan_max_chan_switch_time)\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c:296:\t\thw-\u003ewiphy-\u003enan_capa.max_channel_switch_time =\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-297-\t\t\tmld-\u003efw-\u003eucode_capa.nan_max_chan_switch_time;\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-298-\telse\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c:299:\t\thw-\u003ewiphy-\u003enan_capa.max_channel_switch_time =\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-300-\t\t\t4 * USEC_PER_MSEC;\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-301-\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c:302:\thw-\u003ewiphy-\u003enan_capa.phy.ht = mld-\u003envm_data-\u003enan_phy_capa.ht;\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c:303:\thw-\u003ewiphy-\u003enan_capa.phy.vht = mld-\u003envm_data-\u003enan_phy_capa.vht;\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c:304:\thw-\u003ewiphy-\u003enan_capa.phy.he = mld-\u003envm_data-\u003enan_phy_capa.he;\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-305-}\n--\ndrivers/net/wireless/intel/iwlwifi/mld/tlc.c=638=static void iwl_mld_config_tlc_nan(struct iwl_mld *mld,\n--\ndrivers/net/wireless/intel/iwlwifi/mld/tlc.c-712-\ndrivers/net/wireless/intel/iwlwifi/mld/tlc.c:713:\t\tcapa.own_he_cap = \u0026mld-\u003ewiphy-\u003enan_capa.phy.he;\ndrivers/net/wireless/intel/iwlwifi/mld/tlc.c-714-\t\t/* no EHT/UHR for NAN */\n--\ndrivers/net/wireless/mediatek/mt76/mt7925/init.c=163=static int mt7925_init_nan_cap(struct mt76_dev *mdev)\n--\ndrivers/net/wireless/mediatek/mt76/mt7925/init.c-174-\tif (sband)\ndrivers/net/wireless/mediatek/mt76/mt7925/init.c:175:\t\twiphy-\u003enan_capa.phy.ht = sband-\u003eht_cap;\ndrivers/net/wireless/mediatek/mt76/mt7925/init.c-176-\n--\ndrivers/net/wireless/mediatek/mt76/mt7925/init.c-178-\tif (sband)\ndrivers/net/wireless/mediatek/mt76/mt7925/init.c:179:\t\twiphy-\u003enan_capa.phy.vht = sband-\u003evht_cap;\ndrivers/net/wireless/mediatek/mt76/mt7925/init.c-180-\n--\ndrivers/net/wireless/mediatek/mt76/mt7925/init.c-184-\tif (he_cap)\ndrivers/net/wireless/mediatek/mt76/mt7925/init.c:185:\t\twiphy-\u003enan_capa.phy.he = *he_cap;\ndrivers/net/wireless/mediatek/mt76/mt7925/init.c-186-\n--\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c=751=int mt792x_init_wiphy(struct ieee80211_hw *hw)\n--\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c-801-\t\t\t\t\t      BIT(NL80211_BAND_5GHZ);\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c:802:\t\twiphy-\u003enan_capa.flags = WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC |\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c-803-\t\t\t\t\tWIPHY_NAN_FLAGS_USERSPACE_DE;\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c:804:\t\twiphy-\u003enan_capa.op_mode = NAN_OP_MODE_PHY_MODE_MASK;\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c:805:\t\twiphy-\u003enan_capa.n_antennas = 0x22;\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c:806:\t\twiphy-\u003enan_capa.max_channel_switch_time = 12;\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c:807:\t\twiphy-\u003enan_capa.dev_capabilities = NAN_DEV_CAPA_EXT_KEY_ID_SUPPORTED;\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c-808-\t\twiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_SECURE_NAN);\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c=5722=static int mac80211_hwsim_new_radio(struct genl_info *info,\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-5846-\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:5847:\t\thw-\u003ewiphy-\u003enan_capa.flags = WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC |\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-5848-\t\t\t\t\t    WIPHY_NAN_FLAGS_USERSPACE_DE |\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-5849-\t\t\t\t\t    WIPHY_NAN_FLAGS_INSTANT_COMM;\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:5850:\t\thw-\u003ewiphy-\u003enan_capa.op_mode = NAN_OP_MODE_PHY_MODE_MASK |\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-5851-\t\t\t\t\t      NAN_OP_MODE_80P80MHZ |\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-5853-\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:5854:\t\thw-\u003ewiphy-\u003enan_capa.n_antennas = 0x22;\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:5855:\t\thw-\u003ewiphy-\u003enan_capa.max_channel_switch_time = 0;\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-5856-\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-5877-\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:5878:\t\thw-\u003ewiphy-\u003enan_capa.phy.ht = hwsim_nan_ht_cap;\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:5879:\t\thw-\u003ewiphy-\u003enan_capa.phy.vht = hwsim_nan_vht_cap;\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:5880:\t\thw-\u003ewiphy-\u003enan_capa.phy.he = hwsim_nan_he_cap;\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-5881-\n--\ninclude/net/cfg80211.h=6615=enum wiphy_nan_flags {\n--\ninclude/net/cfg80211.h-6623-/**\ninclude/net/cfg80211.h:6624: * struct wiphy_nan_capa - NAN capabilities\ninclude/net/cfg80211.h-6625- *\n--\ninclude/net/cfg80211.h-6644- */\ninclude/net/cfg80211.h:6645:struct wiphy_nan_capa {\ninclude/net/cfg80211.h-6646-\tu32 flags;\n--\ninclude/net/cfg80211.h-6831- *\t(i.e. BIT(NL80211_BAND_2GHZ)).\ninclude/net/cfg80211.h:6832: * @nan_capa: NAN capabilities\ninclude/net/cfg80211.h-6833- *\n--\ninclude/net/cfg80211.h=6891=struct wiphy {\n--\ninclude/net/cfg80211.h-7013-\tu8 nan_supported_bands;\ninclude/net/cfg80211.h:7014:\tstruct wiphy_nan_capa nan_capa;\ninclude/net/cfg80211.h-7015-\n--\ninclude/uapi/linux/nl80211.h=1504=enum nl80211_commands {\n--\ninclude/uapi/linux/nl80211.h-3136- *\tThis is used with %NL80211_CMD_GET_WIPHY to indicate the NAN\ninclude/uapi/linux/nl80211.h:3137: *\tcapabilities supported by the driver. See \u0026enum nl80211_nan_capabilities\ninclude/uapi/linux/nl80211.h-3138- *\tfor details.\n--\ninclude/uapi/linux/nl80211.h=9363=enum nl80211_s1g_short_beacon_attrs {\n--\ninclude/uapi/linux/nl80211.h-9375-/**\ninclude/uapi/linux/nl80211.h:9376: * enum nl80211_nan_capabilities - NAN (Neighbor Aware Networking)\ninclude/uapi/linux/nl80211.h-9377- *\tcapabilities.\n--\ninclude/uapi/linux/nl80211.h-9423- */\ninclude/uapi/linux/nl80211.h:9424:enum nl80211_nan_capabilities {\ninclude/uapi/linux/nl80211.h-9425-\t__NL80211_NAN_CAPABILITIES_INVALID,\n--\nnet/mac80211/cfg.c=493=static int ieee80211_add_nan_func(struct wiphy *wiphy,\n--\nnet/mac80211/cfg.c-505-\nnet/mac80211/cfg.c:506:\tif (WARN_ON(wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_USERSPACE_DE))\nnet/mac80211/cfg.c-507-\t\treturn -EOPNOTSUPP;\n--\nnet/mac80211/cfg.c=551=static void ieee80211_del_nan_func(struct wiphy *wiphy,\n--\nnet/mac80211/cfg.c-561-\nnet/mac80211/cfg.c:562:\tif (WARN_ON(wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_USERSPACE_DE))\nnet/mac80211/cfg.c-563-\t\treturn;\n--\nnet/mac80211/cfg.c=2566=static int sta_link_apply_parameters(struct ieee80211_local *local,\n--\nnet/mac80211/cfg.c-2620-\tif (sdata-\u003evif.type == NL80211_IFTYPE_NAN) {\nnet/mac80211/cfg.c:2621:\t\town_ht_cap = \u0026local-\u003ehw.wiphy-\u003enan_capa.phy.ht;\nnet/mac80211/cfg.c:2622:\t\town_vht_cap = \u0026local-\u003ehw.wiphy-\u003enan_capa.phy.vht;\nnet/mac80211/cfg.c:2623:\t\town_he_cap = \u0026local-\u003ehw.wiphy-\u003enan_capa.phy.he;\nnet/mac80211/cfg.c-2624-\t} else {\n--\nnet/mac80211/cfg.c=5546=void ieee80211_nan_func_terminated(struct ieee80211_vif *vif,\n--\nnet/mac80211/cfg.c-5557-\nnet/mac80211/cfg.c:5558:\tif (WARN_ON(sdata-\u003elocal-\u003ehw.wiphy-\u003enan_capa.flags \u0026\nnet/mac80211/cfg.c-5559-\t\t    WIPHY_NAN_FLAGS_USERSPACE_DE))\n--\nnet/mac80211/cfg.c=5582=void ieee80211_nan_func_match(struct ieee80211_vif *vif,\n--\nnet/mac80211/cfg.c-5591-\nnet/mac80211/cfg.c:5592:\tif (WARN_ON(sdata-\u003elocal-\u003ehw.wiphy-\u003enan_capa.flags \u0026\nnet/mac80211/cfg.c-5593-\t\t    WIPHY_NAN_FLAGS_USERSPACE_DE))\n--\nnet/mac80211/iface.c=479=static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_down)\n--\nnet/mac80211/iface.c-646-\t\t/* clean all the functions */\nnet/mac80211/iface.c:647:\t\tif (!(local-\u003ehw.wiphy-\u003enan_capa.flags \u0026\nnet/mac80211/iface.c-648-\t\t      WIPHY_NAN_FLAGS_USERSPACE_DE)) {\n--\nnet/mac80211/iface.c=1914=static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata,\n--\nnet/mac80211/iface.c-1988-\tcase NL80211_IFTYPE_NAN:\nnet/mac80211/iface.c:1989:\t\tif (!(sdata-\u003elocal-\u003ehw.wiphy-\u003enan_capa.flags \u0026\nnet/mac80211/iface.c-1990-\t\t      WIPHY_NAN_FLAGS_USERSPACE_DE)) {\n--\nnet/mac80211/main.c=1142=int ieee80211_register_hw(struct ieee80211_hw *hw)\n--\nnet/mac80211/main.c-1168-\t\t    ((!local-\u003eops-\u003estart_nan || !local-\u003eops-\u003estop_nan) ||\nnet/mac80211/main.c:1169:\t\t     (local-\u003ehw.wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_USERSPACE_DE \u0026\u0026\nnet/mac80211/main.c-1170-\t\t     (local-\u003eops-\u003eadd_nan_func || local-\u003eops-\u003edel_nan_func)))))\n--\nnet/mac80211/util.c=1806=static int ieee80211_reconfig_nan(struct ieee80211_sub_if_data *sdata)\n--\nnet/mac80211/util.c-1816-\nnet/mac80211/util.c:1817:\tif (!(sdata-\u003elocal-\u003ehw.wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_USERSPACE_DE))\nnet/mac80211/util.c-1818-\t\treturn ieee80211_reconfig_nan_offload_de(sdata);\n--\nnet/wireless/core.c=904=int wiphy_register(struct wiphy *wiphy)\n--\nnet/wireless/core.c-938-\tif (WARN_ON((wiphy-\u003einterface_modes \u0026 BIT(NL80211_IFTYPE_NAN_DATA)) \u0026\u0026\nnet/wireless/core.c:939:\t\t    (!wiphy-\u003enan_capa.phy.ht.ht_supported || wiphy-\u003en_radio \u003e 1)))\nnet/wireless/core.c-940-\t\treturn -EINVAL;\nnet/wireless/core.c-941-\nnet/wireless/core.c:942:\tif (WARN_ON((wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_INSTANT_COMM) \u0026\u0026\nnet/wireless/core.c:943:\t\t    !(wiphy-\u003enan_capa.flags \u0026\nnet/wireless/core.c-944-\t\t      WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC)))\n--\nnet/wireless/core.c-947-\t/* Instant Communication requires user space to track NAN beacons */\nnet/wireless/core.c:948:\tif (WARN_ON((wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_INSTANT_COMM) \u0026\u0026\nnet/wireless/core.c-949-\t\t    (!wiphy-\u003emgmt_stypes ||\n--\nnet/wireless/nl80211.c=3113=static int nl80211_put_nan_phy_cap(struct wiphy *wiphy, struct sk_buff *msg)\n--\nnet/wireless/nl80211.c-3122-\nnet/wireless/nl80211.c:3123:\tht_cap = \u0026wiphy-\u003enan_capa.phy.ht;\nnet/wireless/nl80211.c:3124:\tvht_cap = \u0026wiphy-\u003enan_capa.phy.vht;\nnet/wireless/nl80211.c:3125:\the_cap = \u0026wiphy-\u003enan_capa.phy.he;\nnet/wireless/nl80211.c-3126-\n--\nnet/wireless/nl80211.c-3174-\nnet/wireless/nl80211.c:3175:static int nl80211_put_nan_capa(struct wiphy *wiphy, struct sk_buff *msg)\nnet/wireless/nl80211.c-3176-{\n--\nnet/wireless/nl80211.c-3182-\nnet/wireless/nl80211.c:3183:\tif (wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC \u0026\u0026\nnet/wireless/nl80211.c-3184-\t    nla_put_flag(msg, NL80211_NAN_CAPA_CONFIGURABLE_SYNC))\n--\nnet/wireless/nl80211.c-3186-\nnet/wireless/nl80211.c:3187:\tif ((wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_USERSPACE_DE) \u0026\u0026\n\n"
}

21/2 2026/10/14 16:41 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 71075
							output: 19
							thoughts: 325
						

Thoughts:
**NAN Capability Flag Analysis**

Okay, here's what's running through my mind. I see that several drivers, specifically `iwl_mld`, `mt792x`, and `mac80211_hwsim`, are all setting the `nan_capa.flags` field in their respective Wi-Fi PHY (Wiphy) configurations. They all seem to be setting `WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC` and `WIPHY_NAN_FLAGS_USERSPACE_DE`. But wait a minute, are these the *only* drivers involved? I need to make sure I have a complete picture.

My immediate next thought is to investigate if there are any drivers *not* setting `WIPHY_NAN_FLAGS_USERSPACE_DE`. Is zero the default value if it's not set? That would be useful information. This leads me to a more crucial thought: what about drivers that don't even *support* NAN, or drivers that register with a default value of zero for this flag? That's a critical oversight.

Okay, let's step back. If `wiphy->nan_capa.flags` is zero, how does the system know? Ah! Are any drivers registering an `nl80211_nan_add_func` or, more generally, an `rdev->ops->add_nan_func`? That's the real test. I need to scan the entire codebase and specifically search for `add_nan_func`. That's where I will find the answer.



22/2 2026/10/14 16:41 tool grepper
0m Args:
{
  "Expression": "add_nan_func"
}

Results:
{
  "Output": "include/net/cfg80211.h=5112=struct mgmt_frame_regs {\n--\ninclude/net/cfg80211.h-5469- * @stop_nan: Stop the NAN interface.\ninclude/net/cfg80211.h:5470: * @add_nan_func: Add a NAN function. Returns negative value on failure.\ninclude/net/cfg80211.h-5471- *\tOn success @nan_func ownership is transferred to the driver and\n--\ninclude/net/cfg80211.h=5582=struct cfg80211_ops {\n--\ninclude/net/cfg80211.h-5897-\tvoid\t(*stop_nan)(struct wiphy *wiphy, struct wireless_dev *wdev);\ninclude/net/cfg80211.h:5898:\tint\t(*add_nan_func)(struct wiphy *wiphy, struct wireless_dev *wdev,\ninclude/net/cfg80211.h-5899-\t\t\t\tstruct cfg80211_nan_func *nan_func);\n--\ninclude/net/mac80211.h=4077=struct ieee80211_prep_tx_info {\n--\ninclude/net/mac80211.h-4678- *\tchanged parameters.\ninclude/net/mac80211.h:4679: * @add_nan_func: Add a NAN function. Returns 0 on success. The data in\ninclude/net/mac80211.h-4680- *\tcfg80211_nan_func must not be referenced outside the scope of\n--\ninclude/net/mac80211.h=4764=struct ieee80211_ops {\n--\ninclude/net/mac80211.h-5101-\t\t\t       struct cfg80211_nan_conf *conf, u32 changes);\ninclude/net/mac80211.h:5102:\tint (*add_nan_func)(struct ieee80211_hw *hw,\ninclude/net/mac80211.h-5103-\t\t\t    struct ieee80211_vif *vif,\n--\nnet/mac80211/cfg.c=452=static int ieee80211_nan_change_conf(struct wiphy *wiphy,\n--\nnet/mac80211/cfg.c-492-\nnet/mac80211/cfg.c:493:static int ieee80211_add_nan_func(struct wiphy *wiphy,\nnet/mac80211/cfg.c-494-\t\t\t\t  struct wireless_dev *wdev,\n--\nnet/mac80211/cfg.c-522-\nnet/mac80211/cfg.c:523:\tret = drv_add_nan_func(sdata-\u003elocal, sdata, nan_func);\nnet/mac80211/cfg.c-524-\tif (ret) {\n--\nnet/mac80211/cfg.c=6312=const struct cfg80211_ops mac80211_config_ops = {\n--\nnet/mac80211/cfg.c-6407-\t.nan_change_conf = ieee80211_nan_change_conf,\nnet/mac80211/cfg.c:6408:\t.add_nan_func = ieee80211_add_nan_func,\nnet/mac80211/cfg.c-6409-\t.del_nan_func = ieee80211_del_nan_func,\n--\nnet/mac80211/driver-ops.h=1489=static inline int drv_nan_change_conf(struct ieee80211_local *local,\n--\nnet/mac80211/driver-ops.h-1510-\nnet/mac80211/driver-ops.h:1511:static inline int drv_add_nan_func(struct ieee80211_local *local,\nnet/mac80211/driver-ops.h-1512-\t\t\t\t   struct ieee80211_sub_if_data *sdata,\n--\nnet/mac80211/driver-ops.h-1520-\nnet/mac80211/driver-ops.h:1521:\tif (!local-\u003eops-\u003eadd_nan_func)\nnet/mac80211/driver-ops.h-1522-\t\treturn -EOPNOTSUPP;\nnet/mac80211/driver-ops.h-1523-\nnet/mac80211/driver-ops.h:1524:\ttrace_drv_add_nan_func(local, sdata, nan_func);\nnet/mac80211/driver-ops.h:1525:\tret = local-\u003eops-\u003eadd_nan_func(\u0026local-\u003ehw, \u0026sdata-\u003evif, nan_func);\nnet/mac80211/driver-ops.h-1526-\ttrace_drv_return_int(local, ret);\n--\nnet/mac80211/main.c=1142=int ieee80211_register_hw(struct ieee80211_hw *hw)\n--\nnet/mac80211/main.c-1169-\t\t     (local-\u003ehw.wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_USERSPACE_DE \u0026\u0026\nnet/mac80211/main.c:1170:\t\t     (local-\u003eops-\u003eadd_nan_func || local-\u003eops-\u003edel_nan_func)))))\nnet/mac80211/main.c-1171-\t\treturn -EINVAL;\n--\nnet/mac80211/trace.h=2090=TRACE_EVENT(drv_nan_change_conf,\n--\nnet/mac80211/trace.h-2120-\nnet/mac80211/trace.h:2121:TRACE_EVENT(drv_add_nan_func,\nnet/mac80211/trace.h-2122-\tTP_PROTO(struct ieee80211_local *local,\n--\nnet/mac80211/util.c=1773=ieee80211_reconfig_nan_offload_de(struct ieee80211_sub_if_data *sdata)\n--\nnet/mac80211/util.c-1793-\tfor (i = 0; funcs[i]; i++) {\nnet/mac80211/util.c:1794:\t\tres = drv_add_nan_func(sdata-\u003elocal, sdata, funcs[i]);\nnet/mac80211/util.c-1795-\t\tif (WARN_ON(res))\n--\nnet/wireless/core.c=904=int wiphy_register(struct wiphy *wiphy)\n--\nnet/wireless/core.c-933-\t\t    (!rdev-\u003eops-\u003estart_nan || !rdev-\u003eops-\u003estop_nan ||\nnet/wireless/core.c:934:\t\t     !rdev-\u003eops-\u003eadd_nan_func || !rdev-\u003eops-\u003edel_nan_func ||\nnet/wireless/core.c-935-\t\t     !(wiphy-\u003enan_supported_bands \u0026 BIT(NL80211_BAND_2GHZ)))))\n--\nnet/wireless/nl80211.c=17431=static int nl80211_nan_add_func(struct sk_buff *skb,\n--\nnet/wireless/nl80211.c-17825-\nnet/wireless/nl80211.c:17826:\terr = rdev_add_nan_func(rdev, wdev, func);\nnet/wireless/nl80211.c-17827-out:\n--\nnet/wireless/rdev-ops.h=1080=static inline int\nnet/wireless/rdev-ops.h:1081:rdev_add_nan_func(struct cfg80211_registered_device *rdev,\nnet/wireless/rdev-ops.h-1082-\t\t  struct wireless_dev *wdev,\n--\nnet/wireless/rdev-ops.h-1086-\nnet/wireless/rdev-ops.h:1087:\ttrace_rdev_add_nan_func(\u0026rdev-\u003ewiphy, wdev, nan_func);\nnet/wireless/rdev-ops.h:1088:\tret = rdev-\u003eops-\u003eadd_nan_func(\u0026rdev-\u003ewiphy, wdev, nan_func);\nnet/wireless/rdev-ops.h-1089-\ttrace_rdev_return_int(\u0026rdev-\u003ewiphy, ret);\n--\nnet/wireless/trace.h=2437=DEFINE_EVENT(wiphy_wdev_evt, rdev_stop_pd,\n--\nnet/wireless/trace.h-2441-\nnet/wireless/trace.h:2442:TRACE_EVENT(rdev_add_nan_func,\nnet/wireless/trace.h-2443-\tTP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,\n"
}

23/2 2026/10/14 16:41 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 74191
							output: 17
							thoughts: 453
						

Thoughts:
**Investigating NAN Support in mac80211**

Okay, let's break this down. I'm looking at how NAN (Neighbor Awareness Networking) is handled within the mac80211 framework. Specifically, I'm focusing on the configuration and registration aspects. I've found a few key points in `net/mac80211/cfg.c` regarding the relevant operations. I see that `mac80211_config_ops` defines the function pointers for NAN-related configuration which includes `.nan_change_conf`, `.add_nan_func`, and `.del_nan_func` through `ieee80211_nan_change_conf`, `ieee80211_add_nan_func`, and `ieee80211_del_nan_func` respectively.

Now, I'm digging into `wiphy_register`. The logic here is critical. If a Wi-Fi PHY (`wiphy`) claims to support `NL80211_IFTYPE_NAN`, the registration process *demands* the presence of `start_nan`, `stop_nan`, `add_nan_func`, and `del_nan_func` operations in the associated `rdev->ops` structure *and* that it supports 2GHz band. This is a crucial check to ensure the driver's readiness.

This is where it gets interesting, I also spot a similar check during hardware registration within `ieee80211_register_hw`. The code there seems to be handling the user-space implementation by requiring `start_nan` or `stop_nan` but not requiring `add_nan_func` or `del_nan_func` if `WIPHY_NAN_FLAGS_USERSPACE_DE` is set.

My current thought is to understand the scope and implementation of this, I need to find the drivers that are registering `start_nan` or `add_nan_func` and which ones are registering `NL80211_IFTYPE_NAN` since these functions are the key building blocks for any NAN implementation. I have a list of function to start from to do some analysis of the current implementation.



24/2 2026/10/14 16:42 tool grepper
0m Args:
{
  "Expression": "start_nan"
}

Results:
{
  "Output": "drivers/net/wireless/intel/iwlwifi/mld/mac80211.c=2914=const struct ieee80211_ops iwl_mld_hw_ops = {\n--\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-2988-\t.can_neg_ttlm = iwl_mld_can_neg_ttlm,\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c:2989:\t.start_nan = iwl_mld_start_nan,\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-2990-\t.stop_nan = iwl_mld_stop_nan,\n--\ndrivers/net/wireless/intel/iwlwifi/mld/nan.c=146=static int iwl_mld_nan_config(struct iwl_mld *mld,\n--\ndrivers/net/wireless/intel/iwlwifi/mld/nan.c-232-\ndrivers/net/wireless/intel/iwlwifi/mld/nan.c:233:int iwl_mld_start_nan(struct ieee80211_hw *hw, struct ieee80211_vif *vif,\ndrivers/net/wireless/intel/iwlwifi/mld/nan.c-234-\t\t      struct cfg80211_nan_conf *conf)\n--\ndrivers/net/wireless/intel/iwlwifi/mld/nan.h=29=bool iwl_mld_nan_supported(struct iwl_mld *mld);\ndrivers/net/wireless/intel/iwlwifi/mld/nan.h:30:int iwl_mld_start_nan(struct ieee80211_hw *hw,\ndrivers/net/wireless/intel/iwlwifi/mld/nan.h-31-\t\t      struct ieee80211_vif *vif,\n--\ndrivers/net/wireless/mediatek/mt76/mt7925/main.c=2595=static void mt7925_channel_switch_rx_beacon(struct ieee80211_hw *hw,\n--\ndrivers/net/wireless/mediatek/mt76/mt7925/main.c-2618-\ndrivers/net/wireless/mediatek/mt76/mt7925/main.c:2619:static int mt7925_start_nan(struct ieee80211_hw *hw,\ndrivers/net/wireless/mediatek/mt76/mt7925/main.c-2620-\t\t\t    struct ieee80211_vif *vif,\n--\ndrivers/net/wireless/mediatek/mt76/mt7925/main.c=2761=const struct ieee80211_ops mt7925_ops = {\n--\ndrivers/net/wireless/mediatek/mt76/mt7925/main.c-2829-\t.channel_switch_rx_beacon = mt7925_channel_switch_rx_beacon,\ndrivers/net/wireless/mediatek/mt76/mt7925/main.c:2830:\t.start_nan = mt7925_start_nan,\ndrivers/net/wireless/mediatek/mt76/mt7925/main.c-2831-\t.stop_nan = mt7925_stop_nan,\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c=4286=static int mac80211_hwsim_set_radar_background(struct ieee80211_hw *hw,\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-4338-\t.set_rts_threshold = mac80211_hwsim_set_rts_threshold,\t\\\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:4339:\t.start_nan = mac80211_hwsim_nan_start,\t\t\t\\\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-4340-\t.stop_nan = mac80211_hwsim_nan_stop,\t\t\t\\\n--\ninclude/net/cfg80211.h=5112=struct mgmt_frame_regs {\n--\ninclude/net/cfg80211.h-5467- *\tpeers must be on the base channel when the call completes.\ninclude/net/cfg80211.h:5468: * @start_nan: Start the NAN interface.\ninclude/net/cfg80211.h-5469- * @stop_nan: Stop the NAN interface.\n--\ninclude/net/cfg80211.h=5582=struct cfg80211_ops {\n--\ninclude/net/cfg80211.h-5894-\t\t\t\t\t      const u8 *addr);\ninclude/net/cfg80211.h:5895:\tint\t(*start_nan)(struct wiphy *wiphy, struct wireless_dev *wdev,\ninclude/net/cfg80211.h-5896-\t\t\t     struct cfg80211_nan_conf *conf);\n--\ninclude/net/mac80211.h=4077=struct ieee80211_prep_tx_info {\n--\ninclude/net/mac80211.h-4670- *\ninclude/net/mac80211.h:4671: * @start_nan: join an existing NAN cluster, or create a new one.\ninclude/net/mac80211.h-4672- * @stop_nan: leave the NAN cluster.\n--\ninclude/net/mac80211.h=4764=struct ieee80211_ops {\n--\ninclude/net/mac80211.h-5093-\ninclude/net/mac80211.h:5094:\tint (*start_nan)(struct ieee80211_hw *hw,\ninclude/net/mac80211.h-5095-\t\t\t struct ieee80211_vif *vif,\n--\nnet/mac80211/cfg.c=355=static int ieee80211_nan_conf_copy(struct cfg80211_nan_conf *dst,\n--\nnet/mac80211/cfg.c-413-\nnet/mac80211/cfg.c:414:static int ieee80211_start_nan(struct wiphy *wiphy,\nnet/mac80211/cfg.c-415-\t\t\t       struct wireless_dev *wdev,\n--\nnet/mac80211/cfg.c-433-\nnet/mac80211/cfg.c:434:\tret = drv_start_nan(sdata-\u003elocal, sdata, conf);\nnet/mac80211/cfg.c-435-\tif (ret) {\n--\nnet/mac80211/cfg.c=6312=const struct cfg80211_ops mac80211_config_ops = {\n--\nnet/mac80211/cfg.c-6404-\t.del_tx_ts = ieee80211_del_tx_ts,\nnet/mac80211/cfg.c:6405:\t.start_nan = ieee80211_start_nan,\nnet/mac80211/cfg.c-6406-\t.stop_nan = ieee80211_stop_nan,\n--\nnet/mac80211/driver-ops.h=1445=static inline void drv_abort_pmsr(struct ieee80211_local *local,\n--\nnet/mac80211/driver-ops.h-1460-\nnet/mac80211/driver-ops.h:1461:static inline int drv_start_nan(struct ieee80211_local *local,\nnet/mac80211/driver-ops.h-1462-\t\t\t\tstruct ieee80211_sub_if_data *sdata,\n--\nnet/mac80211/driver-ops.h-1470-\nnet/mac80211/driver-ops.h:1471:\ttrace_drv_start_nan(local, sdata, conf);\nnet/mac80211/driver-ops.h:1472:\tret = local-\u003eops-\u003estart_nan(\u0026local-\u003ehw, \u0026sdata-\u003evif, conf);\nnet/mac80211/driver-ops.h-1473-\ttrace_drv_return_int(local, ret);\n--\nnet/mac80211/main.c=1142=int ieee80211_register_hw(struct ieee80211_hw *hw)\n--\nnet/mac80211/main.c-1167-\t\t\tBIT(NL80211_IFTYPE_NAN) \u0026\u0026\nnet/mac80211/main.c:1168:\t\t    ((!local-\u003eops-\u003estart_nan || !local-\u003eops-\u003estop_nan) ||\nnet/mac80211/main.c-1169-\t\t     (local-\u003ehw.wiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_USERSPACE_DE \u0026\u0026\n--\nnet/mac80211/trace.h=2022=TRACE_EVENT(drv_get_expected_throughput,\n--\nnet/mac80211/trace.h-2039-\nnet/mac80211/trace.h:2040:TRACE_EVENT(drv_start_nan,\nnet/mac80211/trace.h-2041-\tTP_PROTO(struct ieee80211_local *local,\n--\nnet/mac80211/util.c=1806=static int ieee80211_reconfig_nan(struct ieee80211_sub_if_data *sdata)\n--\nnet/mac80211/util.c-1812-\nnet/mac80211/util.c:1813:\tres = drv_start_nan(local, sdata, \u0026sdata-\u003eu.nan.conf);\nnet/mac80211/util.c-1814-\tif (WARN_ON(res))\n--\nnet/wireless/core.c=904=int wiphy_register(struct wiphy *wiphy)\n--\nnet/wireless/core.c-932-\tif (WARN_ON((wiphy-\u003einterface_modes \u0026 BIT(NL80211_IFTYPE_NAN)) \u0026\u0026\nnet/wireless/core.c:933:\t\t    (!rdev-\u003eops-\u003estart_nan || !rdev-\u003eops-\u003estop_nan ||\nnet/wireless/core.c-934-\t\t     !rdev-\u003eops-\u003eadd_nan_func || !rdev-\u003eops-\u003edel_nan_func ||\n--\nnet/wireless/nl80211.c=17151=static int nl80211_parse_nan_conf(struct wiphy *wiphy,\n--\nnet/wireless/nl80211.c-17316-\nnet/wireless/nl80211.c:17317:static int nl80211_start_nan(struct sk_buff *skb, struct genl_info *info)\nnet/wireless/nl80211.c-17318-{\n--\nnet/wireless/nl80211.c-17340-\nnet/wireless/nl80211.c:17341:\terr = rdev_start_nan(rdev, wdev, \u0026conf);\nnet/wireless/nl80211.c-17342-\tif (err)\n--\nnet/wireless/nl80211.c=21266=static const struct genl_small_ops nl80211_small_ops[] = {\n--\nnet/wireless/nl80211.c-21809-\t\t.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,\nnet/wireless/nl80211.c:21810:\t\t.doit = nl80211_start_nan,\nnet/wireless/nl80211.c-21811-\t\t.flags = GENL_ADMIN_PERM,\n--\nnet/wireless/rdev-ops.h=1052=static inline void rdev_stop_p2p_device(struct cfg80211_registered_device *rdev,\n--\nnet/wireless/rdev-ops.h-1059-\nnet/wireless/rdev-ops.h:1060:static inline int rdev_start_nan(struct cfg80211_registered_device *rdev,\nnet/wireless/rdev-ops.h-1061-\t\t\t\t struct wireless_dev *wdev,\n--\nnet/wireless/rdev-ops.h-1065-\nnet/wireless/rdev-ops.h:1066:\ttrace_rdev_start_nan(\u0026rdev-\u003ewiphy, wdev, conf);\nnet/wireless/rdev-ops.h:1067:\tret = rdev-\u003eops-\u003estart_nan(\u0026rdev-\u003ewiphy, wdev, conf);\nnet/wireless/rdev-ops.h-1068-\ttrace_rdev_return_int(\u0026rdev-\u003ewiphy, ret);\n--\nnet/wireless/trace.h=2376=DEFINE_EVENT(wiphy_wdev_evt, rdev_stop_p2p_device,\n--\nnet/wireless/trace.h-2380-\nnet/wireless/trace.h:2381:TRACE_EVENT(rdev_start_nan,\nnet/wireless/trace.h-2382-\tTP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,\n"
}

25/2 2026/10/14 16:42 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 78800
							output: 53
							thoughts: 1890
						

Thoughts:
**NAN Discovery Engine Userspace Interaction Analysis**

Okay, here's the breakdown of my thought process. I started digging into the NAN (Neighbor Awareness Networking) Discovery Engine code, specifically looking at the interaction between the kernel and userspace for NAN function addition. The initial trigger was likely a bug report or a curious question about the user space integration.

My train of thought goes like this:

1.  I started with `drivers/net/wireless/virtual/mac80211_hwsim_main.c` because it's a simulated wireless device, and a good place to start experimenting. I quickly confirmed that `mac80211_hwsim` sets up the necessary NAN capabilities (`.start_nan`, `.stop_nan`), and critically, configures `WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC`, `WIPHY_NAN_FLAGS_USERSPACE_DE`, and `WIPHY_NAN_FLAGS_INSTANT_COMM`.
2.  Then, I moved to `net/mac80211/main.c`, focusing on how `mac80211` handles NAN interface types. I noticed a critical check: if `WIPHY_NAN_FLAGS_USERSPACE_DE` is set, `local->ops->add_nan_func` should *not* be set. However, *if* `WIPHY_NAN_FLAGS_USERSPACE_DE` is *not* set, then `local->ops->add_nan_func` *can* be set (for offloaded DE). This immediately raised a red flag.
3.  Next, I drilled down into `net/wireless/nl80211.c`, specifically `nl80211_nan_add_func`, which handles the `NL80211_CMD_NAN_ADD_FUNCTION` netlink command. I realized that this function contains a *new* check that explicitly returns `-EOPNOTSUPP` if `WIPHY_NAN_FLAGS_USERSPACE_DE` is set. This was added in a patch. This is super important: if a driver *claims* to have a userspace Discovery Engine, then this specific function should reject the netlink request.
4.  I then took a detour and searched if any other driver supports a configuration that *doesn't* have `WIPHY_NAN_FLAGS_USERSPACE_DE`. But all of the supported drivers, specifically, `iwl_mld`, `mt792x`, and `mac80211_hwsim` *all* do have `WIPHY_NAN_FLAGS_USERSPACE_DE`, and the investigation revealed no others exist in the tree.
5.  I then investigated the `net/wireless/core.c` file and found another check: that if a wiphy supports NAN but *doesn't* have the correct NAN operations, it should return `-EINVAL`.
6.  Back in `mac80211`, I recalled that the driver provides `ieee80211_add_nan_func`, and I examined `net/mac80211/cfg.c` and found that `ieee80211_add_nan_func` calls a function that does the same `WARN_ON(wiphy->nan_capa.flags & WIPHY_NAN_FLAGS_USERSPACE_DE)` check!
7.  The key realization hit: the initial netlink request goes through `nl80211_nan_add_func`. If the device claims a userspace DE, `nl80211_nan_add_func` returns an error *before* the driver-specific `add_nan_func` is ever called. However, this check was added in a patch.
8.  I then verified that `mac80211_hwsim` *does* support `NL80211_IFTYPE_NAN`, making it reachable. This is significant because it means a syzkaller fuzz target *could* trigger this exact scenario. With the addition of this patch to reject a call from userspace if DE is set, the crash is avoided.

In summary, this deep dive confirms that the patch adding a check in `nl80211_nan_add_func` correctly prevents a crash condition caused by calling the deprecated `add_nan_func` when the NAN Discovery Engine is configured for userspace operation. The simulated `mac80211_hwsim` driver, which supports NAN, is *directly* involved in this flow, which means fuzzing this function is super important.



26/2 2026/10/14 16:42 tool grepper
0m Args:
{
  "Expression": "NL80211_IFTYPE_NAN",
  "PathPrefixes": [
    "drivers/net/wireless/virtual/mac80211_hwsim_main.c"
  ]
}

Results:
{
  "Output": "drivers/net/wireless/virtual/mac80211_hwsim_main.c=1786=static void mac80211_hwsim_tx_iter(void *_data, u8 *addr,\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-1791-\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:1792:\tif (vif-\u003etype == NL80211_IFTYPE_NAN ||\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:1793:\t    vif-\u003etype == NL80211_IFTYPE_NAN_DATA) {\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-1794-\t\tdata-\u003ereceive = mac80211_hwsim_nan_receive(data-\u003ehw,\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c=2111=static void mac80211_hwsim_tx(struct ieee80211_hw *hw,\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-2142-\tif (vif \u0026\u0026 !data-\u003etmp_chan \u0026\u0026\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:2143:\t    (vif-\u003etype == NL80211_IFTYPE_NAN ||\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:2144:\t     vif-\u003etype == NL80211_IFTYPE_NAN_DATA)) {\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-2145-\t\tstruct cfg80211_chan_def chandef;\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c=2305=void ieee80211_hwsim_wake_tx_queue(struct ieee80211_hw *hw,\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-2312-\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:2313:\tif ((txq-\u003evif-\u003etype == NL80211_IFTYPE_NAN ||\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:2314:\t     txq-\u003evif-\u003etype == NL80211_IFTYPE_NAN_DATA) \u0026\u0026\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-2315-\t    !mac80211_hwsim_nan_txq_transmitting(hw, txq))\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c=2808=mac80211_hwsim_sta_rc_update(struct ieee80211_hw *hw,\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-2817-\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:2818:\tif (vif-\u003etype == NL80211_IFTYPE_NAN ||\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:2819:\t    vif-\u003etype == NL80211_IFTYPE_NAN_DATA)\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-2820-\t\treturn;\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c=5722=static int mac80211_hwsim_new_radio(struct genl_info *info,\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-5838-\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:5839:\tif (param-\u003eiftypes \u0026 BIT(NL80211_IFTYPE_NAN)) {\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-5840-\t\tdata-\u003eif_limits[n_limits].max = 1;\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:5841:\t\tdata-\u003eif_limits[n_limits].types = BIT(NL80211_IFTYPE_NAN);\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-5842-\t\tn_limits++;\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-5872-\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:5873:\tif (param-\u003eiftypes \u0026 BIT(NL80211_IFTYPE_NAN_DATA)) {\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-5874-\t\tdata-\u003eif_limits[n_limits].max = 2;\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:5875:\t\tdata-\u003eif_limits[n_limits].types = BIT(NL80211_IFTYPE_NAN_DATA);\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-5876-\t\tn_limits++;\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c=6308=static int mac80211_hwsim_get_radio(struct sk_buff *skb,\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-6332-\tparam.nan_device = !!(data-\u003ehw-\u003ewiphy-\u003einterface_modes \u0026\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:6333:\t\t\t\t\tBIT(NL80211_IFTYPE_NAN));\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-6334-\tparam.use_chanctx = data-\u003euse_chanctx;\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c=6910=static int hwsim_new_radio_nl(struct sk_buff *msg, struct genl_info *info)\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-6998-\t\t}\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:6999:\t\tparam.iftypes |= BIT(NL80211_IFTYPE_NAN) |\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:7000:\t\t\t\t BIT(NL80211_IFTYPE_NAN_DATA);\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-7001-\t}\n"
}

27/2 2026/10/14 16:42 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 83585
							output: 50
							thoughts: 490
						

Thoughts:
**NAN Capability Conflict in mac80211_hwsim**

Okay, so `mac80211_hwsim` is set up to create radios that support `BIT(NL80211_IFTYPE_NAN)`, that's good. But here's where it gets interesting... what does `mac80211_hwsim_new_radio` actually *set* the `hw->wiphy->nan_capa.flags` to? Ah, it's setting it to `WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC | WIPHY_NAN_FLAGS_USERSPACE_DE | WIPHY_NAN_FLAGS_INSTANT_COMM`.

Now, if I recall, `nl80211_nan_add_func` has that check, right? Let me check... *yes*, there it is:
```c
+	if (wdev->wiphy->nan_capa.flags & WIPHY_NAN_FLAGS_USERSPACE_DE) {
+		NL_SET_ERR_MSG(info->extack,
+			       "NAN Discovery Engine is in userspace");
+		return -EOPNOTSUPP;
+	}
```

Wait a second... *if* `mac80211_hwsim` is setting that `WIPHY_NAN_FLAGS_USERSPACE_DE` flag, then any attempt to call `NL80211_CMD_ADD_NAN_FUNCTION` is *immediately* going to return `-EOPNOTSUPP`. The check will simply fail! This is a problem. What's even the point of the rest of `nl80211_nan_add_func` if this is always returning?

I have to wonder, can *any* wiphy have `nan_capa.flags` without that `WIPHY_NAN_FLAGS_USERSPACE_DE` flag set? Is it *possible* to create a wiphy in `mac80211_hwsim` *without* this flag being present? Does syzkaller or a user space application even have the ability to create radios in `mac80211_hwsim` at all?

Right, let's go back and look at `mac80211_hwsim_new_radio`. I need to review those lines in `drivers/net/wireless/virtual/mac80211_hwsim_main.c` (5835-5865) to be sure. This definitely seems like a potential bug or at least an undesirable behavior. I need to understand this better.



28/2 2026/10/14 16:42 tool read-file
0m Args:
{
  "File": "drivers/net/wireless/virtual/mac80211_hwsim_main.c",
  "FirstLine": 5835,
  "LineCount": 40
}

Results:
{
  "Contents": "5835:\t\t\t\t\t\t\tBIT(NL80211_IFTYPE_P2P_DEVICE);\n5836:\t\t\tn_limits++;\n5837:\t\t}\n5838:\t\n5839:\t\tif (param-\u003eiftypes \u0026 BIT(NL80211_IFTYPE_NAN)) {\n5840:\t\t\tdata-\u003eif_limits[n_limits].max = 1;\n5841:\t\t\tdata-\u003eif_limits[n_limits].types = BIT(NL80211_IFTYPE_NAN);\n5842:\t\t\tn_limits++;\n5843:\t\n5844:\t\t\thw-\u003ewiphy-\u003enan_supported_bands = BIT(NL80211_BAND_2GHZ) |\n5845:\t\t\t\t\t\t\t BIT(NL80211_BAND_5GHZ);\n5846:\t\n5847:\t\t\thw-\u003ewiphy-\u003enan_capa.flags = WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC |\n5848:\t\t\t\t\t\t    WIPHY_NAN_FLAGS_USERSPACE_DE |\n5849:\t\t\t\t\t\t    WIPHY_NAN_FLAGS_INSTANT_COMM;\n5850:\t\t\thw-\u003ewiphy-\u003enan_capa.op_mode = NAN_OP_MODE_PHY_MODE_MASK |\n5851:\t\t\t\t\t\t      NAN_OP_MODE_80P80MHZ |\n5852:\t\t\t\t\t\t      NAN_OP_MODE_160MHZ;\n5853:\t\n5854:\t\t\thw-\u003ewiphy-\u003enan_capa.n_antennas = 0x22;\n5855:\t\t\thw-\u003ewiphy-\u003enan_capa.max_channel_switch_time = 0;\n5856:\t\n5857:\t\t\twiphy_ext_feature_set(hw-\u003ewiphy,\n5858:\t\t\t\t\t      NL80211_EXT_FEATURE_SECURE_NAN);\n5859:\t\n5860:\t\t\thrtimer_setup(\u0026data-\u003enan.slot_timer,\n5861:\t\t\t\t      mac80211_hwsim_nan_slot_timer,\n5862:\t\t\t\t      CLOCK_BOOTTIME, HRTIMER_MODE_ABS_SOFT);\n5863:\t\t\thrtimer_setup(\u0026data-\u003enan.resume_txqs_timer,\n5864:\t\t\t\t      mac80211_hwsim_nan_resume_txqs_timer,\n5865:\t\t\t\t      CLOCK_BOOTTIME, HRTIMER_MODE_ABS_SOFT);\n5866:\t\t\thrtimer_setup(\u0026data-\u003enan.discovery_beacon_timer,\n5867:\t\t\t\t      mac80211_hwsim_nan_discovery_beacon_timer,\n5868:\t\t\t\t      CLOCK_BOOTTIME, HRTIMER_MODE_ABS_SOFT);\n5869:\t\n5870:\t\t\tspin_lock_init(\u0026data-\u003enan.state_lock);\n5871:\t\t}\n5872:\t\n5873:\t\tif (param-\u003eiftypes \u0026 BIT(NL80211_IFTYPE_NAN_DATA)) {\n5874:\t\t\tdata-\u003eif_limits[n_limits].max = 2;\n"
}

29/2 2026/10/14 16:42 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 85507
							output: 17
							thoughts: 478
						

Thoughts:
**NAN Capabilities Deep Dive**

Okay, here's what I'm seeing. In `mac80211_hwsim_main.c`, they're setting `hw->wiphy->nan_capa.flags` to a specific set of NAN capability flags. Interesting. But hold on, where else in the kernel is this `nan_capa.flags` being initialized? Let me check those grep results from before. Ah, there are a couple of other places: `iwl_mld` and `mt792x` both seem to initialize it, but only with `WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC` and `WIPHY_NAN_FLAGS_USERSPACE_DE`. But `mac80211_hwsim` adds `WIPHY_NAN_FLAGS_INSTANT_COMM`.

Now, the real question is, are any other drivers in the kernel even *using* other NAN features? Let me start with `WIPHY_NAN_FLAGS_OFFLOAD_NDP`. Nope, doesn't seem to be anywhere else. Same with `WIPHY_NAN_FLAGS_OFFLOAD_RANGING`. And what about the actual function implementations? Are there any drivers that are implementing `nan_ndp_initiate`, `nan_ndp_respond`, or `nan_ndp_terminate`? Nope, not a single one. And finally, what about the more general `nan_support` flag in `pmsr_capabilities`? Hmm, time to break out another grep and see what the whole landscape looks like! This could be a good starting point for understanding how NAN is utilized in the kernel... or isn't.



30/2 2026/10/14 16:42 tool grepper
0m Args:
{
  "Expression": "nan_support"
}

Results:
{
  "Output": "drivers/net/wireless/intel/iwlwifi/mld/mac80211.c=268=static void iwl_mld_hw_set_nan(struct iwl_mld *mld)\n--\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-274-\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c:275:\thw-\u003ewiphy-\u003enan_supported_bands = BIT(NL80211_BAND_2GHZ);\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-276-\tif (mld-\u003envm_data-\u003ebands[NL80211_BAND_5GHZ].n_channels)\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c:277:\t\thw-\u003ewiphy-\u003enan_supported_bands |=\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-278-\t\t\tBIT(NL80211_BAND_5GHZ);\n--\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c=307=static void iwl_mac_hw_set_wiphy(struct iwl_mld *mld)\n--\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-370-\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c:371:\tif (iwl_mld_nan_supported(mld)) {\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-372-\t\twiphy-\u003en_iface_combinations =\n--\ndrivers/net/wireless/intel/iwlwifi/mld/nan.c-18-\ndrivers/net/wireless/intel/iwlwifi/mld/nan.c:19:bool iwl_mld_nan_supported(struct iwl_mld *mld)\ndrivers/net/wireless/intel/iwlwifi/mld/nan.c-20-{\n--\ndrivers/net/wireless/intel/iwlwifi/mld/nan.h=23=static inline void iwl_mld_cleanup_nan_link(struct iwl_mld_nan_link *nan_link)\n--\ndrivers/net/wireless/intel/iwlwifi/mld/nan.h-28-\ndrivers/net/wireless/intel/iwlwifi/mld/nan.h:29:bool iwl_mld_nan_supported(struct iwl_mld *mld);\ndrivers/net/wireless/intel/iwlwifi/mld/nan.h-30-int iwl_mld_start_nan(struct ieee80211_hw *hw,\n--\ndrivers/net/wireless/mediatek/mt76/mt7925/nan.h=114=enum mt7925_nan_deferred_event {\n--\ndrivers/net/wireless/mediatek/mt76/mt7925/nan.h-119-/* NAN 4.0 Table 79. Device Capability attribute format, Supported Bands */\ndrivers/net/wireless/mediatek/mt76/mt7925/nan.h:120:enum nan_supported_bands {\ndrivers/net/wireless/mediatek/mt76/mt7925/nan.h-121-\tNAN_SUPPORTED_BAND_ID_2P4G = 2,\n--\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c=751=int mt792x_init_wiphy(struct ieee80211_hw *hw)\n--\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c-799-\t\t\t\t\t  BIT(NL80211_IFTYPE_NAN_DATA);\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c:800:\t\twiphy-\u003enan_supported_bands = BIT(NL80211_BAND_2GHZ) |\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c-801-\t\t\t\t\t      BIT(NL80211_BAND_5GHZ);\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c=5722=static int mac80211_hwsim_new_radio(struct genl_info *info,\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-5843-\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:5844:\t\thw-\u003ewiphy-\u003enan_supported_bands = BIT(NL80211_BAND_2GHZ) |\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-5845-\t\t\t\t\t\t BIT(NL80211_BAND_5GHZ);\n--\ninclude/net/cfg80211.h=6400=cfg80211_get_iftype_ext_capa(struct wiphy *wiphy, enum nl80211_iftype type);\n--\ninclude/net/cfg80211.h-6472- *\tPD stands for proximity detection\ninclude/net/cfg80211.h:6473: * @ftm.type.nan_support: supports NAN ranging as defined in\ninclude/net/cfg80211.h-6474- *\tthe \"Wi-Fi Aware Specification v4.0, clause 8\".\n--\ninclude/net/cfg80211.h=6483=struct cfg80211_pmsr_capabilities {\n--\ninclude/net/cfg80211.h-6525-\t\t\t   pd_support:1,\ninclude/net/cfg80211.h:6526:\t\t\t   nan_support:1;\ninclude/net/cfg80211.h-6527-\t\t} type;\n--\ninclude/net/cfg80211.h=6645=struct wiphy_nan_capa {\n--\ninclude/net/cfg80211.h-6827- *\ninclude/net/cfg80211.h:6828: * @nan_supported_bands: bands supported by the device in NAN mode, a\ninclude/net/cfg80211.h-6829- *\tbitmap of \u0026enum nl80211_band values.  For instance, for\n--\ninclude/net/cfg80211.h=6891=struct wiphy {\n--\ninclude/net/cfg80211.h-7012-\ninclude/net/cfg80211.h:7013:\tu8 nan_supported_bands;\ninclude/net/cfg80211.h-7014-\tstruct wiphy_nan_capa nan_capa;\n--\nnet/wireless/core.c=904=int wiphy_register(struct wiphy *wiphy)\n--\nnet/wireless/core.c-934-\t\t     !rdev-\u003eops-\u003eadd_nan_func || !rdev-\u003eops-\u003edel_nan_func ||\nnet/wireless/core.c:935:\t\t     !(wiphy-\u003enan_supported_bands \u0026 BIT(NL80211_BAND_2GHZ)))))\nnet/wireless/core.c-936-\t\treturn -EINVAL;\n--\nnet/wireless/nl80211.c=2639=nl80211_send_pmsr_ftm_capa(const struct cfg80211_pmsr_capabilities *cap,\n--\nnet/wireless/nl80211.c-2782-\tif (cap-\u003eftm.type.infra_support || cap-\u003eftm.type.pd_support ||\nnet/wireless/nl80211.c:2783:\t    cap-\u003eftm.type.nan_support) {\nnet/wireless/nl80211.c-2784-\t\tstruct nlattr *pd_caps;\n--\nnet/wireless/nl80211.c-2798-\nnet/wireless/nl80211.c:2799:\t\tif (cap-\u003eftm.type.nan_support \u0026\u0026\nnet/wireless/nl80211.c-2800-\t\t    nla_put_flag(msg, NL80211_PMSR_FTM_TYPE_CAPA_ATTR_NAN_SUPPORT))\n--\nnet/wireless/nl80211.c=3232=static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev,\n--\nnet/wireless/nl80211.c-3810-\t\tif (nla_put_u32(msg, NL80211_ATTR_BANDS,\nnet/wireless/nl80211.c:3811:\t\t\t\trdev-\u003ewiphy.nan_supported_bands))\nnet/wireless/nl80211.c-3812-\t\t\tgoto nla_put_failure;\n--\nnet/wireless/nl80211.c=17105=static int nl80211_parse_nan_band_config(struct wiphy *wiphy,\n--\nnet/wireless/nl80211.c-17109-{\nnet/wireless/nl80211.c:17110:\tif (BIT(band) \u0026 ~(u32)wiphy-\u003enan_supported_bands)\nnet/wireless/nl80211.c-17111-\t\treturn -EINVAL;\n--\nnet/wireless/nl80211.c=17151=static int nl80211_parse_nan_conf(struct wiphy *wiphy,\n--\nnet/wireless/nl80211.c-17171-\nnet/wireless/nl80211.c:17172:\t\tif (bands \u0026 ~(u32)wiphy-\u003enan_supported_bands)\nnet/wireless/nl80211.c-17173-\t\t\treturn -EOPNOTSUPP;\n--\nnet/wireless/pmsr.c=405=static int pmsr_parse_peer(struct cfg80211_registered_device *rdev,\n--\nnet/wireless/pmsr.c-445-\tif (out-\u003eftm.request_type == NL80211_PMSR_FTM_REQ_TYPE_NAN) {\nnet/wireless/pmsr.c:446:\t\tif (!rdev-\u003ewiphy.pmsr_capa-\u003eftm.type.nan_support) {\nnet/wireless/pmsr.c-447-\t\t\tNL_SET_ERR_MSG_ATTR(info-\u003eextack,\n"
}

31/2 2026/10/14 16:42 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 89158
							output: 26
							thoughts: 907
						

Thoughts:
**Analyzing the NAN NDP Implementation**

Alright, let's break this down. First, I noticed something interesting: `nan_support` is only defined in `include/net/cfg80211.h` and is used exclusively in `net/wireless/nl80211.c` and `net/wireless/pmsr.c`. More importantly, *no* driver in the entire kernel is setting `nan_support = 1`. This is a significant red flag. I'm also seeing that no driver sets `WIPHY_NAN_FLAGS_OFFLOAD_NDP` or `WIPHY_NAN_FLAGS_OFFLOAD_RANGING` either. This means we're in a situation where the infrastructure *exists*, but it's not actually *used*. This suggests a state of incomplete implementation.

Now, let's dig into the patch's changes function by function. I'll focus on whether any of this code can even be reached.

1.  `nl80211_nan_ndp_initiate`: I see that userspace can invoke `NL80211_CMD_NAN_NDP_INITIATE` via netlink. Syzkaller or any user program can do that. That is interesting. If that happens, the code reaches `if (wdev->iftype != NL80211_IFTYPE_NAN)`. Can we even *have* a `NL80211_IFTYPE_NAN` interface? Yes, with `mac80211_hwsim` we *can*! So that check is passed by the hwsim test. Next, we have `if (!(rdev->wiphy.nan_capa.flags & WIPHY_NAN_FLAGS_OFFLOAD_NDP))`. Since no driver sets `WIPHY_NAN_FLAGS_OFFLOAD_NDP`, this check *always* returns `-EOPNOTSUPP`. This is the same for `nl80211_nan_ndp_respond` and `nl80211_nan_ndp_terminate`: those functions *always* return `-EOPNOTSUPP` too.

What about the `cfg80211_nan_ndp_*` functions? These are driver-facing functions, that drivers would call to notify userspace. I'll go through the call stack for the `cfg80211_nan_ndp_request` and find if any drivers call this.



32/2 2026/10/14 16:42 tool grepper
0m Args:
{
  "Expression": "cfg80211_nan_ndp_"
}

Results:
{
  "Output": "include/net/cfg80211.h=4325=struct cfg80211_nan_peer_sched {\n--\ninclude/net/cfg80211.h-4337-/**\ninclude/net/cfg80211.h:4338: * struct cfg80211_nan_ndp_initiate - NAN NDP initiate parameters\ninclude/net/cfg80211.h-4339- *\n--\ninclude/net/cfg80211.h-4361- */\ninclude/net/cfg80211.h:4362:struct cfg80211_nan_ndp_initiate {\ninclude/net/cfg80211.h-4363-\tconst u8 *peer_nmi;\n--\ninclude/net/cfg80211.h-4381-/**\ninclude/net/cfg80211.h:4382: * struct cfg80211_nan_ndp_respond - NAN NDP respond parameters\ninclude/net/cfg80211.h-4383- *\n--\ninclude/net/cfg80211.h-4404- */\ninclude/net/cfg80211.h:4405:struct cfg80211_nan_ndp_respond {\ninclude/net/cfg80211.h-4406-\tconst u8 *peer_nmi;\n--\ninclude/net/cfg80211.h-4424-/**\ninclude/net/cfg80211.h:4425: * struct cfg80211_nan_ndp_terminate - NAN NDP terminate parameters\ninclude/net/cfg80211.h-4426- *\n--\ninclude/net/cfg80211.h-4431- */\ninclude/net/cfg80211.h:4432:struct cfg80211_nan_ndp_terminate {\ninclude/net/cfg80211.h-4433-\tconst u8 *peer_nmi;\n--\ninclude/net/cfg80211.h-4439-/**\ninclude/net/cfg80211.h:4440: * struct cfg80211_nan_ndp_request_params - NAN NDP request event parameters\ninclude/net/cfg80211.h-4441- *\n--\ninclude/net/cfg80211.h-4460- */\ninclude/net/cfg80211.h:4461:struct cfg80211_nan_ndp_request_params {\ninclude/net/cfg80211.h-4462-\tconst u8 *peer_nmi;\n--\ninclude/net/cfg80211.h-4477-/**\ninclude/net/cfg80211.h:4478: * struct cfg80211_nan_ndp_confirm_params - NAN NDP confirm event parameters\ninclude/net/cfg80211.h-4479- *\n--\ninclude/net/cfg80211.h-4494- */\ninclude/net/cfg80211.h:4495:struct cfg80211_nan_ndp_confirm_params {\ninclude/net/cfg80211.h-4496-\tconst u8 *peer_nmi;\n--\ninclude/net/cfg80211.h-4508-/**\ninclude/net/cfg80211.h:4509: * struct cfg80211_nan_ndp_terminated_params - NAN NDP terminated event\ninclude/net/cfg80211.h-4510- *\n--\ninclude/net/cfg80211.h-4515- */\ninclude/net/cfg80211.h:4516:struct cfg80211_nan_ndp_terminated_params {\ninclude/net/cfg80211.h-4517-\tconst u8 *peer_nmi;\n--\ninclude/net/cfg80211.h=5582=struct cfg80211_ops {\n--\ninclude/net/cfg80211.h-5916-\t\t\t\t    struct wireless_dev *wdev,\ninclude/net/cfg80211.h:5917:\t\t\t\t    struct cfg80211_nan_ndp_initiate *params);\ninclude/net/cfg80211.h-5918-\tint\t(*nan_ndp_respond)(struct wiphy *wiphy,\ninclude/net/cfg80211.h-5919-\t\t\t\t   struct wireless_dev *wdev,\ninclude/net/cfg80211.h:5920:\t\t\t\t   struct cfg80211_nan_ndp_respond *params);\ninclude/net/cfg80211.h-5921-\tint\t(*nan_ndp_terminate)(struct wiphy *wiphy,\ninclude/net/cfg80211.h-5922-\t\t\t\t     struct wireless_dev *wdev,\ninclude/net/cfg80211.h:5923:\t\t\t\t     struct cfg80211_nan_ndp_terminate *params);\ninclude/net/cfg80211.h-5924-\tint\t(*set_multicast_to_unicast)(struct wiphy *wiphy,\n--\ninclude/net/cfg80211.h=11376=cfg80211_s1g_get_primary_sibling(struct wiphy *wiphy,\n--\ninclude/net/cfg80211.h-11401-/**\ninclude/net/cfg80211.h:11402: * cfg80211_nan_ndp_request - notify userspace of a received NDP request\ninclude/net/cfg80211.h-11403- * @wdev: the wireless device reporting the event\n--\ninclude/net/cfg80211.h-11409- */\ninclude/net/cfg80211.h:11410:void cfg80211_nan_ndp_request(struct wireless_dev *wdev,\ninclude/net/cfg80211.h:11411:\t\t\t      struct cfg80211_nan_ndp_request_params *params,\ninclude/net/cfg80211.h-11412-\t\t\t      gfp_t gfp);\n--\ninclude/net/cfg80211.h-11414-/**\ninclude/net/cfg80211.h:11415: * cfg80211_nan_ndp_confirm - notify userspace that NDP setup is complete\ninclude/net/cfg80211.h-11416- * @wdev: the wireless device reporting the event\n--\ninclude/net/cfg80211.h-11423- */\ninclude/net/cfg80211.h:11424:void cfg80211_nan_ndp_confirm(struct wireless_dev *wdev,\ninclude/net/cfg80211.h:11425:\t\t\t      struct cfg80211_nan_ndp_confirm_params *params,\ninclude/net/cfg80211.h-11426-\t\t\t      gfp_t gfp);\n--\ninclude/net/cfg80211.h-11428-/**\ninclude/net/cfg80211.h:11429: * cfg80211_nan_ndp_terminated - notify userspace that an NDP was terminated\ninclude/net/cfg80211.h-11430- * @wdev: the wireless device reporting the event\n--\ninclude/net/cfg80211.h-11436- */\ninclude/net/cfg80211.h:11437:void cfg80211_nan_ndp_terminated(struct wireless_dev *wdev,\ninclude/net/cfg80211.h:11438:\t\t\t\t struct cfg80211_nan_ndp_terminated_params *params,\ninclude/net/cfg80211.h-11439-\t\t\t\t gfp_t gfp);\n--\nnet/wireless/nl80211.c=18504=static int nl80211_nan_ndp_initiate(struct sk_buff *skb,\n--\nnet/wireless/nl80211.c-18509-\tstruct nlattr *tb[NL80211_NAN_NDP_ATTR_MAX + 1];\nnet/wireless/nl80211.c:18510:\tstruct cfg80211_nan_ndp_initiate params = {};\nnet/wireless/nl80211.c-18511-\tint err;\n--\nnet/wireless/nl80211.c=18629=static int nl80211_nan_ndp_respond(struct sk_buff *skb,\n--\nnet/wireless/nl80211.c-18634-\tstruct nlattr *tb[NL80211_NAN_NDP_ATTR_MAX + 1];\nnet/wireless/nl80211.c:18635:\tstruct cfg80211_nan_ndp_respond params = {};\nnet/wireless/nl80211.c-18636-\tint err;\n--\nnet/wireless/nl80211.c=18750=static int nl80211_nan_ndp_terminate(struct sk_buff *skb,\n--\nnet/wireless/nl80211.c-18755-\tstruct nlattr *tb[NL80211_NAN_NDP_ATTR_MAX + 1];\nnet/wireless/nl80211.c:18756:\tstruct cfg80211_nan_ndp_terminate params = {};\nnet/wireless/nl80211.c-18757-\tint err;\n--\nnet/wireless/nl80211.c-18801-\nnet/wireless/nl80211.c:18802:void cfg80211_nan_ndp_request(struct wireless_dev *wdev,\nnet/wireless/nl80211.c:18803:\t\t\t      struct cfg80211_nan_ndp_request_params *params,\nnet/wireless/nl80211.c-18804-\t\t\t      gfp_t gfp)\n--\nnet/wireless/nl80211.c-18878-}\nnet/wireless/nl80211.c:18879:EXPORT_SYMBOL(cfg80211_nan_ndp_request);\nnet/wireless/nl80211.c-18880-\nnet/wireless/nl80211.c:18881:void cfg80211_nan_ndp_confirm(struct wireless_dev *wdev,\nnet/wireless/nl80211.c:18882:\t\t\t      struct cfg80211_nan_ndp_confirm_params *params,\nnet/wireless/nl80211.c-18883-\t\t\t      gfp_t gfp)\n--\nnet/wireless/nl80211.c-18952-}\nnet/wireless/nl80211.c:18953:EXPORT_SYMBOL(cfg80211_nan_ndp_confirm);\nnet/wireless/nl80211.c-18954-\nnet/wireless/nl80211.c:18955:void cfg80211_nan_ndp_terminated(struct wireless_dev *wdev,\nnet/wireless/nl80211.c:18956:\t\t\t\t struct cfg80211_nan_ndp_terminated_params *params,\nnet/wireless/nl80211.c-18957-\t\t\t\t gfp_t gfp)\n--\nnet/wireless/nl80211.c-19002-}\nnet/wireless/nl80211.c:19003:EXPORT_SYMBOL(cfg80211_nan_ndp_terminated);\nnet/wireless/nl80211.c-19004-\n--\nnet/wireless/rdev-ops.h=1187=rdev_nan_ndp_initiate(struct cfg80211_registered_device *rdev,\nnet/wireless/rdev-ops.h-1188-\t\t      struct wireless_dev *wdev,\nnet/wireless/rdev-ops.h:1189:\t\t      struct cfg80211_nan_ndp_initiate *params)\nnet/wireless/rdev-ops.h-1190-{\n--\nnet/wireless/rdev-ops.h=1203=rdev_nan_ndp_respond(struct cfg80211_registered_device *rdev,\nnet/wireless/rdev-ops.h-1204-\t\t     struct wireless_dev *wdev,\nnet/wireless/rdev-ops.h:1205:\t\t     struct cfg80211_nan_ndp_respond *params)\nnet/wireless/rdev-ops.h-1206-{\n--\nnet/wireless/rdev-ops.h=1219=rdev_nan_ndp_terminate(struct cfg80211_registered_device *rdev,\nnet/wireless/rdev-ops.h-1220-\t\t       struct wireless_dev *wdev,\nnet/wireless/rdev-ops.h:1221:\t\t       struct cfg80211_nan_ndp_terminate *params)\nnet/wireless/rdev-ops.h-1222-{\n--\nnet/wireless/trace.h=2555=TRACE_EVENT(rdev_nan_ndp_initiate,\nnet/wireless/trace.h-2556-\tTP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,\nnet/wireless/trace.h:2557:\t\t struct cfg80211_nan_ndp_initiate *params),\nnet/wireless/trace.h-2558-\tTP_ARGS(wiphy, wdev, params),\n--\nnet/wireless/trace.h=2577=TRACE_EVENT(rdev_nan_ndp_respond,\nnet/wireless/trace.h-2578-\tTP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,\nnet/wireless/trace.h:2579:\t\t struct cfg80211_nan_ndp_respond *params),\nnet/wireless/trace.h-2580-\tTP_ARGS(wiphy, wdev, params),\n--\nnet/wireless/trace.h=2601=TRACE_EVENT(rdev_nan_ndp_terminate,\nnet/wireless/trace.h-2602-\tTP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,\nnet/wireless/trace.h:2603:\t\t struct cfg80211_nan_ndp_terminate *params),\nnet/wireless/trace.h-2604-\tTP_ARGS(wiphy, wdev, params),\n"
}

33/2 2026/10/14 16:42 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 94599
							output: 24
							thoughts: 905
						

Thoughts:
**NAN Ranging and NDP Investigation**

Okay, so I'm diving into this NAN ranging and NDP functionality, and initially, I noticed that `cfg80211_nan_ndp_request`, `cfg80211_nan_ndp_confirm`, and `cfg80211_nan_ndp_terminated` don't seem to be called anywhere directly. That's a bit odd. I need to figure out how these pieces are supposed to fit together.

My next thought is to dig into `pmsr_parse_peer` and `pmsr_parse_ftm_nan`, both within `pmsr.c`. Okay, here's what I've found: In `pmsr_parse_peer`, there's a crucial check for `out->ftm.request_type == NL80211_PMSR_FTM_REQ_TYPE_NAN`. Crucially, it then checks `rdev->wiphy.pmsr_capa->ftm.type.nan_support`. Right, and since *no* driver is currently setting `nan_support` to 1, this condition always evaluates to false when it's NAN.  This means that any time the request is NAN, it returns `-EOPNOTSUPP`. That's a problem because `pmsr_parse_ftm_nan` is *only* called when `out->ftm.request_type` is NAN! I can see that clearly in the switch statement: the NAN parsing is conditional on that check! Because of that, `pmsr_parse_ftm_nan` is basically unreachable.

Okay, let's step back and consider if there's any other route to trigger NAN-related functionality. I need to check `nl80211_send_pmsr_ftm_capa` and `nl80211_put_nan_capa`. Here, I see the flags `WIPHY_NAN_FLAGS_OFFLOAD_RANGING` and `WIPHY_NAN_FLAGS_OFFLOAD_NDP`, and I'm looking for where they're set. My hunch is that they're related to offloading the ranging calculations. After inspecting the code, I find that neither flag is set by any driver, and they're both related to the NAN capabilities advertised to userspace.

Hmm, this is leading me down a path of increasing concern.

Finally, I need to check `cfg80211_nan_match`. I need to track down who calls *that*. This will be a critical piece. Let me see where this function is called.



34/2 2026/10/14 16:43 tool grepper
0m Args:
{
  "Expression": "cfg80211_nan_match"
}

Results:
{
  "Output": "include/net/cfg80211.h=10808=void cfg80211_free_nan_func(struct cfg80211_nan_func *f);\n--\ninclude/net/cfg80211.h-10810-/**\ninclude/net/cfg80211.h:10811: * struct cfg80211_nan_match_params - NAN match parameters\ninclude/net/cfg80211.h-10812- * @type: the type of the function that triggered a match. If it is\n--\ninclude/net/cfg80211.h-10842- */\ninclude/net/cfg80211.h:10843:struct cfg80211_nan_match_params {\ninclude/net/cfg80211.h-10844-\tenum nl80211_nan_function_type type;\n--\ninclude/net/cfg80211.h-10868-/**\ninclude/net/cfg80211.h:10869: * cfg80211_nan_match - report a match for a NAN function.\ninclude/net/cfg80211.h-10870- * @wdev: the wireless device reporting the match\n--\ninclude/net/cfg80211.h-10877- */\ninclude/net/cfg80211.h:10878:void cfg80211_nan_match(struct wireless_dev *wdev,\ninclude/net/cfg80211.h:10879:\t\t\tstruct cfg80211_nan_match_params *match, gfp_t gfp);\ninclude/net/cfg80211.h-10880-\n--\ninclude/net/mac80211.h=7982=void ieee80211_nan_func_match(struct ieee80211_vif *vif,\ninclude/net/mac80211.h:7983:\t\t\t      struct cfg80211_nan_match_params *match,\ninclude/net/mac80211.h-7984-\t\t\t      gfp_t gfp);\n--\nnet/mac80211/cfg.c=5582=void ieee80211_nan_func_match(struct ieee80211_vif *vif,\nnet/mac80211/cfg.c:5583:\t\t\t      struct cfg80211_nan_match_params *match,\nnet/mac80211/cfg.c-5584-\t\t\t      gfp_t gfp)\n--\nnet/mac80211/cfg.c-5606-\nnet/mac80211/cfg.c:5607:\tcfg80211_nan_match(ieee80211_vif_to_wdev(vif), match, gfp);\nnet/mac80211/cfg.c-5608-}\n--\nnet/wireless/nl80211.c=17932=static int nl80211_stop_pd(struct sk_buff *skb, struct genl_info *info)\n--\nnet/wireless/nl80211.c-17944-\nnet/wireless/nl80211.c:17945:void cfg80211_nan_match(struct wireless_dev *wdev,\nnet/wireless/nl80211.c:17946:\t\t\tstruct cfg80211_nan_match_params *match, gfp_t gfp)\nnet/wireless/nl80211.c-17947-{\n--\nnet/wireless/nl80211.c-18077-}\nnet/wireless/nl80211.c:18078:EXPORT_SYMBOL(cfg80211_nan_match);\nnet/wireless/nl80211.c-18079-\n"
}

35/2 2026/10/14 16:43 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 97161
							output: 27
							thoughts: 22
						

Thoughts:
Okay, here's my summary, tailored for an expert audience, as if I'm thinking these thoughts myself:

**Tracing the Caller of `ieee80211_nan_func_match`**

Alright, time to get my hands dirty. I need to understand the control flow surrounding `ieee80211_nan_func_match`. My immediate thought is, "who's *calling* this function?" That's the key to understanding its purpose and how it fits into the broader NAN (Neighbor Awareness Networking) context within this IEEE 802.11 implementation. My first step is going to be tracing the call graph. Let's fire up the debugger or static analysis tools and immediately pinpoint every single instance where `ieee80211_nan_func_match` is invoked. Knowing the callers is crucial: is it triggered by incoming NAN frames, internal state changes, timer events, or something else entirely? The context of the call will be just as important as the function itself. Depending on what I find I may be able to infer some more in depth detail regarding the purpose. Then, I need to analyze the surrounding code to determine how `ieee80211_nan_func_match` interacts with other functions and data structures. This is a critical first step.



36/2 2026/10/14 16:43 tool grepper
0m Args:
{
  "Expression": "ieee80211_nan_func_match"
}

Results:
{
  "Output": "include/net/mac80211.h=7966=void ieee80211_nan_func_terminated(struct ieee80211_vif *vif,\n--\ninclude/net/mac80211.h-7971-/**\ninclude/net/mac80211.h:7972: * ieee80211_nan_func_match - notify about NAN function match event.\ninclude/net/mac80211.h-7973- *\n--\ninclude/net/mac80211.h-7981- */\ninclude/net/mac80211.h:7982:void ieee80211_nan_func_match(struct ieee80211_vif *vif,\ninclude/net/mac80211.h-7983-\t\t\t      struct cfg80211_nan_match_params *match,\n--\nnet/mac80211/cfg.c=5580=EXPORT_SYMBOL(ieee80211_nan_func_terminated);\nnet/mac80211/cfg.c-5581-\nnet/mac80211/cfg.c:5582:void ieee80211_nan_func_match(struct ieee80211_vif *vif,\nnet/mac80211/cfg.c-5583-\t\t\t      struct cfg80211_nan_match_params *match,\n--\nnet/mac80211/cfg.c-5608-}\nnet/mac80211/cfg.c:5609:EXPORT_SYMBOL(ieee80211_nan_func_match);\nnet/mac80211/cfg.c-5610-\n"
}

37/2 2026/10/14 16:43 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 97964
							output: 42
							thoughts: 324
						

Thoughts:
**NAN Function Matching - A Deep Dive**

Okay, so I'm looking at these NAN function match functions, `ieee80211_nan_func_match` and `cfg80211_nan_match`. It's immediately strange... neither of these functions are *actually* called by any driver within the kernel tree. That's a red flag.

Then I see the `WARN_ON` check inside both functions, specifically related to `WIPHY_NAN_FLAGS_USERSPACE_DE`. It seems like these functions were intended to potentially handle a scenario where the NAN functionality is managed entirely in userspace. The `WARN_ON` suggests this is an exceptional case.

But wait a minute... what about `nl80211_nan_add_func`? It's connected to Netlink, and that's the usual route for userspace configuration. I need to take a closer look at that function. Can `wdev->wiphy->nan_capa.flags & WIPHY_NAN_FLAGS_USERSPACE_DE` *ever* be false given how Netlink is structured? And if so, how? And what if a wireless device is created with *no* NAN capabilities whatsoever? What does the code do in that case?

Okay, time to dig into the source. I'm going to carefully read `nl80211_nan_add_func` in `net/wireless/nl80211.c` from line 17430. Let's see what happens if someone actually tries to use `NL80211_CMD_ADD_NAN_FUNCTION` on an interface. I need to understand the control flow, the data structures, and the error handling to get a full picture of what's going on here. This is going to be interesting.



38/2 2026/10/14 16:43 tool read-file
0m Args:
{
  "File": "net/wireless/nl80211.c",
  "FirstLine": 17430,
  "LineCount": 80
}

Results:
{
  "Contents": "17430:\t\n17431:\tstatic int nl80211_nan_add_func(struct sk_buff *skb,\n17432:\t\t\t\t\tstruct genl_info *info)\n17433:\t{\n17434:\t\tstruct cfg80211_registered_device *rdev = info-\u003euser_ptr[0];\n17435:\t\tstruct wireless_dev *wdev = info-\u003euser_ptr[1];\n17436:\t\tstruct nlattr *tb[NUM_NL80211_NAN_FUNC_ATTR], *func_attr;\n17437:\t\tstruct cfg80211_nan_func *func;\n17438:\t\tstruct sk_buff *msg = NULL;\n17439:\t\tvoid *hdr = NULL;\n17440:\t\tint err = 0;\n17441:\t\n17442:\t\tif (wdev-\u003eiftype != NL80211_IFTYPE_NAN)\n17443:\t\t\treturn -EOPNOTSUPP;\n17444:\t\n17445:\t\tif (!wdev_running(wdev))\n17446:\t\t\treturn -ENOTCONN;\n17447:\t\n17448:\t\tif (wdev-\u003ewiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_USERSPACE_DE) {\n17449:\t\t\tNL_SET_ERR_MSG(info-\u003eextack,\n17450:\t\t\t\t       \"NAN Discovery Engine is in userspace\");\n17451:\t\t\treturn -EOPNOTSUPP;\n17452:\t\t}\n17453:\t\n17454:\t\tif (!info-\u003eattrs[NL80211_ATTR_NAN_FUNC])\n17455:\t\t\treturn -EINVAL;\n17456:\t\n17457:\t\terr = nla_parse_nested_deprecated(tb, NL80211_NAN_FUNC_ATTR_MAX,\n17458:\t\t\t\t\t\t  info-\u003eattrs[NL80211_ATTR_NAN_FUNC],\n17459:\t\t\t\t\t\t  nl80211_nan_func_policy,\n17460:\t\t\t\t\t\t  info-\u003eextack);\n17461:\t\tif (err)\n17462:\t\t\treturn err;\n17463:\t\n17464:\t\tfunc = kzalloc_obj(*func);\n17465:\t\tif (!func)\n17466:\t\t\treturn -ENOMEM;\n17467:\t\n17468:\t\tfunc-\u003ecookie = cfg80211_assign_cookie(rdev);\n17469:\t\n17470:\t\tif (!tb[NL80211_NAN_FUNC_TYPE]) {\n17471:\t\t\terr = -EINVAL;\n17472:\t\t\tgoto out;\n17473:\t\t}\n17474:\t\n17475:\t\n17476:\t\tfunc-\u003etype = nla_get_u8(tb[NL80211_NAN_FUNC_TYPE]);\n17477:\t\n17478:\t\tif (!tb[NL80211_NAN_FUNC_SERVICE_ID]) {\n17479:\t\t\terr = -EINVAL;\n17480:\t\t\tgoto out;\n17481:\t\t}\n17482:\t\n17483:\t\tmemcpy(func-\u003eservice_id, nla_data(tb[NL80211_NAN_FUNC_SERVICE_ID]),\n17484:\t\t       sizeof(func-\u003eservice_id));\n17485:\t\n17486:\t\tfunc-\u003eclose_range =\n17487:\t\t\tnla_get_flag(tb[NL80211_NAN_FUNC_CLOSE_RANGE]);\n17488:\t\n17489:\t\tif (tb[NL80211_NAN_FUNC_SERVICE_INFO]) {\n17490:\t\t\tfunc-\u003eserv_spec_info_len =\n17491:\t\t\t\tnla_len(tb[NL80211_NAN_FUNC_SERVICE_INFO]);\n17492:\t\t\tfunc-\u003eserv_spec_info =\n17493:\t\t\t\tkmemdup(nla_data(tb[NL80211_NAN_FUNC_SERVICE_INFO]),\n17494:\t\t\t\t\tfunc-\u003eserv_spec_info_len,\n17495:\t\t\t\t\tGFP_KERNEL);\n17496:\t\t\tif (!func-\u003eserv_spec_info) {\n17497:\t\t\t\terr = -ENOMEM;\n17498:\t\t\t\tgoto out;\n17499:\t\t\t}\n17500:\t\t}\n17501:\t\n17502:\t\tif (tb[NL80211_NAN_FUNC_TTL])\n17503:\t\t\tfunc-\u003ettl = nla_get_u32(tb[NL80211_NAN_FUNC_TTL]);\n17504:\t\n17505:\t\tswitch (func-\u003etype) {\n17506:\t\tcase NL80211_NAN_FUNC_PUBLISH:\n17507:\t\t\tif (!tb[NL80211_NAN_FUNC_PUBLISH_TYPE]) {\n17508:\t\t\t\terr = -EINVAL;\n17509:\t\t\t\tgoto out;\n"
}

39/2 2026/10/14 16:43 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 100125
							output: 28
							thoughts: 538
						

Thoughts:
**Analyzing NAN Interface Creation and Capability Checks**

Okay, here's what's going through my mind as I dissect this code snippet. First, I see these lines of code (17442-17452). A NAN interface check is happening, and it's looking at whether `wdev->iftype` is `NL80211_IFTYPE_NAN`. That's the crux of this.

Immediately, I'm questioning the *validity* of this. Can we *really* have a `wdev` with `NL80211_IFTYPE_NAN`? It throws up a red flag, prompting me to trace the creation of such an interface. How does that interface get created in the first place?

The answer, I believe, is likely that a userspace application calls `NL80211_CMD_NEW_INTERFACE` with the specific type `NL80211_IFTYPE_NAN`. Okay, makes sense. But does the kernel check that the underlying `wiphy` *actually supports* that interface type during the new interface creation? This is important.

I then check `nl80211_new_interface`, and yes, it *does* make that crucial check: `wiphy->interface_modes & BIT(NL80211_IFTYPE_NAN)`. Good, good. We want to ensure that only devices that can handle NAN actually expose the option to create a NAN interface.

Now the follow up question: Which `wiphy` devices actually declare support for `NL80211_IFTYPE_NAN`? That's what I really need to know.

I remember the `wiphy_register` function and how it sets `wiphy->interface_modes`. I recall this check:
```c
	if (WARN_ON((wiphy->interface_modes & BIT(NL80211_IFTYPE_NAN)) &&
		    (!rdev->ops->start_nan || !rdev->ops->stop_nan ||
		     !rdev->ops->add_nan_func || !rdev->ops->del_nan_func ||
		     !(wiphy->nan_supported_bands & BIT(NL80211_BAND_2GHZ)))))
		return -EINVAL;
```
That's useful. It checks that if NAN is supported, then the device driver must provide the appropriate NAN operations (start, stop, add, delete NAN functions, and support for the 2GHz band). This is an *important* consistency check to ensure that the driver can handle the interface type it claims to support.

So, I need to know which drivers *in the kernel* set the `BIT(NL80211_IFTYPE_NAN)` flag, thereby advertising NAN interface support. I need to exhaustively check *every single driver* to understand this better.



40/2 2026/10/14 16:43 tool grepper
0m Args:
{
  "Expression": "BIT\\(NL80211_IFTYPE_NAN\\)"
}

Results:
{
  "Output": "drivers/net/wireless/intel/iwlwifi/mld/mac80211.c=63=static const struct ieee80211_iface_limit iwl_mld_limits_nan[] = {\n--\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-69-\t\t.max = 1,\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c:70:\t\t.types = BIT(NL80211_IFTYPE_NAN),\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-71-\t},\n--\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c=268=static void iwl_mld_hw_set_nan(struct iwl_mld *mld)\n--\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-271-\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c:272:\thw-\u003ewiphy-\u003einterface_modes |= BIT(NL80211_IFTYPE_NAN);\ndrivers/net/wireless/intel/iwlwifi/mld/mac80211.c-273-\thw-\u003ewiphy-\u003einterface_modes |= BIT(NL80211_IFTYPE_NAN_DATA);\n--\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c=64=static const struct ieee80211_iface_limit if_limits_nan_mcc[] = {\n--\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c-70-\t\t.max = 1,\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c:71:\t\t.types = BIT(NL80211_IFTYPE_NAN),\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c-72-\t},\n--\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c=79=static const struct ieee80211_iface_limit if_limits_nan_scc[] = {\n--\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c-85-\t\t.max = 1,\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c:86:\t\t.types = BIT(NL80211_IFTYPE_NAN),\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c-87-\t},\n--\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c=751=int mt792x_init_wiphy(struct ieee80211_hw *hw)\n--\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c-797-\t    (dev-\u003efw_features \u0026 MT792x_FW_CAP_NAN)) {\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c:798:\t\twiphy-\u003einterface_modes |= BIT(NL80211_IFTYPE_NAN) |\ndrivers/net/wireless/mediatek/mt76/mt792x_core.c-799-\t\t\t\t\t  BIT(NL80211_IFTYPE_NAN_DATA);\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c=5722=static int mac80211_hwsim_new_radio(struct genl_info *info,\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-5838-\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:5839:\tif (param-\u003eiftypes \u0026 BIT(NL80211_IFTYPE_NAN)) {\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-5840-\t\tdata-\u003eif_limits[n_limits].max = 1;\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:5841:\t\tdata-\u003eif_limits[n_limits].types = BIT(NL80211_IFTYPE_NAN);\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-5842-\t\tn_limits++;\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c=6308=static int mac80211_hwsim_get_radio(struct sk_buff *skb,\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-6332-\tparam.nan_device = !!(data-\u003ehw-\u003ewiphy-\u003einterface_modes \u0026\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:6333:\t\t\t\t\tBIT(NL80211_IFTYPE_NAN));\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-6334-\tparam.use_chanctx = data-\u003euse_chanctx;\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c=6910=static int hwsim_new_radio_nl(struct sk_buff *msg, struct genl_info *info)\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-6998-\t\t}\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:6999:\t\tparam.iftypes |= BIT(NL80211_IFTYPE_NAN) |\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-7000-\t\t\t\t BIT(NL80211_IFTYPE_NAN_DATA);\n--\nnet/mac80211/main.c=1142=int ieee80211_register_hw(struct ieee80211_hw *hw)\n--\nnet/mac80211/main.c-1166-\tif (WARN_ON(local-\u003ehw.wiphy-\u003einterface_modes \u0026\nnet/mac80211/main.c:1167:\t\t\tBIT(NL80211_IFTYPE_NAN) \u0026\u0026\nnet/mac80211/main.c-1168-\t\t    ((!local-\u003eops-\u003estart_nan || !local-\u003eops-\u003estop_nan) ||\n--\nnet/wireless/core.c=757=int wiphy_verify_iface_combinations(struct wiphy *wiphy,\n--\nnet/wireless/core.c-818-\t\t\t/* Only a single NAN can be allowed */\nnet/wireless/core.c:819:\t\t\tif (WARN_ON(types \u0026 BIT(NL80211_IFTYPE_NAN) \u0026\u0026\nnet/wireless/core.c-820-\t\t\t\t    c-\u003elimits[j].max \u003e 1))\n--\nnet/wireless/core.c=904=int wiphy_register(struct wiphy *wiphy)\n--\nnet/wireless/core.c-931-\nnet/wireless/core.c:932:\tif (WARN_ON((wiphy-\u003einterface_modes \u0026 BIT(NL80211_IFTYPE_NAN)) \u0026\u0026\nnet/wireless/core.c-933-\t\t    (!rdev-\u003eops-\u003estart_nan || !rdev-\u003eops-\u003estop_nan ||\n"
}

41/2 2026/10/14 16:43 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 103272
							output: 50
							thoughts: 1448
						

Thoughts:
**NAN Implementation in the Linux Kernel: A Deep Dive**

Okay, this is interesting. I'm taking a close look at the NAN (Neighbor Awareness Networking) implementation in the kernel, and the implications of this patch are becoming clear. First, I noticed something rather striking. There are only *three* places in the entire kernel where `BIT(NL80211_IFTYPE_NAN)` is even set. That's it! We're talking about the Intel iwlwifi driver, the Mediatek mt76 driver, and the virtual `mac80211_hwsim` driver.

The truly fascinating part? *All three* of these drivers set the `WIPHY_NAN_FLAGS_USERSPACE_DE` flag within their NAN capability flags. Every single one. Let's quickly verify... yep, `iwl_mld`, `mt792x`, and `mac80211_hwsim` all have that flag enabled. `mac80211_hwsim` also has `WIPHY_NAN_FLAGS_INSTANT_COMM`, but the user space flag is common.

Now, let's consider this patch. Because this flag is set across all the real implementations, any call to `NL80211_CMD_ADD_NAN_FUNCTION` will immediately trigger an error. That means the detailed attribute parsing for SDEA, pairing, CSIDs, PMK, ranging, all of it, becomes completely unreachable. Lines 17626-17815 of `net/wireless/nl80211.c` are effectively dead code, as they can never be executed in the current driver landscape.

Furthermore, the code path checks for `WIPHY_NAN_FLAGS_OFFLOAD_NDP`, which none of the drivers set. The same is true with the checks regarding FTM. So every single function that's part of the NDP protocol, and FTM, will always return `-EOPNOTSUPP`. That's everything in `nl80211_nan_ndp_initiate`, `nl80211_nan_ndp_respond`, and `nl80211_nan_ndp_terminate`. And the ranging code in `pmsr.c` is going to fail too.

And the calls meant to be used by the drivers - `cfg80211_nan_ndp_request`, `cfg80211_nan_ndp_confirm`, and `cfg80211_nan_ndp_terminated` - no drivers ever use them. Additionally, `cfg80211_nan_match` is a no-go too, as it gets called by `ieee80211_nan_func_match`, which emits a warning if the user space flag is set. That means no drivers can set these flags or call the exported functions.

Wait a second. This immediately makes me think, are there any other ways these flags could be set? Could a virtual driver or a dynamically created Wi-Fi physical device (wiphy) provide an alternative? Could the user space create a new wiphy with custom flags? Let me check how the `mac80211_hwsim` driver handles radio creation. I'll need to check `hwsim_new_radio_nl` in `mac80211_hwsim_main.c` to see how the radios are created in the simulator.



42/2 2026/10/14 16:43 tool read-file
0m Args:
{
  "File": "drivers/net/wireless/virtual/mac80211_hwsim_main.c",
  "FirstLine": 6910,
  "LineCount": 95
}

Results:
{
  "Contents": "6910:\tstatic int hwsim_new_radio_nl(struct sk_buff *msg, struct genl_info *info)\n6911:\t{\n6912:\t\tstruct hwsim_new_radio_params param = { 0 };\n6913:\t\tconst char *hwname = NULL;\n6914:\t\tint ret;\n6915:\t\n6916:\t\tparam.reg_strict = info-\u003eattrs[HWSIM_ATTR_REG_STRICT_REG];\n6917:\t\tparam.p2p_device = info-\u003eattrs[HWSIM_ATTR_SUPPORT_P2P_DEVICE];\n6918:\t\tparam.nan_device = info-\u003eattrs[HWSIM_ATTR_SUPPORT_NAN_DEVICE];\n6919:\t\tparam.channels = channels;\n6920:\t\tparam.destroy_on_close =\n6921:\t\t\tinfo-\u003eattrs[HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE];\n6922:\t\n6923:\t\tif (info-\u003eattrs[HWSIM_ATTR_CHANNELS])\n6924:\t\t\tparam.channels = nla_get_u32(info-\u003eattrs[HWSIM_ATTR_CHANNELS]);\n6925:\t\n6926:\t\tif (param.channels \u003c 1) {\n6927:\t\t\tGENL_SET_ERR_MSG(info, \"must have at least one channel\");\n6928:\t\t\treturn -EINVAL;\n6929:\t\t}\n6930:\t\n6931:\t\tif (info-\u003eattrs[HWSIM_ATTR_NO_VIF])\n6932:\t\t\tparam.no_vif = true;\n6933:\t\n6934:\t\tif (info-\u003eattrs[HWSIM_ATTR_USE_CHANCTX])\n6935:\t\t\tparam.use_chanctx = true;\n6936:\t\telse\n6937:\t\t\tparam.use_chanctx = (param.channels \u003e 1);\n6938:\t\n6939:\t\tif (info-\u003eattrs[HWSIM_ATTR_MULTI_RADIO])\n6940:\t\t\tparam.multi_radio = true;\n6941:\t\n6942:\t\tif (info-\u003eattrs[HWSIM_ATTR_SUPPORT_BACKGROUND_RADAR])\n6943:\t\t\tparam.background_radar = true;\n6944:\t\n6945:\t\tif (info-\u003eattrs[HWSIM_ATTR_REG_HINT_ALPHA2])\n6946:\t\t\tparam.reg_alpha2 =\n6947:\t\t\t\tnla_data(info-\u003eattrs[HWSIM_ATTR_REG_HINT_ALPHA2]);\n6948:\t\n6949:\t\tif (info-\u003eattrs[HWSIM_ATTR_REG_CUSTOM_REG]) {\n6950:\t\t\tu32 idx = nla_get_u32(info-\u003eattrs[HWSIM_ATTR_REG_CUSTOM_REG]);\n6951:\t\n6952:\t\t\tif (idx \u003e= ARRAY_SIZE(hwsim_world_regdom_custom))\n6953:\t\t\t\treturn -EINVAL;\n6954:\t\n6955:\t\t\tidx = array_index_nospec(idx,\n6956:\t\t\t\t\t\t ARRAY_SIZE(hwsim_world_regdom_custom));\n6957:\t\t\tparam.regd = hwsim_world_regdom_custom[idx];\n6958:\t\t}\n6959:\t\n6960:\t\tif (info-\u003eattrs[HWSIM_ATTR_PERM_ADDR]) {\n6961:\t\t\tif (!is_valid_ether_addr(\n6962:\t\t\t\t\tnla_data(info-\u003eattrs[HWSIM_ATTR_PERM_ADDR]))) {\n6963:\t\t\t\tGENL_SET_ERR_MSG(info,\"MAC is no valid source addr\");\n6964:\t\t\t\tNL_SET_BAD_ATTR(info-\u003eextack,\n6965:\t\t\t\t\t\tinfo-\u003eattrs[HWSIM_ATTR_PERM_ADDR]);\n6966:\t\t\t\treturn -EINVAL;\n6967:\t\t\t}\n6968:\t\n6969:\t\t\tparam.perm_addr = nla_data(info-\u003eattrs[HWSIM_ATTR_PERM_ADDR]);\n6970:\t\t}\n6971:\t\n6972:\t\tif (info-\u003eattrs[HWSIM_ATTR_IFTYPE_SUPPORT]) {\n6973:\t\t\tparam.iftypes =\n6974:\t\t\t\tnla_get_u32(info-\u003eattrs[HWSIM_ATTR_IFTYPE_SUPPORT]);\n6975:\t\n6976:\t\t\tif (param.iftypes \u0026 ~HWSIM_IFTYPE_SUPPORT_MASK) {\n6977:\t\t\t\tNL_SET_ERR_MSG_ATTR(info-\u003eextack,\n6978:\t\t\t\t\t\t    info-\u003eattrs[HWSIM_ATTR_IFTYPE_SUPPORT],\n6979:\t\t\t\t\t\t    \"cannot support more iftypes than kernel\");\n6980:\t\t\t\treturn -EINVAL;\n6981:\t\t\t}\n6982:\t\t} else {\n6983:\t\t\tparam.iftypes = HWSIM_IFTYPE_SUPPORT_MASK;\n6984:\t\t}\n6985:\t\n6986:\t\t/* ensure both flag and iftype support is honored */\n6987:\t\tif (param.p2p_device ||\n6988:\t\t    param.iftypes \u0026 BIT(NL80211_IFTYPE_P2P_DEVICE)) {\n6989:\t\t\tparam.iftypes |= BIT(NL80211_IFTYPE_P2P_DEVICE);\n6990:\t\t\tparam.p2p_device = true;\n6991:\t\t}\n6992:\t\n6993:\t\tif (param.nan_device) {\n6994:\t\t\tif (param.multi_radio) {\n6995:\t\t\t\tNL_SET_ERR_MSG(info-\u003eextack,\n6996:\t\t\t\t\t       \"NAN is not supported on multi-radio wiphys\");\n6997:\t\t\t\treturn -EINVAL;\n6998:\t\t\t}\n6999:\t\t\tparam.iftypes |= BIT(NL80211_IFTYPE_NAN) |\n7000:\t\t\t\t\t BIT(NL80211_IFTYPE_NAN_DATA);\n7001:\t\t}\n7002:\t\n7003:\t\tif (info-\u003eattrs[HWSIM_ATTR_CIPHER_SUPPORT]) {\n7004:\t\t\tu32 len = nla_len(info-\u003eattrs[HWSIM_ATTR_CIPHER_SUPPORT]);\n"
}

43/2 2026/10/14 16:43 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 107194
							output: 29
							thoughts: 5554
						

Thoughts:
**Analyzing the Reachability of New NAN NDP/Ranging Offload Code**

Okay, here's the deal. I'm looking at this patch and initially, the excitement is there. New code, extended structures for NAN NDP (NAN Data Path) and ranging offload in `cfg80211`, which is cool. However, my Spidey-Sense is tingling because I'm not seeing immediate driver support. The first thing I spot is this hardcoded `WIPHY_NAN_FLAGS_USERSPACE_DE` flag. This immediately screams "userspace control only," which is usually a red flag for reachability, and it effectively prevents the new `rdev_nan_ndp_*` calls from ever being reached.

I'm thinking about the triage philosophy: Reachability is king. If the code *can't* run in a standard virtualized environment, we shouldn't fuzz it. I'm going through every file modified, like `cfg80211.h`, `nl80211.h`, and `nl80211.c`, and checking reachability. Adding new commands (`NL80211_CMD_NAN_NDP_INITIATE`, `_RESPOND`, `_TERMINATE`, and so on) and attributes is all well and good, but can we *actually* trigger any of the new logic?

Okay, the extended netlink policies for NAN look clean, I note those. My focus goes towards `nl80211_send_pmsr_ftm_capa` which calls `nl80211_send_pmsr_capa`. That one, I see that when `wiphy` info is requested, the function executes, but when `nan_support` is evaluated, it will always be false (0).

`nl80211_put_nan_capa` is called when getting `wiphy` info, but only if `OFFLOAD_RANGING` or `OFFLOAD_NDP` are set, which aren't set anywhere in the kernel! The `if` statements are technically executed, but the conditions will always be false.

`nl80211_nan_add_func`: This is crucial. This is where the `USERSPACE_DE` check lives, which is reachable when adding a NAN function. But it immediately returns -EOPNOTSUPP, and the whole point of this new code is to support offload *from* userspace to the driver.

Okay, let's look at netlink command handlers like `nl80211_nan_ndp_initiate`. The command is registered, so syzkaller can send messages, but the checks inside immediately return -EOPNOTSUPP if `OFFLOAD_NDP` isn't set. The same applies to `_RESPOND` and `_TERMINATE`. It never reaches the logic to parse the attributes.

Even `pmsr_parse_peer` in `pmsr.c`, for ranging capabilities, has similar checks that prevent execution of the new functionality when it's `NL80211_PMSR_FTM_REQ_TYPE_NAN`.

So, the issue is that none of these new `OFFLOAD` flags are set by any existing driver. I went through *every* driver that uses `NL80211_IFTYPE_NAN`, which I found using `grepper` and that list came down to a few: `iwlwifi`, `mt76`, and `mac80211_hwsim`. *None* of them have the flags to enable the offload, but they *all* set `WIPHY_NAN_FLAGS_USERSPACE_DE`. Thus, even with the physical cards for `iwlwifi` and `mt76`, the offload code is unreachable.

I re-read the triage philosophy and it says that code reachable via netlink *is* worth fuzzing. The key, however, is that the code *must* be reachable. This patch, I'm thinking, is just infrastructure and is designed to allow drivers to add the `OFFLOAD` flags and call the core logic down the road. But right now, the logic is structurally unreachable. So, based on the principle of reachability, this particular patch isn't worth fuzzing because it can't execute. It is a new abstraction, and the implementation is yet to come.



44/2 2026/10/14 16:44 tool grepper
0m Args:
{
  "Expression": "NL80211_FLAG_NEED_WDEV_UP"
}

Results:
{
  "Output": "net/wireless/nl80211.c=20789=nl80211_epcs_cfg(struct sk_buff *skb, struct genl_info *info)\n--\nnet/wireless/nl80211.c-20815-/* If a netdev is associated, it must be UP, P2P must be started */\nnet/wireless/nl80211.c:20816:#define NL80211_FLAG_NEED_WDEV_UP\t(NL80211_FLAG_NEED_WDEV |\\\nnet/wireless/nl80211.c-20817-\t\t\t\t\t NL80211_FLAG_CHECK_NETDEV_UP)\n--\nnet/wireless/nl80211.c-20875-\tSELECTOR(__sel, WDEV_UP,\t\t\t\\\nnet/wireless/nl80211.c:20876:\t\t NL80211_FLAG_NEED_WDEV_UP)\t\t\\\nnet/wireless/nl80211.c-20877-\tSELECTOR(__sel, WDEV_UP_CLEAR,\t\t\t\\\nnet/wireless/nl80211.c:20878:\t\t NL80211_FLAG_NEED_WDEV_UP |\t\t\\\nnet/wireless/nl80211.c-20879-\t\t NL80211_FLAG_CLEAR_SKB)\t\t\\\nnet/wireless/nl80211.c-20880-\tSELECTOR(__sel, WDEV_UP_LINK,\t\t\t\\\nnet/wireless/nl80211.c:20881:\t\t NL80211_FLAG_NEED_WDEV_UP |\t\t\\\nnet/wireless/nl80211.c-20882-\t\t NL80211_FLAG_MLO_VALID_LINK_ID)\t\\\nnet/wireless/nl80211.c-20883-\tSELECTOR(__sel, WDEV_UP_RTNL,\t\t\t\\\nnet/wireless/nl80211.c:20884:\t\t NL80211_FLAG_NEED_WDEV_UP |\t\t\\\nnet/wireless/nl80211.c-20885-\t\t NL80211_FLAG_NEED_RTNL)\t\t\\\n--\nnet/wireless/nl80211.c-20889-\tSELECTOR(__sel, WDEV_UP_RTNL_NOMTX,\t\t\\\nnet/wireless/nl80211.c:20890:\t\t NL80211_FLAG_NEED_WDEV_UP |\t\t\\\nnet/wireless/nl80211.c-20891-\t\t NL80211_FLAG_NO_WIPHY_MTX |\t\t\\\n--\nnet/wireless/nl80211.c-20893-\tSELECTOR(__sel, WDEV_UP_NOMTX,\t\t\t\\\nnet/wireless/nl80211.c:20894:\t\t NL80211_FLAG_NEED_WDEV_UP |\t\t\\\nnet/wireless/nl80211.c-20895-\t\t NL80211_FLAG_NO_WIPHY_MTX)\n--\nnet/wireless/nl80211.c=21266=static const struct genl_small_ops nl80211_small_ops[] = {\n--\nnet/wireless/nl80211.c-21312-\t\t.flags = GENL_UNS_ADMIN_PERM,\nnet/wireless/nl80211.c:21313:\t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),\nnet/wireless/nl80211.c-21314-\t},\n--\nnet/wireless/nl80211.c-21320-\t\t/* cannot use NL80211_FLAG_MLO_VALID_LINK_ID, depends on key */\nnet/wireless/nl80211.c:21321:\t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP |\nnet/wireless/nl80211.c-21322-\t\t\t\t\t NL80211_FLAG_CLEAR_SKB),\n--\nnet/wireless/nl80211.c-21328-\t\t.flags = GENL_UNS_ADMIN_PERM,\nnet/wireless/nl80211.c:21329:\t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP |\nnet/wireless/nl80211.c-21330-\t\t\t\t\t NL80211_FLAG_CLEAR_SKB),\n--\nnet/wireless/nl80211.c-21336-\t\t.flags = GENL_UNS_ADMIN_PERM,\nnet/wireless/nl80211.c:21337:\t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),\nnet/wireless/nl80211.c-21338-\t},\n--\nnet/wireless/nl80211.c-21367-\t\t.flags = GENL_UNS_ADMIN_PERM,\nnet/wireless/nl80211.c:21368:\t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),\nnet/wireless/nl80211.c-21369-\t},\n--\nnet/wireless/nl80211.c-21374-\t\t.flags = GENL_UNS_ADMIN_PERM,\nnet/wireless/nl80211.c:21375:\t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),\nnet/wireless/nl80211.c-21376-\t},\n--\nnet/wireless/nl80211.c-21385-\t\t */\nnet/wireless/nl80211.c:21386:\t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),\nnet/wireless/nl80211.c-21387-\t},\n--\nnet/wireless/nl80211.c-21478-\t\t.flags = GENL_UNS_ADMIN_PERM,\nnet/wireless/nl80211.c:21479:\t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),\nnet/wireless/nl80211.c-21480-\t},\n--\nnet/wireless/nl80211.c-21485-\t\t.flags = GENL_UNS_ADMIN_PERM,\nnet/wireless/nl80211.c:21486:\t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),\nnet/wireless/nl80211.c-21487-\t},\n--\nnet/wireless/nl80211.c-21625-\t\t/* FIXME: requiring a link ID here is probably not good */\nnet/wireless/nl80211.c:21626:\t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP |\nnet/wireless/nl80211.c-21627-\t\t\t\t\t NL80211_FLAG_MLO_VALID_LINK_ID),\n--\nnet/wireless/nl80211.c-21633-\t\t.flags = GENL_UNS_ADMIN_PERM,\nnet/wireless/nl80211.c:21634:\t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),\nnet/wireless/nl80211.c-21635-\t},\n--\nnet/wireless/nl80211.c-21655-\t\t.flags = GENL_UNS_ADMIN_PERM,\nnet/wireless/nl80211.c:21656:\t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP |\nnet/wireless/nl80211.c-21657-\t\t\t\t\t NL80211_FLAG_NO_WIPHY_MTX),\n--\nnet/wireless/nl80211.c-21663-\t\t.flags = GENL_UNS_ADMIN_PERM,\nnet/wireless/nl80211.c:21664:\t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),\nnet/wireless/nl80211.c-21665-\t},\n--\nnet/wireless/nl80211.c-21803-\t\t.flags = GENL_UNS_ADMIN_PERM,\nnet/wireless/nl80211.c:21804:\t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP |\nnet/wireless/nl80211.c-21805-\t\t\t\t\t NL80211_FLAG_NEED_RTNL),\n--\nnet/wireless/nl80211.c-21819-\t\t.flags = GENL_ADMIN_PERM,\nnet/wireless/nl80211.c:21820:\t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP |\nnet/wireless/nl80211.c-21821-\t\t\t\t\t NL80211_FLAG_NO_WIPHY_MTX |\n--\nnet/wireless/nl80211.c-21828-\t\t.flags = GENL_ADMIN_PERM,\nnet/wireless/nl80211.c:21829:\t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),\nnet/wireless/nl80211.c-21830-\t},\n--\nnet/wireless/nl80211.c-21835-\t\t.flags = GENL_ADMIN_PERM,\nnet/wireless/nl80211.c:21836:\t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),\nnet/wireless/nl80211.c-21837-\t},\n--\nnet/wireless/nl80211.c-21842-\t\t.flags = GENL_ADMIN_PERM,\nnet/wireless/nl80211.c:21843:\t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),\nnet/wireless/nl80211.c-21844-\t},\n--\nnet/wireless/nl80211.c-21855-\t\t.flags = GENL_ADMIN_PERM,\nnet/wireless/nl80211.c:21856:\t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP |\nnet/wireless/nl80211.c-21857-\t\t\t\t\t NL80211_FLAG_NEED_RTNL),\n--\nnet/wireless/nl80211.c-21899-\t\t.flags = GENL_UNS_ADMIN_PERM,\nnet/wireless/nl80211.c:21900:\t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),\nnet/wireless/nl80211.c-21901-\t},\n--\nnet/wireless/nl80211.c-21906-\t\t.flags = GENL_UNS_ADMIN_PERM,\nnet/wireless/nl80211.c:21907:\t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),\nnet/wireless/nl80211.c-21908-\t},\n--\nnet/wireless/nl80211.c-22023-\t\t.flags = GENL_UNS_ADMIN_PERM,\nnet/wireless/nl80211.c:22024:\t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),\nnet/wireless/nl80211.c-22025-\t},\n--\nnet/wireless/nl80211.c-22135-\t\t.flags = GENL_ADMIN_PERM,\nnet/wireless/nl80211.c:22136:\t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),\nnet/wireless/nl80211.c-22137-\t},\n--\nnet/wireless/nl80211.c-22141-\t\t.flags = GENL_ADMIN_PERM,\nnet/wireless/nl80211.c:22142:\t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),\nnet/wireless/nl80211.c-22143-\t},\n--\nnet/wireless/nl80211.c-22147-\t\t.flags = GENL_ADMIN_PERM,\nnet/wireless/nl80211.c:22148:\t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),\nnet/wireless/nl80211.c-22149-\t},\n--\nnet/wireless/nl80211.c-22160-\t\t.flags = GENL_ADMIN_PERM,\nnet/wireless/nl80211.c:22161:\t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),\nnet/wireless/nl80211.c-22162-\t},\n--\nnet/wireless/nl80211.c-22166-\t\t.flags = GENL_ADMIN_PERM,\nnet/wireless/nl80211.c:22167:\t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),\nnet/wireless/nl80211.c-22168-\t},\n--\nnet/wireless/nl80211.c-22172-\t\t.flags = GENL_ADMIN_PERM,\nnet/wireless/nl80211.c:22173:\t\t.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),\nnet/wireless/nl80211.c-22174-\t},\n"
}

45/2 2026/10/14 16:44 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 117589
							output: 33
							thoughts: 369
						

Thoughts:
**Analyzing New NAN NDP Commands**

Okay, let's take a look at these three new commands: `NL80211_CMD_NAN_NDP_INITIATE`, `NL80211_CMD_NAN_NDP_RESPOND`, and `NL80211_CMD_NAN_NDP_TERMINATE`. The structure's pretty straightforward, with the command itself, the corresponding handler function, and those interesting flags. Specifically, I'm focusing on the `.flags = GENL_ADMIN_PERM` attribute.

Now, a red flag pops up. Given these are NETLINK commands, `GENL_ADMIN_PERM` immediately triggers a question: are these commands going to work correctly within a user namespace? My understanding of generic netlink permissions is that `GENL_ADMIN_PERM` grants administrative privileges, but how does this relate to user namespaces? Do we need to consider `GENL_UNS_ADMIN_PERM` instead? This could be a potential security issue and a compatibility hurdle if not handled correctly. Time to verify that these commands are secure and will function properly with or without the user namespace.

Let's do a quick check in `net/netlink/genetlink.c` using `grep` to understand the implications of `GENL_ADMIN_PERM`. I need to ensure the correct permission model is applied.



46/2 2026/10/14 16:44 tool grepper
0m Args:
{
  "Expression": "GENL_ADMIN_PERM",
  "PathPrefixes": [
    "net/netlink/"
  ]
}

Results:
{
  "Output": "net/netlink/genetlink.c=1155=static int genl_family_rcv_msg(const struct genl_family *family,\n--\nnet/netlink/genetlink.c-1181-\nnet/netlink/genetlink.c:1182:\tif ((op.flags \u0026 GENL_ADMIN_PERM) \u0026\u0026\nnet/netlink/genetlink.c-1183-\t    !netlink_capable(skb, CAP_NET_ADMIN))\n"
}

47/2 2026/10/14 16:44 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 118425
							output: 26
							thoughts: 3790
						

Thoughts:
**Unreachable Code in the Linux Kernel's NAN Implementation**

Okay, so I've been digging into the NAN (Neighbor Awareness Networking) code within the kernel, specifically focusing on how it handles offload capabilities and user-space interactions. The initial trace led me down the path of the `nl80211_nan_ndp_initiate` function, triggered through the `genl_family_rcv_msg_doit` call. I started by tracing the path where syzkaller, running with appropriate privileges, can trigger a NAN NDP initiate action.

My deep dive revealed a critical flaw. The function `nl80211_nan_ndp_initiate` contains a check: `if (!(rdev->wiphy.nan_capa.flags & WIPHY_NAN_FLAGS_OFFLOAD_NDP))`.  The intention here seems to be to ensure the driver supports NDP offloading.  However, and here's the kicker, **not a single driver in the entire kernel codebase sets this flag (`WIPHY_NAN_FLAGS_OFFLOAD_NDP`)**.  I meticulously grepped the entire kernel tree, confirming that the flag only appears in header files and in logic related to its definition or use, but never being set by a driver. Therefore, the code block guarded by this condition is *always* executed.

Further investigation into similar flags, specifically `WIPHY_NAN_FLAGS_OFFLOAD_RANGING` and `nan_support` in the `pmsr_capa`, revealed a consistent pattern.  No driver sets either of those.  This raises a serious concern about the intended functionality of these offload features and whether they are even remotely usable.  If these flags are meant to be set by the drivers, then it is critical to address this now.

I expanded my scope to include checking the NAN function addition (`nl80211_nan_add_func`) logic.  Here, there's a check that seems like a gate: `if (wdev->wiphy->nan_capa.flags & WIPHY_NAN_FLAGS_USERSPACE_DE)`.  This is intended to prevent userspace discovery engine control when using an offloaded implementation. However, after extensive review, it's virtually *guaranteed* to return -EOPNOTSUPP. All the drivers that support `NL80211_IFTYPE_NAN` also set `WIPHY_NAN_FLAGS_USERSPACE_DE`. This check means that the subsequent code in `nl80211_nan_add_func` is unreachable, as the function always returns -EOPNOTSUPP and prevents any NAN function from being added. I investigated the relevant drivers (`iwlwifi`, `mt76`, `mac80211_hwsim`), and they *all* set this flag.  The mac80211 code has added logic to check the same thing and return EINVAL if the flags are not correct.

I also looked at `cfg80211_free_nan_func` and it's free operations.

In essence, a large chunk of the kernel's NAN functionality is rendered useless because the offload features and the discovery engine logic are consistently blocked by preconditions that are never met or conditions that are guaranteed to fail. There may be some cleanup actions that are never performed due to the lack of use of certain functions. This is not just a theoretical problem; it represents a significant deficiency in the kernel's NAN implementation that needs immediate attention.  Someone needs to go through all of the NAN flags and either make them actually usable, or remove them, as they are not being used as intended in the code.



48/2 2026/10/14 16:45 tool grepper
0m Args:
{
  "Expression": "cfg80211_free_nan_func"
}

Results:
{
  "Output": "include/net/cfg80211.h=5112=struct mgmt_frame_regs {\n--\ninclude/net/cfg80211.h-5473- *\tshould free the @nan_func when no longer needed by calling\ninclude/net/cfg80211.h:5474: *\tcfg80211_free_nan_func().\ninclude/net/cfg80211.h-5475- *\tOn success the driver should assign an instance_id in the\n--\ninclude/net/cfg80211.h=10793=wiphy_ext_feature_isset(struct wiphy *wiphy,\n--\ninclude/net/cfg80211.h-10802-/**\ninclude/net/cfg80211.h:10803: * cfg80211_free_nan_func - free NAN function\ninclude/net/cfg80211.h-10804- * @f: NAN function that should be freed\n--\ninclude/net/cfg80211.h-10807- */\ninclude/net/cfg80211.h:10808:void cfg80211_free_nan_func(struct cfg80211_nan_func *f);\ninclude/net/cfg80211.h-10809-\n--\nnet/mac80211/cfg.c=5546=void ieee80211_nan_func_terminated(struct ieee80211_vif *vif,\n--\nnet/mac80211/cfg.c-5574-\nnet/mac80211/cfg.c:5575:\tcfg80211_free_nan_func(func);\nnet/mac80211/cfg.c-5576-\n--\nnet/mac80211/iface.c=479=static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_down)\n--\nnet/mac80211/iface.c-653-\t\t\t\tidr_remove(\u0026sdata-\u003eu.nan.de.function_inst_ids, i);\nnet/mac80211/iface.c:654:\t\t\t\tcfg80211_free_nan_func(func);\nnet/mac80211/iface.c-655-\t\t\t}\n--\nnet/wireless/nl80211.c=17431=static int nl80211_nan_add_func(struct sk_buff *skb,\n--\nnet/wireless/nl80211.c-17828-\tif (err \u003c 0) {\nnet/wireless/nl80211.c:17829:\t\tcfg80211_free_nan_func(func);\nnet/wireless/nl80211.c-17830-\t\tnlmsg_free(msg);\n--\nnet/wireless/util.c=2811=EXPORT_SYMBOL(cfg80211_get_station);\nnet/wireless/util.c-2812-\nnet/wireless/util.c:2813:void cfg80211_free_nan_func(struct cfg80211_nan_func *f)\nnet/wireless/util.c-2814-{\n--\nnet/wireless/util.c-2833-}\nnet/wireless/util.c:2834:EXPORT_SYMBOL(cfg80211_free_nan_func);\nnet/wireless/util.c-2835-\n"
}

49/2 2026/10/14 16:45 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 123979
							output: 20
							thoughts: 1995
						

Thoughts:
**Fuzzing Analysis: `cfg80211_free_nan_func` and NAN Functionality**

Okay, so I've been digging into this patch. My initial thought was that `cfg80211_free_nan_func` was never called because it's wrapped in conditionals that always evaluate to false, specifically within `ieee80211_nan_func_terminated`, `ieee80211_do_stop`, and an error path in `nl80211_nan_add_func`. The code appears unreachable due to the `WIPHY_NAN_FLAGS_USERSPACE_DE` flag and a `-EOPNOTSUPP` return. That felt like a dead end, and I was about to dismiss it.

But hold on! Let's re-read the guidelines. We can't jump to conclusions, even if something *seems* unreachable. The core triage philosophy emphasizes *reachability* as the primary gate but also stresses not blindly trusting "No Functional Change" claims. Refactorings, helper functions, or state changes *must* be fuzzed if reachable executable code is modified.

So, let's step back and consider the *netlink* path. The guidelines specifically state that "Reachable Drivers and Protocols... accessible via virtual buses (virtio, USB gadget, loopback, netlink, binder, sockets, etc.)" *must* be tested. Does `nl80211` fall under this category? Yes, it's accessed via generic netlink!

Crucially, the patch does *modify* executable code in `net/wireless/nl80211.c`. Specifically, the new `if` statement in `nl80211_nan_add_func` *is* reachable if a userspace process (e.g., syzkaller) creates a `mac80211_hwsim` radio with a NAN interface and sends the `NL80211_CMD_ADD_NAN_FUNCTION` command. *This code can execute!* Even if `nl80211_nan_add_func` returns `-EOPNOTSUPP` after the `if` statement, this still needs fuzzing.

Furthermore, the code in `nl80211_nan_ndp_initiate` is also reachable under the same conditions. This command includes a check: `!(rdev->wiphy.nan_capa.flags & WIPHY_NAN_FLAGS_OFFLOAD_NDP)`. *This* code can execute, too!

The critical question now is, is it ever *possible* for `WIPHY_NAN_FLAGS_OFFLOAD_NDP` to be true? No driver in the current tree sets this flag. But, what if syzkaller or a userspace program could *set* this flag in a virtualized device? No module in the entire kernel tree has `WIPHY_NAN_FLAGS_OFFLOAD_NDP` specified anywhere, but can the attributes of `mac80211_hwsim` be modified? I need to check the `HWSIM_ATTR_*` attributes and `enum hwsim_attrs` to see if there's *any* way to configure it. We can't dismiss this based on the existing code alone.



50/2 2026/10/14 16:45 tool grepper
0m Args:
{
  "Expression": "HWSIM_ATTR_"
}

Results:
{
  "Output": "\nFull output is too long, showing 200 out of 603 lines.\nUse more precise expression or PathPrefixes if possible.\n\nNumber of matching lines per file (4 files in total):\ndrivers/net/ieee802154/mac802154_hwsim.c:24\ndrivers/net/ieee802154/mac802154_hwsim.h:12\ndrivers/net/wireless/virtual/mac80211_hwsim.h:85\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:130\n\ndrivers/net/ieee802154/mac802154_hwsim.c=348=static int hwsim_del_radio_nl(struct sk_buff *msg, struct genl_info *info)\n--\ndrivers/net/ieee802154/mac802154_hwsim.c-352-\ndrivers/net/ieee802154/mac802154_hwsim.c:353:\tif (!info-\u003eattrs[MAC802154_HWSIM_ATTR_RADIO_ID])\ndrivers/net/ieee802154/mac802154_hwsim.c-354-\t\treturn -EINVAL;\ndrivers/net/ieee802154/mac802154_hwsim.c-355-\ndrivers/net/ieee802154/mac802154_hwsim.c:356:\tidx = nla_get_u32(info-\u003eattrs[MAC802154_HWSIM_ATTR_RADIO_ID]);\ndrivers/net/ieee802154/mac802154_hwsim.c-357-\n--\ndrivers/net/ieee802154/mac802154_hwsim.c=371=static int append_radio_msg(struct sk_buff *skb, struct hwsim_phy *phy)\n--\ndrivers/net/ieee802154/mac802154_hwsim.c-377-\ndrivers/net/ieee802154/mac802154_hwsim.c:378:\tret = nla_put_u32(skb, MAC802154_HWSIM_ATTR_RADIO_ID, phy-\u003eidx);\ndrivers/net/ieee802154/mac802154_hwsim.c-379-\tif (ret \u003c 0)\n--\ndrivers/net/ieee802154/mac802154_hwsim.c-388-\tnl_edges = nla_nest_start_noflag(skb,\ndrivers/net/ieee802154/mac802154_hwsim.c:389:\t\t\t\t\t MAC802154_HWSIM_ATTR_RADIO_EDGES);\ndrivers/net/ieee802154/mac802154_hwsim.c-390-\tif (!nl_edges) {\n--\ndrivers/net/ieee802154/mac802154_hwsim.c-396-\t\tnl_edge = nla_nest_start_noflag(skb,\ndrivers/net/ieee802154/mac802154_hwsim.c:397:\t\t\t\t\t\tMAC802154_HWSIM_ATTR_RADIO_EDGE);\ndrivers/net/ieee802154/mac802154_hwsim.c-398-\t\tif (!nl_edge) {\n--\ndrivers/net/ieee802154/mac802154_hwsim.c=459=static int hwsim_get_radio_nl(struct sk_buff *msg, struct genl_info *info)\n--\ndrivers/net/ieee802154/mac802154_hwsim.c-464-\ndrivers/net/ieee802154/mac802154_hwsim.c:465:\tif (!info-\u003eattrs[MAC802154_HWSIM_ATTR_RADIO_ID])\ndrivers/net/ieee802154/mac802154_hwsim.c-466-\t\treturn -EINVAL;\ndrivers/net/ieee802154/mac802154_hwsim.c:467:\tidx = nla_get_u32(info-\u003eattrs[MAC802154_HWSIM_ATTR_RADIO_ID]);\ndrivers/net/ieee802154/mac802154_hwsim.c-468-\n--\ndrivers/net/ieee802154/mac802154_hwsim.c=580=static int hwsim_new_edge_nl(struct sk_buff *msg, struct genl_info *info)\n--\ndrivers/net/ieee802154/mac802154_hwsim.c-586-\ndrivers/net/ieee802154/mac802154_hwsim.c:587:\tif (!info-\u003eattrs[MAC802154_HWSIM_ATTR_RADIO_ID] ||\ndrivers/net/ieee802154/mac802154_hwsim.c:588:\t    !info-\u003eattrs[MAC802154_HWSIM_ATTR_RADIO_EDGE])\ndrivers/net/ieee802154/mac802154_hwsim.c-589-\t\treturn -EINVAL;\ndrivers/net/ieee802154/mac802154_hwsim.c-590-\ndrivers/net/ieee802154/mac802154_hwsim.c:591:\tif (nla_parse_nested_deprecated(edge_attrs, MAC802154_HWSIM_EDGE_ATTR_MAX, info-\u003eattrs[MAC802154_HWSIM_ATTR_RADIO_EDGE], hwsim_edge_policy, NULL))\ndrivers/net/ieee802154/mac802154_hwsim.c-592-\t\treturn -EINVAL;\n--\ndrivers/net/ieee802154/mac802154_hwsim.c-596-\ndrivers/net/ieee802154/mac802154_hwsim.c:597:\tv0 = nla_get_u32(info-\u003eattrs[MAC802154_HWSIM_ATTR_RADIO_ID]);\ndrivers/net/ieee802154/mac802154_hwsim.c-598-\tv1 = nla_get_u32(edge_attrs[MAC802154_HWSIM_EDGE_ATTR_ENDPOINT_ID]);\n--\ndrivers/net/ieee802154/mac802154_hwsim.c=642=static int hwsim_del_edge_nl(struct sk_buff *msg, struct genl_info *info)\n--\ndrivers/net/ieee802154/mac802154_hwsim.c-648-\ndrivers/net/ieee802154/mac802154_hwsim.c:649:\tif (!info-\u003eattrs[MAC802154_HWSIM_ATTR_RADIO_ID] ||\ndrivers/net/ieee802154/mac802154_hwsim.c:650:\t    !info-\u003eattrs[MAC802154_HWSIM_ATTR_RADIO_EDGE])\ndrivers/net/ieee802154/mac802154_hwsim.c-651-\t\treturn -EINVAL;\ndrivers/net/ieee802154/mac802154_hwsim.c-652-\ndrivers/net/ieee802154/mac802154_hwsim.c:653:\tif (nla_parse_nested_deprecated(edge_attrs, MAC802154_HWSIM_EDGE_ATTR_MAX, info-\u003eattrs[MAC802154_HWSIM_ATTR_RADIO_EDGE], hwsim_edge_policy, NULL))\ndrivers/net/ieee802154/mac802154_hwsim.c-654-\t\treturn -EINVAL;\n--\ndrivers/net/ieee802154/mac802154_hwsim.c-658-\ndrivers/net/ieee802154/mac802154_hwsim.c:659:\tv0 = nla_get_u32(info-\u003eattrs[MAC802154_HWSIM_ATTR_RADIO_ID]);\ndrivers/net/ieee802154/mac802154_hwsim.c-660-\tv1 = nla_get_u32(edge_attrs[MAC802154_HWSIM_EDGE_ATTR_ENDPOINT_ID]);\n--\ndrivers/net/ieee802154/mac802154_hwsim.c=688=static int hwsim_set_edge_lqi(struct sk_buff *msg, struct genl_info *info)\n--\ndrivers/net/ieee802154/mac802154_hwsim.c-696-\ndrivers/net/ieee802154/mac802154_hwsim.c:697:\tif (!info-\u003eattrs[MAC802154_HWSIM_ATTR_RADIO_ID] ||\ndrivers/net/ieee802154/mac802154_hwsim.c:698:\t    !info-\u003eattrs[MAC802154_HWSIM_ATTR_RADIO_EDGE])\ndrivers/net/ieee802154/mac802154_hwsim.c-699-\t\treturn -EINVAL;\ndrivers/net/ieee802154/mac802154_hwsim.c-700-\ndrivers/net/ieee802154/mac802154_hwsim.c:701:\tif (nla_parse_nested_deprecated(edge_attrs, MAC802154_HWSIM_EDGE_ATTR_MAX, info-\u003eattrs[MAC802154_HWSIM_ATTR_RADIO_EDGE], hwsim_edge_policy, NULL))\ndrivers/net/ieee802154/mac802154_hwsim.c-702-\t\treturn -EINVAL;\n--\ndrivers/net/ieee802154/mac802154_hwsim.c-707-\ndrivers/net/ieee802154/mac802154_hwsim.c:708:\tv0 = nla_get_u32(info-\u003eattrs[MAC802154_HWSIM_ATTR_RADIO_ID]);\ndrivers/net/ieee802154/mac802154_hwsim.c-709-\tv1 = nla_get_u32(edge_attrs[MAC802154_HWSIM_EDGE_ATTR_ENDPOINT_ID]);\n--\ndrivers/net/ieee802154/mac802154_hwsim.c-746-\ndrivers/net/ieee802154/mac802154_hwsim.c:747:static const struct nla_policy hwsim_genl_policy[MAC802154_HWSIM_ATTR_MAX + 1] = {\ndrivers/net/ieee802154/mac802154_hwsim.c:748:\t[MAC802154_HWSIM_ATTR_RADIO_ID] = { .type = NLA_U32 },\ndrivers/net/ieee802154/mac802154_hwsim.c:749:\t[MAC802154_HWSIM_ATTR_RADIO_EDGE] = { .type = NLA_NESTED },\ndrivers/net/ieee802154/mac802154_hwsim.c:750:\t[MAC802154_HWSIM_ATTR_RADIO_EDGES] = { .type = NLA_NESTED },\ndrivers/net/ieee802154/mac802154_hwsim.c-751-};\n--\ndrivers/net/ieee802154/mac802154_hwsim.c=793=static struct genl_family hwsim_genl_family __ro_after_init = {\n--\ndrivers/net/ieee802154/mac802154_hwsim.c-795-\t.version = 1,\ndrivers/net/ieee802154/mac802154_hwsim.c:796:\t.maxattr = MAC802154_HWSIM_ATTR_MAX,\ndrivers/net/ieee802154/mac802154_hwsim.c-797-\t.policy = hwsim_genl_policy,\n--\ndrivers/net/ieee802154/mac802154_hwsim.h=19=enum {\n--\ndrivers/net/ieee802154/mac802154_hwsim.h-38- *\ndrivers/net/ieee802154/mac802154_hwsim.h:39: * @MAC802154_HWSIM_ATTR_UNSPEC: unspecified attribute to catch error\ndrivers/net/ieee802154/mac802154_hwsim.h:40: * @MAC802154_HWSIM_ATTR_RADIO_ID: u32 attribute to identify the radio\ndrivers/net/ieee802154/mac802154_hwsim.h:41: * @MAC802154_HWSIM_ATTR_EDGE: nested attribute of edges\ndrivers/net/ieee802154/mac802154_hwsim.h:42: * @MAC802154_HWSIM_ATTR_EDGES: list if nested attributes which contains the\ndrivers/net/ieee802154/mac802154_hwsim.h-43- *\tedge information according the radio id\ndrivers/net/ieee802154/mac802154_hwsim.h:44: * @__MAC802154_HWSIM_ATTR_MAX: enum limit\ndrivers/net/ieee802154/mac802154_hwsim.h-45- */\ndrivers/net/ieee802154/mac802154_hwsim.h=46=enum {\ndrivers/net/ieee802154/mac802154_hwsim.h:47:\tMAC802154_HWSIM_ATTR_UNSPEC,\ndrivers/net/ieee802154/mac802154_hwsim.h:48:\tMAC802154_HWSIM_ATTR_RADIO_ID,\ndrivers/net/ieee802154/mac802154_hwsim.h:49:\tMAC802154_HWSIM_ATTR_RADIO_EDGE,\ndrivers/net/ieee802154/mac802154_hwsim.h:50:\tMAC802154_HWSIM_ATTR_RADIO_EDGES,\ndrivers/net/ieee802154/mac802154_hwsim.h:51:\t__MAC802154_HWSIM_ATTR_MAX,\ndrivers/net/ieee802154/mac802154_hwsim.h-52-};\ndrivers/net/ieee802154/mac802154_hwsim.h-53-\ndrivers/net/ieee802154/mac802154_hwsim.h:54:#define MAC802154_HWSIM_ATTR_MAX (__MAC802154_HWSIM_ATTR_MAX - 1)\ndrivers/net/ieee802154/mac802154_hwsim.h-55-\n--\ndrivers/net/ieee802154/mac802154_hwsim.h-61- *\treceive for this edge\ndrivers/net/ieee802154/mac802154_hwsim.h:62: * @__MAC802154_HWSIM_ATTR_MAX: enum limit\ndrivers/net/ieee802154/mac802154_hwsim.h-63- */\n--\ndrivers/net/wireless/virtual/mac80211_hwsim.h=23=enum hwsim_tx_control_flags {\n--\ndrivers/net/wireless/virtual/mac80211_hwsim.h-58- *\tspace, uses:\ndrivers/net/wireless/virtual/mac80211_hwsim.h:59: *\t%HWSIM_ATTR_ADDR_TRANSMITTER, %HWSIM_ATTR_ADDR_RECEIVER,\ndrivers/net/wireless/virtual/mac80211_hwsim.h:60: *\t%HWSIM_ATTR_FRAME, %HWSIM_ATTR_FLAGS, %HWSIM_ATTR_RX_RATE,\ndrivers/net/wireless/virtual/mac80211_hwsim.h:61: *\t%HWSIM_ATTR_SIGNAL, %HWSIM_ATTR_COOKIE, %HWSIM_ATTR_FREQ (optional)\ndrivers/net/wireless/virtual/mac80211_hwsim.h-62- * @HWSIM_CMD_TX_INFO_FRAME: Transmission info report from user space to\ndrivers/net/wireless/virtual/mac80211_hwsim.h-63- *\tkernel, uses:\ndrivers/net/wireless/virtual/mac80211_hwsim.h:64: *\t%HWSIM_ATTR_ADDR_TRANSMITTER, %HWSIM_ATTR_FLAGS,\ndrivers/net/wireless/virtual/mac80211_hwsim.h:65: *\t%HWSIM_ATTR_TX_INFO, %HWSIM_ATTR_TX_INFO_FLAGS,\ndrivers/net/wireless/virtual/mac80211_hwsim.h:66: *\t%HWSIM_ATTR_SIGNAL, %HWSIM_ATTR_COOKIE\ndrivers/net/wireless/virtual/mac80211_hwsim.h-67- * @HWSIM_CMD_NEW_RADIO: create a new radio with the given parameters,\n--\ndrivers/net/wireless/virtual/mac80211_hwsim.h-69- *\tthen multicast the result, uses optional parameter:\ndrivers/net/wireless/virtual/mac80211_hwsim.h:70: *\t%HWSIM_ATTR_REG_STRICT_REG, %HWSIM_ATTR_SUPPORT_P2P_DEVICE,\ndrivers/net/wireless/virtual/mac80211_hwsim.h:71: *\t%HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE, %HWSIM_ATTR_CHANNELS,\ndrivers/net/wireless/virtual/mac80211_hwsim.h:72: *\t%HWSIM_ATTR_NO_VIF, %HWSIM_ATTR_RADIO_NAME, %HWSIM_ATTR_USE_CHANCTX,\ndrivers/net/wireless/virtual/mac80211_hwsim.h:73: *\t%HWSIM_ATTR_REG_HINT_ALPHA2, %HWSIM_ATTR_REG_CUSTOM_REG,\ndrivers/net/wireless/virtual/mac80211_hwsim.h:74: *\t%HWSIM_ATTR_PERM_ADDR\ndrivers/net/wireless/virtual/mac80211_hwsim.h-75- * @HWSIM_CMD_DEL_RADIO: destroy a radio, reply is multicasted\ndrivers/net/wireless/virtual/mac80211_hwsim.h-76- * @HWSIM_CMD_GET_RADIO: fetch information about existing radios, uses:\ndrivers/net/wireless/virtual/mac80211_hwsim.h:77: *\t%HWSIM_ATTR_RADIO_ID\ndrivers/net/wireless/virtual/mac80211_hwsim.h-78- * @HWSIM_CMD_ADD_MAC_ADDR: add a receive MAC address (given in the\ndrivers/net/wireless/virtual/mac80211_hwsim.h:79: *\t%HWSIM_ATTR_ADDR_RECEIVER attribute) to a device identified by\ndrivers/net/wireless/virtual/mac80211_hwsim.h:80: *\t%HWSIM_ATTR_ADDR_TRANSMITTER. This lets wmediumd forward frames\ndrivers/net/wireless/virtual/mac80211_hwsim.h-81- *\tto this receiver address for a given station.\n--\ndrivers/net/wireless/virtual/mac80211_hwsim.h-84- * @HWSIM_CMD_START_PMSR: request to start peer measurement with the\ndrivers/net/wireless/virtual/mac80211_hwsim.h:85: *\t%HWSIM_ATTR_PMSR_REQUEST. Result will be sent back asynchronously\ndrivers/net/wireless/virtual/mac80211_hwsim.h-86- *\twith %HWSIM_CMD_REPORT_PMSR.\n--\ndrivers/net/wireless/virtual/mac80211_hwsim.h=91=enum hwsim_commands {\n--\ndrivers/net/wireless/virtual/mac80211_hwsim.h-113- *\ndrivers/net/wireless/virtual/mac80211_hwsim.h:114: * @HWSIM_ATTR_UNSPEC: unspecified attribute to catch errors\ndrivers/net/wireless/virtual/mac80211_hwsim.h-115- *\ndrivers/net/wireless/virtual/mac80211_hwsim.h:116: * @HWSIM_ATTR_ADDR_RECEIVER: MAC address of the radio device that\ndrivers/net/wireless/virtual/mac80211_hwsim.h-117- *\tthe frame is broadcasted to\ndrivers/net/wireless/virtual/mac80211_hwsim.h:118: * @HWSIM_ATTR_ADDR_TRANSMITTER: MAC address of the radio device that\ndrivers/net/wireless/virtual/mac80211_hwsim.h-119- *\tthe frame was broadcasted from\ndrivers/net/wireless/virtual/mac80211_hwsim.h:120: * @HWSIM_ATTR_FRAME: Data array\ndrivers/net/wireless/virtual/mac80211_hwsim.h:121: * @HWSIM_ATTR_FLAGS: mac80211 transmission flags, used to process\ndrivers/net/wireless/virtual/mac80211_hwsim.h-122- *\tproperly the frame at user space\ndrivers/net/wireless/virtual/mac80211_hwsim.h:123: * @HWSIM_ATTR_RX_RATE: estimated rx rate index for this frame at user\ndrivers/net/wireless/virtual/mac80211_hwsim.h-124- *\tspace\ndrivers/net/wireless/virtual/mac80211_hwsim.h:125: * @HWSIM_ATTR_SIGNAL: estimated RX signal for this frame at user\ndrivers/net/wireless/virtual/mac80211_hwsim.h-126- *\tspace\ndrivers/net/wireless/virtual/mac80211_hwsim.h:127: * @HWSIM_ATTR_TX_INFO: ieee80211_tx_rate array\ndrivers/net/wireless/virtual/mac80211_hwsim.h:128: * @HWSIM_ATTR_COOKIE: sk_buff cookie to identify the frame\ndrivers/net/wireless/virtual/mac80211_hwsim.h:129: * @HWSIM_ATTR_CHANNELS: u32 attribute used with the %HWSIM_CMD_NEW_RADIO\ndrivers/net/wireless/virtual/mac80211_hwsim.h-130- *\tcommand giving the number of channels supported by the new radio\ndrivers/net/wireless/virtual/mac80211_hwsim.h:131: * @HWSIM_ATTR_RADIO_ID: u32 attribute used with %HWSIM_CMD_DESTROY_RADIO\ndrivers/net/wireless/virtual/mac80211_hwsim.h-132- *\tonly to destroy a radio\ndrivers/net/wireless/virtual/mac80211_hwsim.h:133: * @HWSIM_ATTR_REG_HINT_ALPHA2: alpha2 for regulatory driver hint\ndrivers/net/wireless/virtual/mac80211_hwsim.h-134- *\t(nla string, length 2)\ndrivers/net/wireless/virtual/mac80211_hwsim.h:135: * @HWSIM_ATTR_REG_CUSTOM_REG: custom regulatory domain index (u32 attribute)\ndrivers/net/wireless/virtual/mac80211_hwsim.h:136: * @HWSIM_ATTR_REG_STRICT_REG: request REGULATORY_STRICT_REG (flag attribute)\ndrivers/net/wireless/virtual/mac80211_hwsim.h:137: * @HWSIM_ATTR_SUPPORT_P2P_DEVICE: support P2P Device virtual interface (flag)\ndrivers/net/wireless/virtual/mac80211_hwsim.h:138: * @HWSIM_ATTR_USE_CHANCTX: used with the %HWSIM_CMD_NEW_RADIO\ndrivers/net/wireless/virtual/mac80211_hwsim.h-139- *\tcommand to force use of channel contexts even when only a\ndrivers/net/wireless/virtual/mac80211_hwsim.h-140- *\tsingle channel is supported\ndrivers/net/wireless/virtual/mac80211_hwsim.h:141: * @HWSIM_ATTR_DESTROY_RADIO_ON_CLOSE: used with the %HWSIM_CMD_NEW_RADIO\ndrivers/net/wireless/virtual/mac80211_hwsim.h-142- *\tcommand to force radio removal when process that created the radio dies\ndrivers/net/wireless/virtual/mac80211_hwsim.h:143: * @HWSIM_ATTR_RADIO_NAME: Name of radio, e.g. phy666\ndrivers/net/wireless/virtual/mac80211_hwsim.h:144: * @HWSIM_ATTR_NO_VIF:  Do not create vif (wlanX) when creating radio.\ndrivers/net/wireless/virtual/mac80211_hwsim.h:145: * @HWSIM_ATTR_FREQ: Frequency at which packet is transmitted or received.\ndrivers/net/wireless/virtual/mac80211_hwsim.h:146: * @HWSIM_ATTR_PAD: padding attribute for 64-bit values, ignore\ndrivers/net/wireless/virtual/mac80211_hwsim.h:147: * @HWSIM_ATTR_TX_INFO_FLAGS: additional flags for corresponding\ndrivers/net/wireless/virtual/mac80211_hwsim.h:148: *\trates of %HWSIM_ATTR_TX_INFO\ndrivers/net/wireless/virtual/mac80211_hwsim.h:149: * @HWSIM_ATTR_PERM_ADDR: permanent mac address of new radio\ndrivers/net/wireless/virtual/mac80211_hwsim.h:150: * @HWSIM_ATTR_IFTYPE_SUPPORT: u32 attribute of supported interface types bits\ndrivers/net/wireless/virtual/mac80211_hwsim.h:151: * @HWSIM_ATTR_CIPHER_SUPPORT: u32 array of supported cipher types\ndrivers/net/wireless/virtual/mac80211_hwsim.h:152: * @HWSIM_ATTR_MLO_SUPPORT: claim MLO support (exact parameters TBD) for\ndrivers/net/wireless/virtual/mac80211_hwsim.h-153- *\tthe new radio\ndrivers/net/wireless/virtual/mac80211_hwsim.h:154: * @HWSIM_ATTR_PMSR_SUPPORT: nested attribute used with %HWSIM_CMD_NEW_RADIO\ndrivers/net/wireless/virtual/mac80211_hwsim.h-155- *\tto provide peer measurement capabilities. (nl80211_peer_measurement_attrs)\ndrivers/net/wireless/virtual/mac80211_hwsim.h:156: * @HWSIM_ATTR_PMSR_REQUEST: nested attribute used with %HWSIM_CMD_START_PMSR\ndrivers/net/wireless/virtual/mac80211_hwsim.h-157- *\tto provide details about peer measurement request (nl80211_peer_measurement_attrs)\ndrivers/net/wireless/virtual/mac80211_hwsim.h:158: * @HWSIM_ATTR_PMSR_RESULT: nested attributed used with %HWSIM_CMD_REPORT_PMSR\ndrivers/net/wireless/virtual/mac80211_hwsim.h-159- *\tto provide peer measurement result (nl80211_peer_measurement_attrs)\ndrivers/net/wireless/virtual/mac80211_hwsim.h:160: * @HWSIM_ATTR_MULTI_RADIO: Register multiple wiphy radios (flag).\ndrivers/net/wireless/virtual/mac80211_hwsim.h-161- *\tAdds one radio for each band. Number of supported channels will be set for\ndrivers/net/wireless/virtual/mac80211_hwsim.h-162- *\teach radio instead of for the wiphy.\ndrivers/net/wireless/virtual/mac80211_hwsim.h:163: * @HWSIM_ATTR_SUPPORT_NAN_DEVICE: support NAN Device virtual interface (flag)\ndrivers/net/wireless/virtual/mac80211_hwsim.h:164: * @HWSIM_ATTR_SUPPORT_BACKGROUND_RADAR: background radar/CAC support (flag)\ndrivers/net/wireless/virtual/mac80211_hwsim.h:165: * @HWSIM_ATTR_NO_MONITOR: skip monitor report for this TX status, e.g. in case\ndrivers/net/wireless/virtual/mac80211_hwsim.h-166- *\tthe frame was never reported to any receiver (flag)\ndrivers/net/wireless/virtual/mac80211_hwsim.h:167: * @__HWSIM_ATTR_MAX: enum limit\ndrivers/net/wireless/virtual/mac80211_hwsim.h-168- */\n\n"
}

51/2 2026/10/14 16:45 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 134773
							output: 24
							thoughts: 55
						

Thoughts:
Okay, let me delve into this.

**Investigating `HWSIM_ATTR_PMSR_SUPPORT` in `mac80211_hwsim_main.c`**

Hold on a second, I need to focus. What's this `HWSIM_ATTR_PMSR_SUPPORT` thing? It's jumping out at me, and I need to figure out its purpose. My immediate instinct is to check the source code, specifically within `mac80211_hwsim_main.c`. That's the place where I would expect to find the definition and any usage of that particular attribute. I need to understand what this feature flag does within the context of the mac80211 hardware simulator. Is it enabling/disabling a particular feature? Does it relate to power management, since PMSR is suggestive of that? Perhaps it impacts the simulator's behavior in specific power-saving modes? I must analyze its implications within this file.



52/2 2026/10/14 16:45 tool grepper
0m Args:
{
  "Expression": "HWSIM_ATTR_PMSR_SUPPORT"
}

Results:
{
  "Output": "drivers/net/wireless/virtual/mac80211_hwsim.h=91=enum hwsim_commands {\n--\ndrivers/net/wireless/virtual/mac80211_hwsim.h-153- *\tthe new radio\ndrivers/net/wireless/virtual/mac80211_hwsim.h:154: * @HWSIM_ATTR_PMSR_SUPPORT: nested attribute used with %HWSIM_CMD_NEW_RADIO\ndrivers/net/wireless/virtual/mac80211_hwsim.h-155- *\tto provide peer measurement capabilities. (nl80211_peer_measurement_attrs)\n--\ndrivers/net/wireless/virtual/mac80211_hwsim.h=169=enum hwsim_attrs {\n--\ndrivers/net/wireless/virtual/mac80211_hwsim.h-195-\tHWSIM_ATTR_MLO_SUPPORT,\ndrivers/net/wireless/virtual/mac80211_hwsim.h:196:\tHWSIM_ATTR_PMSR_SUPPORT,\ndrivers/net/wireless/virtual/mac80211_hwsim.h-197-\tHWSIM_ATTR_PMSR_REQUEST,\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c=865=static const struct nla_policy hwsim_genl_policy[HWSIM_ATTR_MAX + 1] = {\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-892-\t[HWSIM_ATTR_MLO_SUPPORT] = { .type = NLA_FLAG },\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:893:\t[HWSIM_ATTR_PMSR_SUPPORT] = NLA_POLICY_NESTED(hwsim_pmsr_capa_policy),\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-894-\t[HWSIM_ATTR_PMSR_RESULT] = NLA_POLICY_NESTED(hwsim_pmsr_peers_result_policy),\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c=6910=static int hwsim_new_radio_nl(struct sk_buff *msg, struct genl_info *info)\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-7046-\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:7047:\tif (info-\u003eattrs[HWSIM_ATTR_PMSR_SUPPORT]) {\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-7048-\t\tstruct cfg80211_pmsr_capabilities *pmsr_capa;\n--\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-7056-\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c:7057:\t\tret = parse_pmsr_capa(info-\u003eattrs[HWSIM_ATTR_PMSR_SUPPORT], pmsr_capa, info);\ndrivers/net/wireless/virtual/mac80211_hwsim_main.c-7058-\t\tif (ret)\n"
}

53/2 2026/10/14 16:45 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 135921
							output: 50
							thoughts: 42
						

Thoughts:
Okay, here's my summary, taking on the persona you requested:

**Deconstructing `parse_pmsr_capa`**

Right, `parse_pmsr_capa`… time to dive into that function, specifically in `mac80211_hwsim_main.c`. I need to refresh my understanding of how it's handling the PMSr capability. I'm assuming it's part of the wider framework within `mac80211_hwsim` that emulates 802.11 hardware. My focus here is on understanding how this particular capability is interpreted and processed within the simulation. I will look for how the different fields of the PMSr capabilities are parsed and integrated with the relevant simulation structures. Is it simply extracting the raw data, or is there any semantic interpretation happening? Any interaction with other parts of the simulation is particularly relevant. Are there any notable optimizations or edge-case handling I should be aware of? Alright, let's get into the code!



54/2 2026/10/14 16:45 tool read-file
0m Args:
{
  "File": "drivers/net/wireless/virtual/mac80211_hwsim_main.c",
  "FirstLine": 6840,
  "LineCount": 70
}

Results:
{
  "Contents": "6840:\t\t\t\tout-\u003eftm.rsta.support_ntb =\n6841:\t\t\t\t\t!!rsta_tb[NL80211_PMSR_FTM_CAPA_ATTR_SUPPORT_NTB];\n6842:\t\t\t\tout-\u003eftm.rsta.support_tb =\n6843:\t\t\t\t\t!!rsta_tb[NL80211_PMSR_FTM_CAPA_ATTR_SUPPORT_TB];\n6844:\t\t\t\tout-\u003eftm.rsta.support_edca =\n6845:\t\t\t\t\t!!rsta_tb[NL80211_PMSR_FTM_CAPA_ATTR_SUPPORT_EDCA];\n6846:\t\t\t\tif (rsta_tb[NL80211_PMSR_ATTR_MAX_PEER_RSTA_ROLE])\n6847:\t\t\t\t\tout-\u003eftm.rsta.max_peers =\n6848:\t\t\t\t\t\tnla_get_u32(rsta_tb[NL80211_PMSR_ATTR_MAX_PEER_RSTA_ROLE]);\n6849:\t\t\t}\n6850:\t\t}\n6851:\t\n6852:\t\tif (tb[NL80211_PMSR_FTM_CAPA_ATTR_TYPE_CAPS]) {\n6853:\t\t\tstruct nlattr *type_tb[NL80211_PMSR_FTM_TYPE_CAPA_ATTR_MAX + 1];\n6854:\t\n6855:\t\t\tif (!nla_parse_nested(type_tb, NL80211_PMSR_FTM_TYPE_CAPA_ATTR_MAX,\n6856:\t\t\t\t\t      tb[NL80211_PMSR_FTM_CAPA_ATTR_TYPE_CAPS],\n6857:\t\t\t\t\t      hwsim_ftm_type_capa_policy, NULL)) {\n6858:\t\t\t\tout-\u003eftm.type.infra_support =\n6859:\t\t\t\t\t!!type_tb[NL80211_PMSR_FTM_TYPE_CAPA_ATTR_INFRA_SUPPORT];\n6860:\t\t\t\tout-\u003eftm.type.pd_support =\n6861:\t\t\t\t\t!!type_tb[NL80211_PMSR_FTM_TYPE_CAPA_ATTR_PD_SUPPORT];\n6862:\t\t\t}\n6863:\t\t}\n6864:\t\n6865:\t\tout-\u003eftm.concurrent_ista_rsta_support =\n6866:\t\t\t!!tb[NL80211_PMSR_FTM_CAPA_ATTR_CONCURRENT_ISTA_RSTA_SUPPORT];\n6867:\t\n6868:\t\treturn 0;\n6869:\t}\n6870:\t\n6871:\tstatic int parse_pmsr_capa(const struct nlattr *pmsr_capa, struct cfg80211_pmsr_capabilities *out,\n6872:\t\t\t\t   struct genl_info *info)\n6873:\t{\n6874:\t\tstruct nlattr *tb[NL80211_PMSR_ATTR_MAX + 1];\n6875:\t\tstruct nlattr *nla;\n6876:\t\tint size;\n6877:\t\tint ret;\n6878:\t\n6879:\t\tret = nla_parse_nested(tb, NL80211_PMSR_ATTR_MAX, pmsr_capa, hwsim_pmsr_capa_policy, NULL);\n6880:\t\tif (ret) {\n6881:\t\t\tNL_SET_ERR_MSG_ATTR(info-\u003eextack, pmsr_capa, \"malformed PMSR capability\");\n6882:\t\t\treturn -EINVAL;\n6883:\t\t}\n6884:\t\n6885:\t\tif (tb[NL80211_PMSR_ATTR_MAX_PEERS])\n6886:\t\t\tout-\u003emax_peers = nla_get_u32(tb[NL80211_PMSR_ATTR_MAX_PEERS]);\n6887:\t\tout-\u003ereport_ap_tsf = !!tb[NL80211_PMSR_ATTR_REPORT_AP_TSF];\n6888:\t\tout-\u003erandomize_mac_addr = !!tb[NL80211_PMSR_ATTR_RANDOMIZE_MAC_ADDR];\n6889:\t\n6890:\t\tif (!tb[NL80211_PMSR_ATTR_TYPE_CAPA]) {\n6891:\t\t\tNL_SET_ERR_MSG_ATTR(info-\u003eextack, tb[NL80211_PMSR_ATTR_TYPE_CAPA],\n6892:\t\t\t\t\t    \"malformed PMSR type\");\n6893:\t\t\treturn -EINVAL;\n6894:\t\t}\n6895:\t\n6896:\t\tnla_for_each_nested(nla, tb[NL80211_PMSR_ATTR_TYPE_CAPA], size) {\n6897:\t\t\tswitch (nla_type(nla)) {\n6898:\t\t\tcase NL80211_PMSR_TYPE_FTM:\n6899:\t\t\t\tparse_ftm_capa(nla, out, info);\n6900:\t\t\t\tbreak;\n6901:\t\t\tdefault:\n6902:\t\t\t\tNL_SET_ERR_MSG_ATTR(info-\u003eextack, nla, \"unsupported measurement type\");\n6903:\t\t\t\treturn -EINVAL;\n6904:\t\t\t}\n6905:\t\t}\n6906:\t\n6907:\t\treturn 0;\n6908:\t}\n6909:\t\n"
}

55/2 2026/10/14 16:45 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 137683
							output: 26
							thoughts: 5845
						

Thoughts:
**WorthFuzzing Analysis for Patch X**

Okay, so I've been given this patch and the task of determining if it's "WorthFuzzing". My initial thought is that it touches a lot of code related to NAN (Wi-Fi Aware) and PMSR (Peer Measurement Service Reporting), specifically the NDP (Neighbor Discovery Protocol) and FTM (Fine Timing Measurement) ranging aspects. And my immediate reaction is that I need to be careful.

My first task is to deeply understand what the code does, so I look for where the patch modifies the `mac80211_hwsim` driver, to understand where any new entry points exist.

I see that the patch modifies several functions: `nl80211_nan_ndp_initiate`, `nl80211_nan_ndp_respond`, `nl80211_nan_ndp_terminate`, `nl80211_nan_add_func`, `pmsr_parse_peer`, among others. I also note that some of these functions are used in core networking.

Now I read the instruction for determining whether a patch should be fuzzed. The instructions say that I need to determine if all of the modified code is *reachable*. I interpret this as "can a fuzzer *actually* trigger the execution of the code in a standard environment like QEMU?"

I see that the patch introduces a bunch of capability checks using flags like `WIPHY_NAN_FLAGS_OFFLOAD_NDP`, `WIPHY_NAN_FLAGS_OFFLOAD_RANGING`, and `!WIPHY_NAN_FLAGS_USERSPACE_DE`. My understanding is that these flags are designed for hardware offload of NAN features, but none of these flags are set by any driver in the kernel currently (e.g. `mac80211_hwsim`). Consequently, all the new functionality added by the patch (the NDP state machines, the NAN function attributes, the PMSR FTM ranging parser) seems to be gated behind these flags.

In particular, I see that functions like `nl80211_nan_ndp_initiate` and `nl80211_nan_add_func` *immediately* return `-EOPNOTSUPP` due to these flag checks, and that similar flag checks prevent reaching most of the new code paths. So I begin to wonder if the patch might be considered "unreachable".

I remember the instructions include:
"If the modified code is structurally unreachable (see Section 2), it MUST NOT be fuzzed, regardless of whether it adds assertions or complex logic."
and Section 2 defines situations such as:
"Unreachable execution paths" and notes:
* Code paths exclusive to architectures other than the target architecture.
* Driver teardown callbacks (.remove, .shutdown, pci_unregister_driver) executed only during physical PCI hot-unplug or manual sysfs driver unbinding.

I dig into `net/wireless/nl80211.c` and confirm that, indeed, all the core functions such as `nl80211_nan_ndp_initiate` return immediately with error codes due to the missing offload capabilities. Also, `nl80211_nan_add_func` returns `-EOPNOTSUPP` because of the `WIPHY_NAN_FLAGS_USERSPACE_DE` flag. This flag is set on every NAN capable Wi-Fi driver, so I reason that the execution path is impossible.

I read the instruction more carefully, and I see that a check like `if (wdev->wiphy->nan_capa.flags & WIPHY_NAN_FLAGS_USERSPACE_DE)` is added to prevent `WARN_ON` from triggering, and it modifies core networking code.

So I think and I read Section 1: "REACHABILITY IS THE PRIMARY GATE: Fuzzing can only discover bugs in code that can actually execute in standard virtualized environments (GCE or QEMU, utilizing software-emulated devices like USB gadgets, netdev, tun/tap). If the modified code is structurally unreachable (see Section 2), it MUST NOT be fuzzed, regardless of whether it adds assertions or complex logic."

Then I read Section 3: "WHEN TO RETURN WorthFuzzing=true (POSITIVE CRITERIA) Return WorthFuzzing=true whenever the patch touches reachable executable code, including: - Core Subsystems: * Any logic modifications in memory management (mm/), synchronization/locking (kernel/locking/), BPF, scheduler, core networking, VFS, or syscall handling. - Refactorings and Code Cleanups: * Any restructuring of reachable data structures, helper abstractions, or algorithm flows. -


56/2 2026/10/14 16:46 tool codesearch-dir-index
0m Args:
{
  "Dir": "drivers/net/wireless/virtual/"
}

Results:
{
  "Files": [
    "mac80211_hwsim.h",
    "mac80211_hwsim_i.h",
    "mac80211_hwsim_main.c",
    "mac80211_hwsim_nan.c",
    "mac80211_hwsim_nan.h",
    "virt_wifi.c"
  ],
  "Subdirs": null
}

57/2 2026/10/14 16:46 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 144678
							output: 43
							thoughts: 37
						

Thoughts:
Okay, here's my thought process on this, expressed as if I'm thinking it:

**NAN Support in virt_wifi.c**

Alright, time to dig into this. I need to figure out if `virt_wifi.c` actually implements or supports NAN. So, first things first, let's take a look at the file itself. Specifically, I'm going to run a quick grep. The obvious approach is to search for keywords. I'll search for both lowercase "nan" and uppercase "NAN" – just to be thorough and cover all bases, including any potential preprocessor macros. That should give me a solid starting point to determine the extent of its NAN-related functionality. Let's see what turns up.



58/2 2026/10/14 16:46 tool grepper
0m Error:
no matches

Args:
{
  "Expression": "[Nn][Aa][Nn]",
  "PathPrefixes": [
    "drivers/net/wireless/virtual/virt_wifi.c"
  ]
}

Results:
{
  "error": "no matches"
}

59/2 2026/10/14 16:46 llm patch-evaluator
1m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 144929
							output: 33
							thoughts: 8689
						

Thoughts:
**Triage Decision: WorthFuzzing=true**

Alright, after meticulously dissecting this patch and its implications, the decision is clear. While the core functionality added—NAN NDP and ranging offload—might be gated by driver support that doesn't exist in our standard QEMU environment, the *interface* itself is undeniably reachable. The netlink commands, the added defensive checks, and the modified code paths within `net/wireless/nl80211.c` and `net/wireless/pmsr.c` are accessible.

The "reachability is primary gate" guideline is the guiding light, and the code isn't in a vendor driver's structure nor does it rely on physical removal, so those aren't applicable.  Even if the substantive features of the NAN offload are unreachable, the fact that Netlink commands like `NL80211_CMD_NAN_NDP_INITIATE` are added and accessible means the code *can* execute. The added defensive checks, specifically the one in `nl80211_nan_add_func`, are directly triggered by a userspace netlink command. This means these checks in `net/wireless/nl80211.c` and other reachable code will trigger new invariants and can be fuzzed for errors.

We can't blindly trust a claim that changes are simply "not functional" or "refactoring." The changes *can* introduce subtle shifts. By exposing these symbols in `FocusSymbols`, we can guide syzkaller to target this code!

Therefore, we have a clear "WorthFuzzing=true" decision. Syzkaller knows about netlink, and thus can target the new netlink commands.



60/2 2026/10/14 16:47 tool grepper
0m Args:
{
  "Expression": "config CFG80211",
  "PathPrefixes": [
    "net/wireless/"
  ]
}

Results:
{
  "Output": "net/wireless/Kconfig=14=config WEXT_PRIV\n--\nnet/wireless/Kconfig-16-\nnet/wireless/Kconfig:17:config CFG80211\nnet/wireless/Kconfig-18-\ttristate \"cfg80211 - wireless configuration API\"\n--\nnet/wireless/Kconfig=38=config NL80211_TESTMODE\n--\nnet/wireless/Kconfig-51-\nnet/wireless/Kconfig:52:config CFG80211_DEVELOPER_WARNINGS\nnet/wireless/Kconfig-53-\tbool \"enable developer warnings\"\n--\nnet/wireless/Kconfig-67-\nnet/wireless/Kconfig:68:config CFG80211_CERTIFICATION_ONUS\nnet/wireless/Kconfig-69-\tbool \"cfg80211 certification onus\"\n--\nnet/wireless/Kconfig-88-\nnet/wireless/Kconfig:89:config CFG80211_REQUIRE_SIGNED_REGDB\nnet/wireless/Kconfig-90-\tbool \"require regdb signature\" if CFG80211_CERTIFICATION_ONUS\n--\nnet/wireless/Kconfig-98-\nnet/wireless/Kconfig:99:config CFG80211_USE_KERNEL_REGDB_KEYS\nnet/wireless/Kconfig-100-\tbool \"allow regdb keys shipped with the kernel\" if CFG80211_CERTIFICATION_ONUS\n--\nnet/wireless/Kconfig-110-\nnet/wireless/Kconfig:111:config CFG80211_EXTRA_REGDB_KEYDIR\nnet/wireless/Kconfig-112-\tstring \"additional regdb key directory\" if CFG80211_CERTIFICATION_ONUS\n--\nnet/wireless/Kconfig-121-\nnet/wireless/Kconfig:122:config CFG80211_REG_CELLULAR_HINTS\nnet/wireless/Kconfig-123-\tbool \"cfg80211 regulatory support for cellular base station hints\"\n--\nnet/wireless/Kconfig-134-\nnet/wireless/Kconfig:135:config CFG80211_REG_RELAX_NO_IR\nnet/wireless/Kconfig-136-\tbool \"cfg80211 support for NO_IR relaxation\"\n--\nnet/wireless/Kconfig-158-\nnet/wireless/Kconfig:159:config CFG80211_DEFAULT_PS\nnet/wireless/Kconfig-160-\tbool \"enable powersave by default\"\n--\nnet/wireless/Kconfig-168-\nnet/wireless/Kconfig:169:config CFG80211_DEBUGFS\nnet/wireless/Kconfig-170-\tbool \"cfg80211 DebugFS entries\"\n--\nnet/wireless/Kconfig-176-\nnet/wireless/Kconfig:177:config CFG80211_CRDA_SUPPORT\nnet/wireless/Kconfig-178-\tbool \"support CRDA\" if EXPERT\n--\nnet/wireless/Kconfig-186-\nnet/wireless/Kconfig:187:config CFG80211_WEXT\nnet/wireless/Kconfig-188-\tbool \"cfg80211 wireless extensions compatibility\"\n--\nnet/wireless/Kconfig-193-\nnet/wireless/Kconfig:194:config CFG80211_KUNIT_TEST\nnet/wireless/Kconfig-195-\ttristate \"KUnit tests for cfg80211\" if !KUNIT_ALL_TESTS\n"
}

61/2 2026/10/14 16:47 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 154936
							output: 31
							thoughts: 39
						

Thoughts:
Okay, here's my take on those thoughts, tailored for an expert audience:

**Investigating the Build Process for Key Wireless Components**

Right, time to dig into the build process for a few critical wireless components. I need to understand how `nl80211.c`, `pmsr.c`, and `util.c` get integrated into the kernel. My first instinct, and the most logical starting point, is to go straight to `net/wireless/Makefile`. That's where the magic should happen, where the dependencies and build rules are likely defined. I want to see exactly how these source files are compiled and linked, and what variables or flags might be relevant to their inclusion. I’m especially interested in whether any specific build-time configurations or kernel features directly impact their compilation. Hopefully, I'll find the dependencies and see the process clearly. I'm expecting to see the standard Kbuild idioms.



62/2 2026/10/14 16:47 tool read-file
0m Args:
{
  "File": "net/wireless/Makefile",
  "FirstLine": 1,
  "LineCount": 40
}

Results:
{
  "Contents": "   1:\t# SPDX-License-Identifier: GPL-2.0\n   2:\tobj-$(CONFIG_CFG80211) += cfg80211.o\n   3:\tobj-y += tests/\n   4:\t\n   5:\tobj-$(CONFIG_WEXT_CORE) += wext-core.o\n   6:\tobj-$(CONFIG_WEXT_PROC) += wext-proc.o\n   7:\tobj-$(CONFIG_WEXT_PRIV) += wext-priv.o\n   8:\t\n   9:\tcfg80211-y += core.o sysfs.o radiotap.o util.o reg.o scan.o nl80211.o\n  10:\tcfg80211-y += mlme.o ibss.o sme.o chan.o ethtool.o mesh.o ap.o trace.o ocb.o\n  11:\tcfg80211-y += michael-mic.o pmsr.o\n  12:\tcfg80211-$(CONFIG_OF) += of.o\n  13:\tcfg80211-$(CONFIG_CFG80211_DEBUGFS) += debugfs.o\n  14:\tcfg80211-$(CONFIG_CFG80211_WEXT) += wext-compat.o wext-sme.o\n  15:\t\n  16:\tCFLAGS_trace.o := -I$(src)\n  17:\t\n  18:\tcfg80211-$(CONFIG_CFG80211_USE_KERNEL_REGDB_KEYS) += shipped-certs.o\n  19:\tifneq ($(CONFIG_CFG80211_EXTRA_REGDB_KEYDIR),)\n  20:\tcfg80211-y += extra-certs.o\n  21:\tendif\n  22:\t\n  23:\t$(obj)/shipped-certs.c: $(sort $(wildcard $(src)/certs/*.hex))\n  24:\t\t@$(kecho) \"  GEN     $@\"\n  25:\t\t$(Q)(echo '#include \"reg.h\"'; \\\n  26:\t\t  echo 'const u8 shipped_regdb_certs[] = {'; \\\n  27:\t\t  echo | cat - $^ ; \\\n  28:\t\t  echo '};'; \\\n  29:\t\t  echo 'unsigned int shipped_regdb_certs_len = sizeof(shipped_regdb_certs);'; \\\n  30:\t\t ) \u003e $@\n  31:\t\n  32:\t$(obj)/extra-certs.c: $(CONFIG_CFG80211_EXTRA_REGDB_KEYDIR) \\\n  33:\t\t\t      $(sort $(wildcard $(CONFIG_CFG80211_EXTRA_REGDB_KEYDIR)/*.x509))\n  34:\t\t@$(kecho) \"  GEN     $@\"\n  35:\t\t$(Q)(set -e; \\\n  36:\t\t  allf=\"\"; \\\n  37:\t\t  for f in $^ ; do \\\n  38:\t\t      test -f $$f || continue;\\\n  39:\t\t      # similar to hexdump -v -e '1/1 \"0x%.2x,\" \"\\n\"' \\\n  40:\t\t      thisf=$$(od -An -v -tx1 \u003c $$f | \\\n"
}

63/2 2026/10/14 16:47 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 156045
							output: 33
							thoughts: 80
						

Thoughts:
Here's my summary, as I see it:

**Digging into the Wireless Configuration Landscape**

Okay, so I'm looking at these object files – `nl80211.o`, `pmsr.o`, and `util.o`. They're all part of that broader `cfg80211-y` module, which is, in turn, built when we enable `CONFIG_CFG80211`. That suggests `CFG80211` is the controlling factor here. My next logical step is to dive into the dependencies of `CFG80211`. I'll head over to `net/wireless/Kconfig` to see what I can find. Understanding the dependencies will give me a better understanding of how the components fit together and what other configurations might be at play.



64/2 2026/10/14 16:48 tool read-file
0m Args:
{
  "File": "net/wireless/Kconfig",
  "FirstLine": 15,
  "LineCount": 25
}

Results:
{
  "Contents": "  15:\t\tbool\n  16:\t\n  17:\tconfig CFG80211\n  18:\t\ttristate \"cfg80211 - wireless configuration API\"\n  19:\t\tdepends on RFKILL || !RFKILL\n  20:\t\tselect FW_LOADER\n  21:\t\tselect CRC32\n  22:\t\t# may need to update this when certificates are changed and are\n  23:\t\t# using a different algorithm, though right now they shouldn't\n  24:\t\t# (this is here rather than below to allow it to be a module)\n  25:\t\tselect CRYPTO_SHA256 if CFG80211_USE_KERNEL_REGDB_KEYS\n  26:\t\thelp\n  27:\t\t  cfg80211 is the Linux wireless LAN (802.11) configuration API.\n  28:\t\t  Enable this if you have a wireless device.\n  29:\t\n  30:\t\t  For more information refer to documentation on the wireless wiki:\n  31:\t\n  32:\t\t  https://wireless.wiki.kernel.org/en/developers/Documentation/cfg80211\n  33:\t\n  34:\t\t  When built as a module it will be called cfg80211.\n  35:\t\n  36:\tif CFG80211\n  37:\t\n  38:\tconfig NL80211_TESTMODE\n  39:\t\tbool \"nl80211 testmode command\"\n"
}

65/2 2026/10/14 16:48 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 156725
							output: 25
							thoughts: 46
						

Thoughts:
Here's my take on those thoughts:

**Investigating the MAC80211_HWSIM Configuration**

Okay, so I'm thinking about `MAC80211_HWSIM`. I need to figure out how that specific virtual driver is configured. Where would I find the build configuration options? My first instinct is to look within the wireless driver's directory structure. Let me check under `drivers/net/wireless/virtual/`. Yep, that makes sense. Kconfig files typically handle these types of options, so I'll go directly to `Kconfig` or similar and see what's what. That should tell me everything I need to know about how this module is enabled.



66/2 2026/10/14 16:48 tool grepper
0m Args:
{
  "Expression": "config MAC80211_HWSIM"
}

Results:
{
  "Output": "drivers/net/wireless/virtual/Kconfig:1:config MAC80211_HWSIM\ndrivers/net/wireless/virtual/Kconfig-2-\ttristate \"Simulated radio testing tool for mac80211\"\n"
}

67/2 2026/10/14 16:48 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 157016
							output: 36
							thoughts: 16
						

Thoughts:
Here's a first-person summary, tailored for an expert audience, based on the prompt:

**Diving into the Virtual Wireless Kconfig**

Okay, let's pull up the `drivers/net/wireless/virtual/Kconfig` file. I'm expecting the usual suspects here, but it's always good to refresh my memory on the specific configuration options and their dependencies within this virtual wireless layer. My initial thought is to quickly scan for any new or changed features since the last time I dug into this area. I'm particularly interested in anything related to recent advancements in virtualization technology – like improvements in host-guest interaction or if there are any new virtual NIC driver additions. The goal is to see how the kernel configuration is reflecting, or perhaps even driving, those changes. I'll be looking for well-defined symbols, robust default values, and sensible dependencies to ensure a clean and maintainable setup. I'm also ready to analyze any conditional logic – I want to understand exactly when these virtual wireless features are enabled or disabled, and the underlying rationale. It's time to get a clear picture of how this configuration is structuring the build for virtual wireless functionality.



68/2 2026/10/14 16:48 tool read-file
0m Args:
{
  "File": "drivers/net/wireless/virtual/Kconfig",
  "FirstLine": 1,
  "LineCount": 20
}

Results:
{
  "Contents": "   1:\tconfig MAC80211_HWSIM\n   2:\t\ttristate \"Simulated radio testing tool for mac80211\"\n   3:\t\tdepends on MAC80211\n   4:\t\thelp\n   5:\t\t  This driver is a developer testing tool that can be used to test\n   6:\t\t  IEEE 802.11 networking stack (mac80211) functionality. This is not\n   7:\t\t  needed for normal wireless LAN usage and is only for testing. See\n   8:\t\t  Documentation/networking/mac80211_hwsim for more information on how\n   9:\t\t  to use this tool.\n  10:\t\n  11:\t\t  To compile this driver as a module, choose M here: the module will be\n  12:\t\t  called mac80211_hwsim.  If unsure, say N.\n  13:\t\n  14:\tconfig VIRT_WIFI\n  15:\t\ttristate \"Wifi wrapper for ethernet drivers\"\n  16:\t\tdepends on CFG80211\n  17:\t\thelp\n  18:\t\t  This option adds support for ethernet connections to appear as if they\n  19:\t\t  are wifi connections through a special rtnetlink device.\n  20:\t\n"
}

69/2 2026/10/14 16:48 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 157637
							output: 402
							thoughts: 1289
						

Thoughts:
**Analysis of New Wireless Functionality for Fuzzing**

Okay, let's break this down. First, I see that `CFG80211` is essential – that's the core configuration needed for compiling the `nl80211`, `pmsr`, and `util` wireless files. And of course, `MAC80211_HWSIM` with `MAC80211` is what allows us to create the simulated virtual radios that syzkaller needs. Good, we have the prerequisites.

Now, let's get into the heart of the matter: the FocusSymbols. I need to understand exactly what new functionality we're dealing with. Okay, looking at `net/wireless/nl80211.c`, I see: `nl80211_nan_ndp_initiate`, `nl80211_nan_ndp_respond`, `nl80211_nan_ndp_terminate`, `nl80211_nan_add_func`, `cfg80211_nan_ndp_request`, `cfg80211_nan_ndp_confirm`, `cfg80211_nan_ndp_terminated`, and `cfg80211_nan_match`. All seem related to NAN (Neighbor Awareness Networking) and NDP (Neighbor Discovery Protocol). Then, in `net/wireless/pmsr.c` (Peer Measurement/Ranging), I've got `pmsr_parse_ftm_nan`, `pmsr_parse_peer`, and `nl80211_pmsr_start`, which looks like the entry point for `pmsr_parse_peer`. Finally, `cfg80211_free_nan_func` in `net/wireless/util.c`.

Wait, before I get carried away, let's establish if any of these are static. Right, `nl80211_nan_ndp_initiate` is static, but it's referenced through a function pointer (`nl80211_small_ops`), so the compiler keeps it! And `nl80211_nan_ndp_respond`, `nl80211_nan_ndp_terminate`, `nl80211_nan_add_func`, `pmsr_parse_ftm_nan`, `pmsr_parse_peer` are static too. `nl80211_pmsr_start` is non-static (an entrypoint) in `pmsr.c`. Then, `cfg80211_nan_ndp_request`, `cfg80211_nan_ndp_confirm`, `cfg80211_nan_ndp_terminated`, `cfg80211_nan_match`, and `cfg80211_free_nan_func` are non-static and EXPORT_SYMBOL, so they're accessible from elsewhere.

Alright, that's the landscape. Are any of these symbols ubiquitous across the kernel, i.e., general memory allocators, page fault handlers or core lifecycle functions? No. They are all very specifically tied to NAN/NDP or PMSR within the cfg80211/nl80211 framework, which is good for targeting.

Let's do a final check to confirm everything. Yes, it's WorthFuzzing. The correct EnableConfigs are there: `CFG80211`, `MAC80211`, and `MAC80211_HWSIM`. And the FocusSymbols are precisely those functions I just reviewed. The reasoning is solid: This patch introduces new NAN NDP and PMSR support, including new netlink commands, new attributes, and peer measurement parsing. These functions are reachable via generic netlink (`AF_NETLINK`) in mac80211/mac80211_hwsim environments. All clear and ready. Let's set the results and move on.



70/2 2026/10/14 16:49 tool set-results
0m Args:
{
  "EnableConfigs": [
    "CFG80211",
    "MAC80211",
    "MAC80211_HWSIM"
  ],
  "FocusSymbols": [
    "nl80211_nan_ndp_initiate",
    "nl80211_nan_ndp_respond",
    "nl80211_nan_ndp_terminate",
    "nl80211_nan_add_func",
    "nl80211_pmsr_start",
    "pmsr_parse_peer",
    "pmsr_parse_ftm_nan",
    "cfg80211_nan_ndp_request",
    "cfg80211_nan_ndp_confirm",
    "cfg80211_nan_ndp_terminated",
    "cfg80211_nan_match",
    "cfg80211_free_nan_func"
  ],
  "Reasoning": "The patch series adds infrastructure for NAN Data Path (NDP) and NAN Ranging in cfg80211 and nl80211. It introduces three new netlink commands (NL80211_CMD_NAN_NDP_INITIATE, NL80211_CMD_NAN_NDP_RESPOND, NL80211_CMD_NAN_NDP_TERMINATE), adds new netlink policies and attributes, introduces defensive checks in nl80211_nan_add_func, and extends peer measurement (PMSR) parsing for NAN ranging. This code is in the core networking subsystem and directly accessible from userspace over Generic Netlink in standard virtualized environments supporting mac80211_hwsim.",
  "WorthFuzzing": true
}

Results:
{
  "EnableConfigs": [
    "CFG80211",
    "MAC80211",
    "MAC80211_HWSIM"
  ],
  "FocusSymbols": [
    "nl80211_nan_ndp_initiate",
    "nl80211_nan_ndp_respond",
    "nl80211_nan_ndp_terminate",
    "nl80211_nan_add_func",
    "nl80211_pmsr_start",
    "pmsr_parse_peer",
    "pmsr_parse_ftm_nan",
    "cfg80211_nan_ndp_request",
    "cfg80211_nan_ndp_confirm",
    "cfg80211_nan_ndp_terminated",
    "cfg80211_nan_match",
    "cfg80211_free_nan_func"
  ],
  "Reasoning": "The patch series adds infrastructure for NAN Data Path (NDP) and NAN Ranging in cfg80211 and nl80211. It introduces three new netlink commands (NL80211_CMD_NAN_NDP_INITIATE, NL80211_CMD_NAN_NDP_RESPOND, NL80211_CMD_NAN_NDP_TERMINATE), adds new netlink policies and attributes, introduces defensive checks in nl80211_nan_add_func, and extends peer measurement (PMSR) parsing for NAN ranging. This code is in the core networking subsystem and directly accessible from userspace over Generic Netlink in standard virtualized environments supporting mac80211_hwsim.",
  "WorthFuzzing": true
}

71/1 2026/10/14 16:49 action If
8m Args:
{
  "WorthFuzzing": true
}

Results:
null

72/2 2026/10/14 16:49 agent kmsan-evaluator
8m Model:
core

Args:
null

Results:
{
  "KMSANReasoning": "The patch series adds support for NAN Data Path (NDP) offload and NAN ranging to cfg80211 and nl80211.\n\n1. Memory Initialization:\n- Stack-allocated structures in nl80211 handlers (`struct cfg80211_nan_ndp_initiate`, `struct cfg80211_nan_ndp_respond`, and `struct cfg80211_nan_ndp_terminate`) are zero-initialized upon declaration using `= {}`.\n- Heap-allocated structures that hold the parsed data (`cfg80211_nan_func` and `cfg80211_pmsr_request`) are allocated using `kzalloc_obj()` and `kzalloc_flex()`, respectively, ensuring all newly added struct fields start in a zeroed state.\n- Dynamic arrays such as `func-\u003ecsids` are allocated and populated with `kmemdup()` after validating that the netlink attribute length is a multiple of `sizeof(u32)`.\n- Channel configuration parsing via `nl80211_parse_chandef()` explicitly zeroes `chandef` with `memset()` before populating it.\n\n2. Kernel-to-Userspace Communication:\n- Netlink notifications to userspace (`cfg80211_nan_match`, `cfg80211_nan_ndp_request`, `cfg80211_nan_ndp_confirm`, and `cfg80211_nan_ndp_terminated`) construct messages using individual typed Netlink helpers (`nla_put_u8`, `nla_put_u16`, `nla_put_u32`, `nla_put_s32`, `nla_put_flag`) and bounded byte buffers (`nla_put`).\n- No raw structs containing uninitialized padding or uninitialized memory fields are copied or leaked to userspace via `copy_to_user` or netlink blobs.\n\n3. KASAN vs KMSAN Applicability:\n- Any risks arising from these changes pertain to Netlink attribute parsing, length validation, or pointer manipulation (such as NULL dereferences or out-of-bounds accesses), which are comprehensively covered by KASAN and standard bug detectors.\n- There are no risks of uninitialized memory reads, conditional branching on uninitialized data, or information leaks. Therefore, a dedicated KMSAN fuzzing session is not warranted.",
  "NeedsKMSAN": false
}

Instruction:
You are an expert Linux kernel security engineer specializing in kernel memory
error detectors (KASAN and KMSAN). Your job is to review the provided patch series and
determine if the code changes justify spawning a dedicated KMSAN (KernelMemorySanitizer)
fuzzing session in addition to standard KASAN fuzzing.

CRITICAL DISTINCTION BETWEEN KASAN AND KMSAN:
- Standard KASAN kernel builds (upstream-apparmor-kasan.config) already enable
  a comprehensive suite of debugging tools and sanitizers, including KASAN
  (out-of-bounds accesses, use-after-free, double free, invalid free), LOCKDEP
  (locking bugs and deadlocks), UB-sanitizers, and memory corruption checks.
- KMSAN (KernelMemorySanitizer) detects reads of UNINITIALIZED memory (stack, heap,
  or page allocations) and kernel-to-user memory info-leaks.

Rule: THERE IS NO SENSE IN RUNNING A KMSAN SESSION IF A BUG CAN BE CAUGHT BY KASAN,
LOCKDEP, OR OTHER STANDARD BUG DETECTORS.
A dedicated KMSAN fuzzing session incurs significant resource costs. You must ONLY
set NeedsKMSAN=true if the code changes introduce or expose UNINITIALIZED MEMORY risks
that are detected ONLY by KMSAN.

Look holistically at the patch series and surrounding code. Even if no direct
uninitialized field accesses or new buffer allocations are added in the diff itself,
a patch may alter control flow, bounds checking, or data length calculations in ways
that change how the rest of the code operates on existing buffers (e.g. allowing
uninitialized stack/heap memory to be read, copied to user space, or used in control
flow). Do not hesitate to use your code access tools to inspect the surrounding code,
called functions, and callers.

Set NeedsKMSAN=true ONLY IF the patch introduces or modifies:
1. Kernel structures sent to user space (via copy_to_user, put_user, netlink skb
   attributes, ioctl output arguments, socket options, or BPF buffers) where fields
   or structure padding might not be fully initialized/zeroed.
2. Conditional logic or branching that depends on potentially uninitialized variables
   or struct fields.
3. Allocation or initialization of complex data structures where uninitialized fields
   could be read later in reachable code paths.
4. Bounds checks, lengths, or logic in a way that allows surrounding code to access
   uninitialized bytes of existing buffers.

Set NeedsKMSAN=false IF:
- The code changes primarily risk out-of-bounds access, array overflows, NULL pointer
  dereferences, locking deadlocks, or use-after-free bugs (these are already caught
  by KASAN, LOCKDEP, or standard bug detectors).
- All stack/heap structures touched or introduced by the patch are fully zeroed
  or initialized (e.g. using = {0}, memset, kzalloc) before being read or copied.
- The patch does not introduce any risk of uninitialized memory usage or info-leaks.

Use your code access tools to inspect the surrounding code if necessary, then provide
detailed KMSANReasoning contrasting KASAN vs KMSAN applicability for this patch.
Prefer calling several tools at the same time to save round-trips.


Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.

Prompt:
Target architecture: amd64

For your convenience, here is the diff of the changes:
commit e69ce378af275ac551b3277525fb9a976aef3381
Author: syz-cluster <triage@syzkaller.com>
Date:   Wed Oct 14 16:38:25 2026 +0000

    syz-cluster: applied patch under review

diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index f773856c18181..8e0325501bcf4 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -4334,6 +4334,192 @@ struct cfg80211_nan_peer_sched {
 	struct cfg80211_nan_peer_map maps[CFG80211_NAN_MAX_PEER_MAPS];
 };
 
+/**
+ * struct cfg80211_nan_ndp_initiate - NAN NDP initiate parameters
+ *
+ * @peer_nmi: peer NMI address
+ * @publish_id: publisher's service instance ID
+ * @service_id: NAN service ID (%NL80211_NAN_FUNC_SERVICE_ID_LEN bytes)
+ * @init_ndi: initiator NDI MAC address. The corresponding
+ *	%NL80211_IFTYPE_NAN_DATA interface must exist.
+ * @ssi: service-specific info (may be NULL)
+ * @ssi_len: length of @ssi
+ * @cipher_suite: NAN cipher suite ID, 0 for open NDP
+ * @pmk: NAN Data Path PMK (%NL80211_NAN_NDP_PMK_LEN bytes,
+ *	valid when @pmk_set is true)
+ * @pmk_set: if true, @pmk contains a valid PMK
+ * @pmkid: PMKID (%NL80211_NAN_NDP_PMKID_LEN bytes,
+ *	valid when @pmkid_set is true)
+ * @pmkid_set: if true, @pmkid contains a valid PMKID
+ * @gtk_required: if true, GTK protection is required
+ * @gtk_cipher: GTK cipher suite ID (valid when @gtk_required is true)
+ * @ipv6_intf_id: IPv6 link-local interface identifier
+ *	(%NL80211_NAN_NDP_IPV6_INTF_ID_LEN bytes,
+ *	valid when @ipv6_intf_id_set is true)
+ * @ipv6_intf_id_set: if true, @ipv6_intf_id is valid
+ * @ndpe: if true, use NDPE attribute instead of NDP attribute
+ */
+struct cfg80211_nan_ndp_initiate {
+	const u8 *peer_nmi;
+	u8 publish_id;
+	u8 service_id[NL80211_NAN_FUNC_SERVICE_ID_LEN];
+	const u8 *init_ndi;
+	const u8 *ssi;
+	u8 ssi_len;
+	u32 cipher_suite;
+	u8 pmk[NL80211_NAN_NDP_PMK_LEN];
+	bool pmk_set;
+	u8 pmkid[NL80211_NAN_NDP_PMKID_LEN];
+	bool pmkid_set;
+	bool gtk_required;
+	u32 gtk_cipher;
+	u8 ipv6_intf_id[NL80211_NAN_NDP_IPV6_INTF_ID_LEN];
+	bool ipv6_intf_id_set;
+	bool ndpe;
+};
+
+/**
+ * struct cfg80211_nan_ndp_respond - NAN NDP respond parameters
+ *
+ * @peer_nmi: peer NMI address
+ * @ndp_id: NDP ID from the received NDP Request
+ * @init_ndi: initiator NDI MAC from the received NDP Request
+ * @resp_ndi: responder NDI MAC. The corresponding
+ *	%NL80211_IFTYPE_NAN_DATA interface must exist (if accepting).
+ * @accept: if true, accept the NDP; if false, reject it
+ * @reason: rejection reason code (valid when @accept is false)
+ * @ssi: response service-specific info (may be NULL)
+ * @ssi_len: length of @ssi
+ * @cipher_suite: NAN cipher suite ID (must match initiator's)
+ * @pmk: NAN Data Path PMK (%NL80211_NAN_NDP_PMK_LEN bytes,
+ *	valid when @pmk_set is true)
+ * @pmk_set: if true, @pmk contains a valid PMK
+ * @gtk_required: if true, GTK protection is required
+ * @gtk_cipher: GTK cipher suite ID
+ * @ipv6_intf_id: IPv6 link-local interface identifier
+ *	(%NL80211_NAN_NDP_IPV6_INTF_ID_LEN bytes,
+ *	valid when @ipv6_intf_id_set is true)
+ * @ipv6_intf_id_set: if true, @ipv6_intf_id is valid
+ * @ndpe: if true, use NDPE attribute instead of NDP attribute
+ */
+struct cfg80211_nan_ndp_respond {
+	const u8 *peer_nmi;
+	u8 ndp_id;
+	const u8 *init_ndi;
+	const u8 *resp_ndi;
+	bool accept;
+	u8 reason;
+	const u8 *ssi;
+	u8 ssi_len;
+	u32 cipher_suite;
+	u8 pmk[NL80211_NAN_NDP_PMK_LEN];
+	bool pmk_set;
+	bool gtk_required;
+	u32 gtk_cipher;
+	u8 ipv6_intf_id[NL80211_NAN_NDP_IPV6_INTF_ID_LEN];
+	bool ipv6_intf_id_set;
+	bool ndpe;
+};
+
+/**
+ * struct cfg80211_nan_ndp_terminate - NAN NDP terminate parameters
+ *
+ * @peer_nmi: peer NMI address
+ * @ndp_id: NDP ID to terminate
+ * @init_ndi: initiator NDI MAC address
+ * @reason: termination reason code
+ */
+struct cfg80211_nan_ndp_terminate {
+	const u8 *peer_nmi;
+	u8 ndp_id;
+	const u8 *init_ndi;
+	u8 reason;
+};
+
+/**
+ * struct cfg80211_nan_ndp_request_params - NAN NDP request event parameters
+ *
+ * Sent to userspace when the driver receives a NDP Request frame.
+ *
+ * @peer_nmi: peer NMI address
+ * @ndp_id: NDP ID from the received frame
+ * @init_ndi: initiator NDI MAC from the received frame
+ * @publish_id: publisher's service instance ID
+ * @ssi: service-specific info (may be NULL)
+ * @ssi_len: length of @ssi
+ * @cipher_suite: initiator's cipher suite ID
+ * @pmkid: PMKID from the peer's SCIA (%NL80211_NAN_NDP_PMKID_LEN bytes,
+ *	valid when @pmkid_set is true)
+ * @pmkid_set: if true, @pmkid is valid
+ * @gtk_required: if true, initiator requires GTK protection
+ * @ipv6_intf_id: initiator's IPv6 link-local interface identifier
+ *	(%NL80211_NAN_NDP_IPV6_INTF_ID_LEN bytes,
+ *	valid when @ipv6_intf_id_set is true)
+ * @ipv6_intf_id_set: if true, @ipv6_intf_id is valid
+ * @ndpe: if true, use NDPE attribute instead of NDP attribute
+ */
+struct cfg80211_nan_ndp_request_params {
+	const u8 *peer_nmi;
+	u8 ndp_id;
+	const u8 *init_ndi;
+	u8 publish_id;
+	const u8 *ssi;
+	u8 ssi_len;
+	u32 cipher_suite;
+	u8 pmkid[NL80211_NAN_NDP_PMKID_LEN];
+	bool pmkid_set;
+	bool gtk_required;
+	u8 ipv6_intf_id[NL80211_NAN_NDP_IPV6_INTF_ID_LEN];
+	bool ipv6_intf_id_set;
+	bool ndpe;
+};
+
+/**
+ * struct cfg80211_nan_ndp_confirm_params - NAN NDP confirm event parameters
+ *
+ * Sent to userspace after the driver completes NDP setup.
+ *
+ * @peer_nmi: peer NMI address
+ * @ndp_id: NDP ID
+ * @init_ndi: initiator NDI MAC address
+ * @resp_ndi: responder NDI MAC address (valid when @accepted is true)
+ * @accepted: if true, NDP was accepted; if false, rejected
+ * @reason: rejection reason (valid when @accepted is false)
+ * @ssi: response service-specific info (may be NULL)
+ * @ssi_len: length of @ssi
+ * @ipv6_intf_id: peer's IPv6 link-local interface identifier
+ *	(%NL80211_NAN_NDP_IPV6_INTF_ID_LEN bytes,
+ *	valid when @ipv6_intf_id_set is true)
+ * @ipv6_intf_id_set: if true, @ipv6_intf_id is valid
+ */
+struct cfg80211_nan_ndp_confirm_params {
+	const u8 *peer_nmi;
+	u8 ndp_id;
+	const u8 *init_ndi;
+	const u8 *resp_ndi;
+	bool accepted;
+	u8 reason;
+	const u8 *ssi;
+	u8 ssi_len;
+	u8 ipv6_intf_id[NL80211_NAN_NDP_IPV6_INTF_ID_LEN];
+	bool ipv6_intf_id_set;
+};
+
+/**
+ * struct cfg80211_nan_ndp_terminated_params - NAN NDP terminated event
+ *
+ * @peer_nmi: peer NMI address
+ * @ndp_id: NDP ID
+ * @init_ndi: initiator NDI MAC address
+ * @reason: termination reason code
+ */
+struct cfg80211_nan_ndp_terminated_params {
+	const u8 *peer_nmi;
+	u8 ndp_id;
+	const u8 *init_ndi;
+	u8 reason;
+};
+
 /**
  * enum cfg80211_nan_conf_changes - indicates changed fields in NAN
  * configuration
@@ -4392,6 +4578,34 @@ struct cfg80211_nan_func_filter {
  * @num_tx_filters: length of &tx_filters.
  * @instance_id: driver allocated id of the function.
  * @cookie: unique NAN function identifier.
+ * @sdea_ctrl: SDEA control field bitmask as defined in Wi-Fi Aware
+ *	specification Table 9-297. Bit 2: Data Path Required. Bit 6:
+ *	Security Required. Bit 10: GTK Required. The Security Required and
+ *	GTK Required bits require %NL80211_EXT_FEATURE_SECURE_NAN.
+ * @pairing_bootstrap_methods: bitmap of supported NAN pairing
+ *	bootstrapping methods per the Wi-Fi Aware Specification Table 9-321.
+ * @csids: array of u32 NAN Cipher Suite ID (CSID) selectors supported by
+ *	this service. See the Wi-Fi Aware Specification for cipher suite values.
+ * @num_csids: number of entries in @csids.
+ * @nd_pmk: pre-shared NAN Data Path PMK (%NL80211_NAN_NDP_PMK_LEN bytes).
+ * @nd_pmk_set: if true, @nd_pmk contains a valid pre-shared ND-PMK.
+ * @pairing_setup: if true, this service supports NAN pairing setup.
+ * @pairing_cache: if true, this service supports NAN pairing caching.
+ * @pairing_verify: if true, this service supports NAN pairing
+ *	verification using a cached NPK.
+ * @ranging_interval: interval in milliseconds between two consecutive
+ *	ranging measurements, or 0 if not specified.
+ * @ingress_distance: inner geofence threshold in millimetres, or 0 if
+ *	not specified.
+ * @egress_distance: outer geofence threshold in millimetres, or 0 if
+ *	not specified.
+ * @ftms_per_burst: number of FTM frames per burst, or 0 if not specified.
+ * @preamble: PHY preamble for FTM frames, see &enum nl80211_preamble,
+ *	or %NL80211_PREAMBLE_LEGACY if not specified.
+ * @chandef_valid: if true, @chandef is valid.
+ * @chandef: channel definition for FTM ranging.
+ * @range_report: if true, a NAN Ranging Report is required after the FTM
+ *	session.
  */
 struct cfg80211_nan_func {
 	enum nl80211_nan_function_type type;
@@ -4418,6 +4632,23 @@ struct cfg80211_nan_func {
 	u8 num_rx_filters;
 	u8 instance_id;
 	u64 cookie;
+	u16 sdea_ctrl;
+	u16 pairing_bootstrap_methods;
+	u32 *csids;
+	u8 num_csids;
+	u8 nd_pmk[NL80211_NAN_NDP_PMK_LEN];
+	bool nd_pmk_set;
+	bool pairing_setup;
+	bool pairing_cache;
+	bool pairing_verify;
+	u32 ranging_interval;
+	u32 ingress_distance;
+	u32 egress_distance;
+	u8 ftms_per_burst;
+	enum nl80211_preamble preamble;
+	bool chandef_valid;
+	struct cfg80211_chan_def chandef;
+	bool range_report;
 };
 
 /**
@@ -4702,6 +4933,8 @@ struct cfg80211_pmsr_result {
  *		 @trigger_based or @non_trigger_based is set.
  * @rsta: Operate as the RSTA in the measurement. Only valid if @lmr_feedback
  *	and either @trigger_based or @non_trigger_based is set.
+ *	Also valid when @range_report is set and @request_type is
+ *	%NL80211_PMSR_FTM_REQ_TYPE_NAN.
  * @bss_color: the bss color of the responder. Optional. Set to zero to
  *	indicate the driver should set the BSS color. Only valid if
  *	@non_trigger_based or @trigger_based is set.
@@ -4747,6 +4980,10 @@ struct cfg80211_pmsr_result {
  *	provide ranging services to a peer (e.g. in RSTA role) but does
  *	not report the measurement results to userspace. Only valid when
  *	@request_type is %NL80211_PMSR_FTM_REQ_TYPE_PD.
+ * @range_report: a NAN Ranging Report is required after the FTM session.
+ *	Only valid for a NAN RSTA request.
+ * @min_delta_ftm: NAN Min Delta FTM value in units of 100 microseconds.
+ *	Zero indicates no preference.
  *
  * See also nl80211 for the respective attribute documentation.
  */
@@ -4763,6 +5000,7 @@ struct cfg80211_pmsr_ftm_request_peer {
 	   rsta:1;
 	u8 num_bursts_exp;
 	u8 burst_duration;
+	u8 min_delta_ftm;
 	u8 ftms_per_burst;
 	u8 ftmr_retries;
 	u8 bss_color;
@@ -4775,7 +5013,8 @@ struct cfg80211_pmsr_ftm_request_peer {
 	u32 num_measurements;
 	u64 ingress_distance;
 	u64 egress_distance;
-	u8 pd_suppress_range_results:1;
+	u8 pd_suppress_range_results:1,
+	   range_report:1;
 };
 
 /**
@@ -5259,6 +5498,13 @@ struct mgmt_frame_regs {
  *	not included become evacuable again. All provided channels are
  *	guaranteed by cfg80211 to belong to the current local schedule.
  *
+ * @nan_ndp_initiate: Initiate a NAN Data Path session as the initiator.
+ *	Only valid if the driver has set %WIPHY_NAN_FLAGS_OFFLOAD_NDP.
+ * @nan_ndp_respond: Respond to an incoming NDP request as the responder.
+ *	Only valid if the driver has set %WIPHY_NAN_FLAGS_OFFLOAD_NDP.
+ * @nan_ndp_terminate: Terminate an established NDP session.
+ *	Only valid if the driver has set %WIPHY_NAN_FLAGS_OFFLOAD_NDP.
+ *
  * @set_multicast_to_unicast: configure multicast to unicast conversion for BSS
  *
  * @get_txq_stats: Get TXQ stats for interface or phy. If wdev is %NULL, this
@@ -5666,6 +5912,15 @@ struct cfg80211_ops {
 	int	(*nan_set_non_evac_channels)(struct wiphy *wiphy,
 					     struct wireless_dev *wdev,
 					     struct cfg80211_nan_non_evac_channels *channels);
+	int     (*nan_ndp_initiate)(struct wiphy *wiphy,
+				    struct wireless_dev *wdev,
+				    struct cfg80211_nan_ndp_initiate *params);
+	int	(*nan_ndp_respond)(struct wiphy *wiphy,
+				   struct wireless_dev *wdev,
+				   struct cfg80211_nan_ndp_respond *params);
+	int	(*nan_ndp_terminate)(struct wiphy *wiphy,
+				     struct wireless_dev *wdev,
+				     struct cfg80211_nan_ndp_terminate *params);
 	int	(*set_multicast_to_unicast)(struct wiphy *wiphy,
 					    struct net_device *dev,
 					    const bool enabled);
@@ -6215,6 +6470,8 @@ cfg80211_get_iftype_ext_capa(struct wiphy *wiphy, enum nl80211_iftype type);
  * @ftm.type.pd_support: supports peer-to-peer ranging as mentioned in the
  *	specification "PR Implementation Consideration Draft 1.9 rev 1" where
  *	PD stands for proximity detection
+ * @ftm.type.nan_support: supports NAN ranging as defined in
+ *	the "Wi-Fi Aware Specification v4.0, clause 8".
  * @ftm.concurrent_ista_rsta_support: indicates if the device can
  *	simultaneously act as initiator and responder in a multi-peer
  *	measurement request. Only valid if @ftm.rsta_support is set.
@@ -6265,7 +6522,8 @@ struct cfg80211_pmsr_capabilities {
 		u32 min_allowed_ranging_interval_ntb;
 		struct {
 			u8 infra_support:1,
-			   pd_support:1;
+			   pd_support:1,
+			   nan_support:1;
 		} type;
 		u8 concurrent_ista_rsta_support:1;
 		u32 pd_preambles;
@@ -6348,11 +6606,18 @@ struct wiphy_radio {
  * @WIPHY_NAN_FLAGS_USERSPACE_DE: Device doesn't support DE offload.
  * @WIPHY_NAN_FLAGS_INSTANT_COMM: Device can switch to Instant Communication
  *     (IC) mode. Can only be set along with %WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC.
+ * @WIPHY_NAN_FLAGS_OFFLOAD_NDP: Driver handles NAN Data Path (NDP) handshake
+ *	frames and data path key installation autonomously.
+ * @WIPHY_NAN_FLAGS_OFFLOAD_RANGING: Firmware supports fully offloaded NAN
+ *	ranging procedure, including ranging session setup, update, and
+ *	termination, FTM protocol and procedure, and ranging report.
  */
 enum wiphy_nan_flags {
 	WIPHY_NAN_FLAGS_CONFIGURABLE_SYNC = BIT(0),
 	WIPHY_NAN_FLAGS_USERSPACE_DE   = BIT(1),
 	WIPHY_NAN_FLAGS_INSTANT_COMM = BIT(2),
+	WIPHY_NAN_FLAGS_OFFLOAD_NDP = BIT(3),
+	WIPHY_NAN_FLAGS_OFFLOAD_RANGING = BIT(4),
 };
 
 /**
@@ -10554,7 +10819,26 @@ void cfg80211_free_nan_func(struct cfg80211_nan_func *f);
  * @addr: the MAC address of the peer
  * @info_len: the length of the &info
  * @info: the Service Specific Info from the peer (if any)
+ * @extra_info_len: the length of @extra_info (Extended SSI)
+ * @extra_info: Extended Service Specific Info from the peer (if any)
+ * @ies_len: the length of @ies
+ * @ies: additional elements from the peer's Service Descriptor frame (if any)
+ * @sdea_ctrl: SDEA control field from the peer's SDEA attribute. Bit 2
+ *	indicates Data Path Required, bit 6 Security Required.
+ * @pairing_bootstrap_methods: bitmap of the peer's supported NAN pairing
+ *	bootstrapping methods.
+ * @csids: array of NAN cipher suite IDs advertised by the peer.
+ *	NULL if not present.
+ * @num_csids: number of entries in @csids.
+ * @pairing_setup: if true, the peer supports NAN pairing setup.
+ * @pairing_cache: if true, the peer supports NAN pairing NPK/NIK caching.
+ * @pairing_verify: if true, the peer supports NAN pairing re-verification.
+ * @rssi: received signal strength in dBm at the time of the match.
+ *	Only valid when @rssi_valid is true.
+ * @rssi_valid: if true, @rssi contains a valid RSSI measurement.
  * @cookie: unique identifier of the corresponding function
+ * @ranging_indication: bitmap indicating the type of ranging performed.
+ * @ranging_measurement: distance to the peer in millimetres.
  */
 struct cfg80211_nan_match_params {
 	enum nl80211_nan_function_type type;
@@ -10563,7 +10847,22 @@ struct cfg80211_nan_match_params {
 	const u8 *addr;
 	u8 info_len;
 	const u8 *info;
+	u8 extra_info_len;
+	const u8 *extra_info;
+	u16 ies_len;
+	const u8 *ies;
+	u16 sdea_ctrl;
+	u16 pairing_bootstrap_methods;
+	const u32 *csids;
+	u8 num_csids;
+	bool pairing_setup;
+	bool pairing_cache;
+	bool pairing_verify;
+	s32 rssi;
+	bool rssi_valid;
 	u64 cookie;
+	u8 ranging_indication;
+	s32 ranging_measurement;
 };
 
 /**
@@ -11099,6 +11398,46 @@ cfg80211_s1g_get_primary_sibling(struct wiphy *wiphy,
 }
 
 
+/**
+ * cfg80211_nan_ndp_request - notify userspace of a received NDP request
+ * @wdev: the wireless device reporting the event
+ * @params: NDP request parameters parsed from the received frame
+ * @gfp: allocation flags
+ *
+ * Notify userspace that a NAN Data Path request was received from a peer.
+ * Only valid when %WIPHY_NAN_FLAGS_OFFLOAD_NDP is set.
+ */
+void cfg80211_nan_ndp_request(struct wireless_dev *wdev,
+			      struct cfg80211_nan_ndp_request_params *params,
+			      gfp_t gfp);
+
+/**
+ * cfg80211_nan_ndp_confirm - notify userspace that NDP setup is complete
+ * @wdev: the wireless device reporting the event
+ * @params: NDP confirm parameters
+ * @gfp: allocation flags
+ *
+ * Notify userspace that NAN Data Path setup is complete. Includes the
+ * accept/reject status and, if accepted, the responder NDI. Only valid
+ * when %WIPHY_NAN_FLAGS_OFFLOAD_NDP is set.
+ */
+void cfg80211_nan_ndp_confirm(struct wireless_dev *wdev,
+			      struct cfg80211_nan_ndp_confirm_params *params,
+			      gfp_t gfp);
+
+/**
+ * cfg80211_nan_ndp_terminated - notify userspace that an NDP was terminated
+ * @wdev: the wireless device reporting the event
+ * @params: NDP termination parameters
+ * @gfp: allocation flags
+ *
+ * Notify userspace that a NAN Data Path was torn down. Only valid
+ * when %WIPHY_NAN_FLAGS_OFFLOAD_NDP is set.
+ */
+void cfg80211_nan_ndp_terminated(struct wireless_dev *wdev,
+				 struct cfg80211_nan_ndp_terminated_params *params,
+				 gfp_t gfp);
+
 /**
  * cfg80211_incumbent_signal_notify - Notify userspace of incumbent signal detection
  * @wiphy: the wiphy to use
diff --git a/include/uapi/linux/nl80211.h b/include/uapi/linux/nl80211.h
index b56a96f57bec2..71ed38992d334 100644
--- a/include/uapi/linux/nl80211.h
+++ b/include/uapi/linux/nl80211.h
@@ -1468,6 +1468,36 @@
  *	and multiple can be nested in %NL80211_ATTR_MLO_LINKS but then the
  *	update isn't atomic if any failures happen.
  *	Only supported with %NL80211_EXT_FEATURE_UPDATE_BEACON.
+ *
+ * @NL80211_CMD_NAN_NDP_INITIATE: Initiate NAN Data Path (NDP) setup
+ *	as the initiator. Requires %WIPHY_NAN_FLAGS_OFFLOAD_NDP. The NDI
+ *	interface specified in %NL80211_NAN_NDP_ATTR_INIT_NDI must already
+ *	exist as a %NL80211_IFTYPE_NAN_DATA interface. Carries
+ *	%NL80211_ATTR_NAN_NDP nested with %NL80211_NAN_NDP_ATTR_* fields.
+ * @NL80211_CMD_NAN_NDP_RESPOND: Respond to a received NDP request as
+ *	the responder. Requires %WIPHY_NAN_FLAGS_OFFLOAD_NDP. The NDI
+ *	interface specified in %NL80211_NAN_NDP_ATTR_RESP_NDI must already
+ *	exist as a %NL80211_IFTYPE_NAN_DATA interface. Carries
+ *	%NL80211_ATTR_NAN_NDP nested with %NL80211_NAN_NDP_ATTR_* fields.
+ * @NL80211_CMD_NAN_NDP_TERMINATE: Terminate an established NDP.
+ *	Requires %WIPHY_NAN_FLAGS_OFFLOAD_NDP. Carries %NL80211_ATTR_NAN_NDP
+ *	nested with %NL80211_NAN_NDP_ATTR_ID, %NL80211_NAN_NDP_ATTR_INIT_NDI
+ *	and optionally %NL80211_NAN_NDP_ATTR_REASON.
+ * @NL80211_CMD_NAN_NDP_REQUEST: Notification sent to userspace when
+ *	the driver receives a NDP Request frame from a peer. Carries
+ *	%NL80211_ATTR_MAC (peer NMI) and %NL80211_ATTR_NAN_NDP nested with
+ *	all parsed NDP request parameters. Userspace must ensure the NDI
+ *	interface is ready before calling %NL80211_CMD_NAN_NDP_RESPOND.
+ * @NL80211_CMD_NAN_NDP_CONFIRM: Notification sent to userspace after
+ *	the driver completes NDP setup and installs data path keys. Carries
+ *	%NL80211_ATTR_MAC (peer NMI) and %NL80211_ATTR_NAN_NDP nested with
+ *	the NDP confirm parameters including %NL80211_NAN_NDP_ATTR_RESP_NDI.
+ *	Userspace should call %NL80211_CMD_NEW_STATION on the NDI interface
+ *	to add the peer NDI station.
+ * @NL80211_CMD_NAN_NDP_TERMINATED: Notification sent to userspace
+ *	when an NDP is terminated. Carries %NL80211_ATTR_MAC (peer NMI)
+ *	and %NL80211_ATTR_NAN_NDP nested with the termination parameters.
+ *
  * @NL80211_CMD_MAX: highest used command number
  * @__NL80211_CMD_AFTER_LAST: internal use
  */
@@ -1750,6 +1780,13 @@ enum nl80211_commands {
 
 	NL80211_CMD_UPDATE_BEACON,
 
+	NL80211_CMD_NAN_NDP_INITIATE,
+	NL80211_CMD_NAN_NDP_RESPOND,
+	NL80211_CMD_NAN_NDP_TERMINATE,
+	NL80211_CMD_NAN_NDP_REQUEST,
+	NL80211_CMD_NAN_NDP_CONFIRM,
+	NL80211_CMD_NAN_NDP_TERMINATED,
+
 	/* add new commands above here */
 
 	/* used to define NL80211_CMD_MAX below */
@@ -3243,6 +3280,9 @@ enum nl80211_commands {
  * @NL80211_ATTR_ASSOC_PROTECTED_TWT: Enable protected TWT for the association,
  *	requires protected TWT support (flag attribute)
  *
+ * @NL80211_ATTR_NAN_NDP: nested attribute carrying NAN Data Path parameters.
+ *	See &enum nl80211_nan_ndp_attributes.
+ *
  * @NUM_NL80211_ATTR: total number of nl80211_attrs available
  * @NL80211_ATTR_MAX: highest attribute number currently defined
  * @__NL80211_ATTR_AFTER_LAST: internal use
@@ -3850,6 +3890,8 @@ enum nl80211_attrs {
 
 	NL80211_ATTR_ASSOC_PROTECTED_TWT,
 
+	NL80211_ATTR_NAN_NDP,
+
 	/* add attributes here, update the policy in nl80211.c */
 
 	__NL80211_ATTR_AFTER_LAST,
@@ -7715,6 +7757,8 @@ enum nl80211_nan_func_term_reason {
 #define NL80211_NAN_FUNC_SERVICE_SPEC_INFO_MAX_LEN 0xff
 #define NL80211_NAN_FUNC_SRF_MAX_LEN 0xff
 
+#define NL80211_NAN_NDP_PMK_LEN 32
+
 /**
  * enum nl80211_nan_func_attributes - NAN function attributes
  * @__NL80211_NAN_FUNC_INVALID: invalid
@@ -7753,6 +7797,40 @@ enum nl80211_nan_func_term_reason {
  *	Its type is u8 and it cannot be 0.
  * @NL80211_NAN_FUNC_TERM_REASON: NAN function termination reason.
  *	See &enum nl80211_nan_func_term_reason.
+ * @NL80211_NAN_FUNC_SDEA_CTRL: u16 Service Descriptor Extension Attribute
+ *	(SDEA) control field bitmask as defined in the Wi-Fi Aware Specification
+ *	Table 9-297. See &enum nl80211_nan_func_sdea_ctrl_flags for the
+ *	relevant bit definitions. The Security Required and GTK Required bits
+ *	require %NL80211_EXT_FEATURE_SECURE_NAN.
+ * @NL80211_NAN_FUNC_PAIRING_BOOTSTRAP_METHODS: u16 bitmap of supported
+ *	NAN pairing bootstrapping methods as defined in Wi-Fi Aware
+ *	specification Table 9-321. Each bit corresponds to one method.
+ * @NL80211_NAN_FUNC_CSIDS: a set of u32 NAN Cipher Suite ID (CSID)
+ *	selectors supported by this service. Requires
+ *	%NL80211_EXT_FEATURE_SECURE_NAN.
+ * @NL80211_NAN_FUNC_PAIRING_SETUP: flag attribute. This service supports
+ *	NAN pairing setup (new pairing).
+ * @NL80211_NAN_FUNC_PAIRING_CACHE: flag attribute. This service supports
+ *	NAN pairing caching (NPK caching).
+ * @NL80211_NAN_FUNC_PAIRING_VERIFY: flag attribute. This service supports
+ *	NAN pairing verification using a cached NPK.
+ * @NL80211_NAN_FUNC_ND_PMK: %NL80211_NAN_NDP_PMK_LEN-byte pre-shared NAN
+ *	Data Path PMK (ND-PMK).
+ *	Requires %NL80211_EXT_FEATURE_SECURE_NAN.
+ * @NL80211_NAN_FUNC_RANGING_INTERVAL: u32 attribute. Interval in
+ *	milliseconds between two consecutive ranging measurements.
+ * @NL80211_NAN_FUNC_INGRESS_DISTANCE: u32 attribute. Inner geofence
+ *	threshold in millimetres.
+ * @NL80211_NAN_FUNC_EGRESS_DISTANCE: u32 attribute. Outer geofence
+ *	threshold in millimetres.
+ * @NL80211_NAN_FUNC_FTMS_PER_BURST: u8 attribute. Number of FTM
+ *	frames per burst.
+ * @NL80211_NAN_FUNC_PREAMBLE: u32 attribute. PHY preamble type for
+ *	FTM frames (see &enum nl80211_preamble).
+ * @NL80211_NAN_FUNC_CHAN: channel definition for FTM ranging, nested,
+ *	using top-level attributes like %NL80211_ATTR_WIPHY_FREQ etc.
+ * @NL80211_NAN_FUNC_RANGE_REPORT: flag indicating that a NAN Ranging
+ *	Report is required after the FTM session.
  *
  * @NUM_NL80211_NAN_FUNC_ATTR: internal
  * @NL80211_NAN_FUNC_ATTR_MAX: highest NAN function attribute
@@ -7775,12 +7853,45 @@ enum nl80211_nan_func_attributes {
 	NL80211_NAN_FUNC_TX_MATCH_FILTER,
 	NL80211_NAN_FUNC_INSTANCE_ID,
 	NL80211_NAN_FUNC_TERM_REASON,
+	NL80211_NAN_FUNC_SDEA_CTRL,
+	NL80211_NAN_FUNC_PAIRING_BOOTSTRAP_METHODS,
+	NL80211_NAN_FUNC_CSIDS,
+	NL80211_NAN_FUNC_PAIRING_SETUP,
+	NL80211_NAN_FUNC_PAIRING_CACHE,
+	NL80211_NAN_FUNC_PAIRING_VERIFY,
+	NL80211_NAN_FUNC_ND_PMK,
+	NL80211_NAN_FUNC_RANGING_INTERVAL,
+	NL80211_NAN_FUNC_INGRESS_DISTANCE,
+	NL80211_NAN_FUNC_EGRESS_DISTANCE,
+	NL80211_NAN_FUNC_FTMS_PER_BURST,
+	NL80211_NAN_FUNC_PREAMBLE,
+	NL80211_NAN_FUNC_CHAN,
+	NL80211_NAN_FUNC_RANGE_REPORT,
 
 	/* keep last */
 	NUM_NL80211_NAN_FUNC_ATTR,
 	NL80211_NAN_FUNC_ATTR_MAX = NUM_NL80211_NAN_FUNC_ATTR - 1
 };
 
+/**
+ * enum nl80211_nan_func_sdea_ctrl_flags - NAN SDEA control field bit flags
+ *
+ * Bit definitions for the u16 SDEA control field carried in
+ * %NL80211_NAN_FUNC_SDEA_CTRL, as specified in the Wi-Fi Aware
+ * Specification Table 9-297.
+ *
+ * @NL80211_NAN_FUNC_SDEA_CTRL_DATAPATH_REQUIRED: bit 2 - Data Path Required.
+ * @NL80211_NAN_FUNC_SDEA_CTRL_SECURITY_REQUIRED: bit 6 - Security Required.
+ * @NL80211_NAN_FUNC_SDEA_CTRL_RANGING_REQUIRED: bit 7 - Ranging Required.
+ * @NL80211_NAN_FUNC_SDEA_CTRL_GTK_REQUIRED: bit 10 - GTK Required.
+ */
+enum nl80211_nan_func_sdea_ctrl_flags {
+	NL80211_NAN_FUNC_SDEA_CTRL_DATAPATH_REQUIRED	= 1 << 2,
+	NL80211_NAN_FUNC_SDEA_CTRL_SECURITY_REQUIRED	= 1 << 6,
+	NL80211_NAN_FUNC_SDEA_CTRL_RANGING_REQUIRED	= 1 << 7,
+	NL80211_NAN_FUNC_SDEA_CTRL_GTK_REQUIRED		= 1 << 10,
+};
+
 /**
  * enum nl80211_nan_srf_attributes - NAN Service Response filter attributes
  * @__NL80211_NAN_SRF_INVALID: invalid
@@ -7817,6 +7928,34 @@ enum nl80211_nan_srf_attributes {
  * @NL80211_NAN_MATCH_FUNC_PEER: the peer function
  *	that caused the match. This is a nested attribute.
  *	See &enum nl80211_nan_func_attributes.
+ * @NL80211_NAN_MATCH_SDEA_CTRL: u16 SDEA control field from the peer's
+ *	Service Descriptor Extension Attribute. Bit 2 indicates Data Path
+ *	Required, bit 6 Security Required, bit 7 Ranging Required, bit 10
+ *	GTK Required.
+ * @NL80211_NAN_MATCH_BOOTSTRAP_METHODS: u16 bitmap of the peer's
+ *	supported NAN pairing bootstrapping methods per the Wi-Fi Aware
+ *	Specification Table 9-321.
+ * @NL80211_NAN_MATCH_CIPHER_SUITES: a set of u32 values indicating the NAN
+ *	cipher suite selectors advertised by the peer.
+ * @NL80211_NAN_MATCH_PAIRING_SETUP: flag attribute. Set if the peer
+ *	supports NAN pairing setup.
+ * @NL80211_NAN_MATCH_PAIRING_CACHE: flag attribute. Set if the peer
+ *	supports NAN pairing NPK/NIK caching.
+ * @NL80211_NAN_MATCH_PAIRING_VERIFY: flag attribute. Set if the peer
+ *	supports NAN pairing re-verification.
+ * @NL80211_NAN_MATCH_EXTRA_INFO: binary attribute carrying the peer's
+ *	Extended Service Specific Info (Extended SSI), if present.
+ * @NL80211_NAN_MATCH_IES: binary attribute carrying additional elements from
+ *	the peer's Service Descriptor frame, if present.
+ * @NL80211_NAN_MATCH_RSSI: s32 attribute. Received signal strength in dBm
+ *	at the time of the match. Only present when the driver provides a
+ *	valid RSSI measurement.
+ * @NL80211_NAN_MATCH_RANGING_INDICATION: u8 attribute. Bitmap indicating
+ *	the type of ranging performed: bit 0: continuous ranging,
+ *	bit 1: ingress condition met, bit 2: egress condition met,
+ *	bit 1 and bit 2: both conditions met. Only present when non-zero.
+ * @NL80211_NAN_MATCH_RANGING_MEASUREMENT: s32 attribute. Distance to
+ *	the peer in millimetres measured via FTM.
  *
  * @NUM_NL80211_NAN_MATCH_ATTR: internal
  * @NL80211_NAN_MATCH_ATTR_MAX: highest NAN match attribute
@@ -7825,6 +7964,17 @@ enum nl80211_nan_match_attributes {
 	__NL80211_NAN_MATCH_INVALID,
 	NL80211_NAN_MATCH_FUNC_LOCAL,
 	NL80211_NAN_MATCH_FUNC_PEER,
+	NL80211_NAN_MATCH_SDEA_CTRL,
+	NL80211_NAN_MATCH_BOOTSTRAP_METHODS,
+	NL80211_NAN_MATCH_CIPHER_SUITES,
+	NL80211_NAN_MATCH_PAIRING_SETUP,
+	NL80211_NAN_MATCH_PAIRING_CACHE,
+	NL80211_NAN_MATCH_PAIRING_VERIFY,
+	NL80211_NAN_MATCH_EXTRA_INFO,
+	NL80211_NAN_MATCH_IES,
+	NL80211_NAN_MATCH_RSSI,
+	NL80211_NAN_MATCH_RANGING_INDICATION,
+	NL80211_NAN_MATCH_RANGING_MEASUREMENT,
 
 	/* keep last */
 	NUM_NL80211_NAN_MATCH_ATTR,
@@ -7938,6 +8088,100 @@ enum nl80211_nan_conf_attributes {
 	NL80211_NAN_CONF_ATTR_MAX = NUM_NL80211_NAN_CONF_ATTR - 1,
 };
 
+#define NL80211_NAN_NDP_PMKID_LEN		16
+#define NL80211_NAN_NDP_IPV6_INTF_ID_LEN	8
+
+/**
+ * enum nl80211_nan_ndp_attributes - NAN Data Path attributes
+ *
+ * Nested attributes used within %NL80211_ATTR_NAN_NDP for NDP setup
+ * commands and events.
+ *
+ * @__NL80211_NAN_NDP_ATTR_INVALID: Invalid.
+ * @NL80211_NAN_NDP_ATTR_ID: (u8) NDP ID (1-255). Allocated by the
+ *	initiator and echoed in all subsequent NDP messages.
+ * @NL80211_NAN_NDP_ATTR_PUBLISH_ID: (u8) Publisher's service instance
+ *	ID. Present in %NL80211_CMD_NAN_NDP_INITIATE and
+ *	%NL80211_CMD_NAN_NDP_REQUEST. Used to match the NDP to a service.
+ * @NL80211_NAN_NDP_ATTR_SERVICE_ID: binary (%NL80211_NAN_FUNC_SERVICE_ID_LEN
+ *	bytes). NAN service ID derived from the service name.
+ * @NL80211_NAN_NDP_ATTR_INIT_NDI: (%ETH_ALEN bytes) Initiator NDI MAC
+ *	address. The corresponding %NL80211_IFTYPE_NAN_DATA interface must
+ *	exist.
+ * @NL80211_NAN_NDP_ATTR_RESP_NDI: (%ETH_ALEN bytes) Responder NDI MAC
+ *	address. Present in %NL80211_CMD_NAN_NDP_RESPOND (if accepting) and
+ *	%NL80211_CMD_NAN_NDP_CONFIRM. The corresponding
+ *	%NL80211_IFTYPE_NAN_DATA interface must exist.
+ * @NL80211_NAN_NDP_ATTR_SSI: binary. Service-specific info carried in
+ *	the NDP setup frames.
+ * @NL80211_NAN_NDP_ATTR_CIPHER_SUITE: (u32) NAN cipher suite ID. 0 for
+ *	open (no security). See the Wi-Fi Aware Specification for values.
+ * @NL80211_NAN_NDP_ATTR_PMK: binary (%NL80211_NAN_NDP_PMK_LEN bytes).
+ *	NAN Data Path PMK.
+ *	The driver uses this to compute the PMKID and derive the PTK.
+ *	Requires %NL80211_EXT_FEATURE_SECURE_NAN.
+ * @NL80211_NAN_NDP_ATTR_PMKID: binary (%NL80211_NAN_NDP_PMKID_LEN bytes).
+ *	PMKID from the peer's
+ *	SCIA attribute. Present in %NL80211_CMD_NAN_NDP_REQUEST to allow
+ *	userspace to look up a cached PMK.
+ * @NL80211_NAN_NDP_ATTR_GTK_REQUIRED: flag. GTK/IGTK/BIGTK protection
+ *	required for group-addressed NDP frames.
+ * @NL80211_NAN_NDP_ATTR_GTK_CIPHER: (u32) GTK cipher suite ID. Required
+ *	if %NL80211_NAN_NDP_ATTR_GTK_REQUIRED is set.
+ * @NL80211_NAN_NDP_ATTR_IPV6_INTF_ID: binary (%NL80211_NAN_NDP_IPV6_INTF_ID_LEN
+ *	bytes). IPv6 link-local
+ *	interface identifier. Included as NDPE TLV type 0 when present.
+ * @NL80211_NAN_NDP_ATTR_NDPE: flag. Use NDPE attribute instead of NDP
+ *	attribute when peer supports NDPE.
+ * @NL80211_NAN_NDP_ATTR_ACCEPT: flag. If present in
+ *	%NL80211_CMD_NAN_NDP_RESPOND, the NDP is accepted. If absent, it is
+ *	rejected.
+ * @NL80211_NAN_NDP_ATTR_REASON: (u8) Termination or rejection reason
+ *	code (enum nan_reason from the Wi-Fi Aware Specification).
+ * @NL80211_NAN_NDP_ATTR_STATUS: (u8) NDP status in
+ *	%NL80211_CMD_NAN_NDP_CONFIRM, see &enum nl80211_nan_ndp_status.
+ * @__NL80211_NAN_NDP_ATTR_LAST: Internal.
+ * @NL80211_NAN_NDP_ATTR_MAX: Highest NDP attribute.
+ */
+enum nl80211_nan_ndp_attributes {
+	__NL80211_NAN_NDP_ATTR_INVALID,
+
+	NL80211_NAN_NDP_ATTR_ID,
+	NL80211_NAN_NDP_ATTR_PUBLISH_ID,
+	NL80211_NAN_NDP_ATTR_SERVICE_ID,
+	NL80211_NAN_NDP_ATTR_INIT_NDI,
+	NL80211_NAN_NDP_ATTR_RESP_NDI,
+	NL80211_NAN_NDP_ATTR_SSI,
+	NL80211_NAN_NDP_ATTR_CIPHER_SUITE,
+	NL80211_NAN_NDP_ATTR_PMK,
+	NL80211_NAN_NDP_ATTR_PMKID,
+	NL80211_NAN_NDP_ATTR_GTK_REQUIRED,
+	NL80211_NAN_NDP_ATTR_GTK_CIPHER,
+	NL80211_NAN_NDP_ATTR_IPV6_INTF_ID,
+	NL80211_NAN_NDP_ATTR_NDPE,
+	NL80211_NAN_NDP_ATTR_ACCEPT,
+	NL80211_NAN_NDP_ATTR_REASON,
+	NL80211_NAN_NDP_ATTR_STATUS,
+
+	/* keep last */
+	__NL80211_NAN_NDP_ATTR_LAST,
+	NL80211_NAN_NDP_ATTR_MAX = __NL80211_NAN_NDP_ATTR_LAST - 1,
+};
+
+/**
+ * enum nl80211_nan_ndp_status - NAN Data Path setup status
+ *
+ * Values for %NL80211_NAN_NDP_ATTR_STATUS reported in
+ * %NL80211_CMD_NAN_NDP_CONFIRM.
+ *
+ * @NL80211_NAN_NDP_STATUS_ACCEPTED: NDP setup was accepted by the peer.
+ * @NL80211_NAN_NDP_STATUS_REJECTED: NDP setup was rejected by the peer.
+ */
+enum nl80211_nan_ndp_status {
+	NL80211_NAN_NDP_STATUS_ACCEPTED,
+	NL80211_NAN_NDP_STATUS_REJECTED,
+};
+
 /**
  * enum nl80211_external_auth_action - Action to perform with external
  *     authentication request. Used by NL80211_ATTR_EXTERNAL_AUTH_ACTION.
@@ -8143,12 +8387,16 @@ enum nl80211_peer_measurement_resp {
  * @NL80211_PMSR_FTM_REQ_TYPE_PD: peer-to-peer ranging as defined in the
  *	Wi-Fi Alliance specification "Proximity Ranging (PR) Implementation
  *	Consideration Draft 1.9 Rev 1"
+ * @NL80211_PMSR_FTM_REQ_TYPE_NAN: NAN ranging between two NAN devices as
+ *	defined in the "Wi-Fi Aware Specification v4.0, clause 8".
+ *	Must be issued on a %NL80211_IFTYPE_NAN interface.
  * @NUM_NL80211_PMSR_FTM_REQ_TYPE: internal
  * @NL80211_PMSR_FTM_REQ_TYPE_MAX: highest request type value
  */
 enum nl80211_peer_measurement_ftm_req_type {
 	NL80211_PMSR_FTM_REQ_TYPE_INFRA,
 	NL80211_PMSR_FTM_REQ_TYPE_PD,
+	NL80211_PMSR_FTM_REQ_TYPE_NAN,
 
 	/* keep last */
 	NUM_NL80211_PMSR_FTM_REQ_TYPE,
@@ -8397,6 +8645,9 @@ enum nl80211_peer_measurement_ftm_capa {
  *	the device supports peer-to-peer ranging as mentioned in the
  *	specification "PR Implementation Consideration Draft 1.9 rev 1" where
  *	PD stands for proximity detection
+ * @NL80211_PMSR_FTM_TYPE_CAPA_ATTR_NAN_SUPPORT: flag attribute indicating
+ *	that the device supports NAN ranging between two NAN devices as
+ *	defined in the "Wi-Fi Aware Specification v4.0, clause 8".
  *
  * @NUM_NL80211_PMSR_FTM_TYPE_CAPA_ATTR: internal
  * @NL80211_PMSR_FTM_TYPE_CAPA_ATTR_MAX: highest attribute number
@@ -8406,6 +8657,7 @@ enum nl80211_peer_measurement_ftm_type_capa {
 
 	NL80211_PMSR_FTM_TYPE_CAPA_ATTR_INFRA_SUPPORT,
 	NL80211_PMSR_FTM_TYPE_CAPA_ATTR_PD_SUPPORT,
+	NL80211_PMSR_FTM_TYPE_CAPA_ATTR_NAN_SUPPORT,
 
 	/* keep last */
 	NUM_NL80211_PMSR_FTM_TYPE_CAPA_ATTR,
@@ -8512,6 +8764,11 @@ enum nl80211_peer_measurement_ftm_type_capa {
  *	but results are not reported to userspace, regardless of ranging role
  *	or type. Only valid when %NL80211_PMSR_PEER_ATTR_REQ_TYPE is set to
  *	%NL80211_PMSR_FTM_REQ_TYPE_PD.
+ * @NL80211_PMSR_FTM_REQ_ATTR_RANGE_REPORT: Flag indicating that a NAN
+ *	Ranging Report is required after the FTM session. Only valid for a NAN
+ *	RSTA request.
+ * @NL80211_PMSR_FTM_REQ_ATTR_MIN_DELTA_FTM: NAN Min Delta FTM value in units
+ *	of 100 microseconds (u8, 0-63). A value of 0 indicates no preference.
  *
  * @NUM_NL80211_PMSR_FTM_REQ_ATTR: internal
  * @NL80211_PMSR_FTM_REQ_ATTR_MAX: highest attribute number
@@ -8542,6 +8799,8 @@ enum nl80211_peer_measurement_ftm_req {
 	NL80211_PMSR_FTM_REQ_ATTR_INGRESS,
 	NL80211_PMSR_FTM_REQ_ATTR_EGRESS,
 	NL80211_PMSR_FTM_REQ_ATTR_PD_SUPPRESS_RESULTS,
+	NL80211_PMSR_FTM_REQ_ATTR_RANGE_REPORT,
+	NL80211_PMSR_FTM_REQ_ATTR_MIN_DELTA_FTM,
 
 	/* keep last */
 	NUM_NL80211_PMSR_FTM_REQ_ATTR,
@@ -9153,6 +9412,12 @@ enum nl80211_s1g_short_beacon_attrs {
  *	of the Wi-Fi Aware Specification v4.0. Can only be set if
  *	%NL80211_NAN_CAPA_CONFIGURABLE_SYNC is set. When IC is enabled, the IC
  *	schedule is expected to be configured by user space.
+ * @NL80211_NAN_CAPA_OFFLOAD_RANGING: flag attribute. Firmware supports the
+ *	fully offloaded NAN ranging procedure, including ranging session setup,
+ *	update, and termination, FTM protocol and procedure, and ranging reports.
+ * @NL80211_NAN_CAPA_OFFLOAD_NDP: flag attribute. Driver handles NAN Data
+ *	Path (NDP) handshake frames and data path key installation.
+
  * @__NL80211_NAN_CAPABILITIES_LAST: Internal
  * @NL80211_NAN_CAPABILITIES_MAX: Highest NAN capability attribute.
  */
@@ -9167,6 +9432,8 @@ enum nl80211_nan_capabilities {
 	NL80211_NAN_CAPA_CAPABILITIES,
 	NL80211_NAN_CAPA_PHY,
 	NL80211_NAN_CAPA_INSTANT_COMM,
+	NL80211_NAN_CAPA_OFFLOAD_RANGING,
+	NL80211_NAN_CAPA_OFFLOAD_NDP,
 	/* keep last */
 	__NL80211_NAN_CAPABILITIES_LAST,
 	NL80211_NAN_CAPABILITIES_MAX = __NL80211_NAN_CAPABILITIES_LAST - 1,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index d790e204aee36..e4b664bdf53df 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -557,7 +557,7 @@ nl80211_ftm_responder_policy[NL80211_FTM_RESP_ATTR_MAX + 1] = {
 					     .len = U8_MAX },
 };
 
-static const struct nla_policy
+const struct nla_policy
 nl80211_pmsr_ftm_req_attr_policy[NL80211_PMSR_FTM_REQ_ATTR_MAX + 1] = {
 	[NL80211_PMSR_FTM_REQ_ATTR_ASAP] = { .type = NLA_FLAG },
 	[NL80211_PMSR_FTM_REQ_ATTR_PREAMBLE] =
@@ -589,6 +589,9 @@ nl80211_pmsr_ftm_req_attr_policy[NL80211_PMSR_FTM_REQ_ATTR_MAX + 1] = {
 	[NL80211_PMSR_FTM_REQ_ATTR_INGRESS] = { .type = NLA_U64 },
 	[NL80211_PMSR_FTM_REQ_ATTR_EGRESS] = { .type = NLA_U64 },
 	[NL80211_PMSR_FTM_REQ_ATTR_PD_SUPPRESS_RESULTS] = { .type = NLA_FLAG },
+	[NL80211_PMSR_FTM_REQ_ATTR_RANGE_REPORT] = { .type = NLA_FLAG },
+	[NL80211_PMSR_FTM_REQ_ATTR_MIN_DELTA_FTM] =
+		NLA_POLICY_MAX(NLA_U8, 63),
 };
 
 static const struct nla_policy
@@ -769,6 +772,33 @@ nl80211_nan_peer_map_policy[NL80211_NAN_PEER_MAP_ATTR_MAX + 1] = {
 		NLA_POLICY_EXACT_LEN(CFG80211_NAN_SCHED_NUM_TIME_SLOTS),
 };
 
+static const struct nla_policy
+nl80211_nan_ndp_policy[NL80211_NAN_NDP_ATTR_MAX + 1] = {
+	[NL80211_NAN_NDP_ATTR_ID] = NLA_POLICY_RANGE(NLA_U8, 1, 255),
+	[NL80211_NAN_NDP_ATTR_PUBLISH_ID] = { .type = NLA_U8 },
+	[NL80211_NAN_NDP_ATTR_SERVICE_ID] =
+		NLA_POLICY_EXACT_LEN(NL80211_NAN_FUNC_SERVICE_ID_LEN),
+	[NL80211_NAN_NDP_ATTR_INIT_NDI] = NLA_POLICY_EXACT_LEN(ETH_ALEN),
+	[NL80211_NAN_NDP_ATTR_RESP_NDI] = NLA_POLICY_EXACT_LEN(ETH_ALEN),
+	[NL80211_NAN_NDP_ATTR_SSI] = {
+		.type = NLA_BINARY,
+		.len = NL80211_NAN_FUNC_SERVICE_SPEC_INFO_MAX_LEN
+	},
+	[NL80211_NAN_NDP_ATTR_CIPHER_SUITE] = { .type = NLA_U32 },
+	[NL80211_NAN_NDP_ATTR_PMK] =
+		NLA_POLICY_EXACT_LEN(NL80211_NAN_NDP_PMK_LEN),
+	[NL80211_NAN_NDP_ATTR_PMKID] =
+		NLA_POLICY_EXACT_LEN(NL80211_NAN_NDP_PMKID_LEN),
+	[NL80211_NAN_NDP_ATTR_GTK_REQUIRED] = { .type = NLA_FLAG },
+	[NL80211_NAN_NDP_ATTR_GTK_CIPHER] = { .type = NLA_U32 },
+	[NL80211_NAN_NDP_ATTR_IPV6_INTF_ID] =
+		NLA_POLICY_EXACT_LEN(NL80211_NAN_NDP_IPV6_INTF_ID_LEN),
+	[NL80211_NAN_NDP_ATTR_NDPE] = { .type = NLA_FLAG },
+	[NL80211_NAN_NDP_ATTR_ACCEPT] = { .type = NLA_FLAG },
+	[NL80211_NAN_NDP_ATTR_REASON] = { .type = NLA_U8 },
+	[NL80211_NAN_NDP_ATTR_STATUS] = { .type = NLA_U8 },
+};
+
 static const struct nla_policy
 nl80211_nan_conf_policy[NL80211_NAN_CONF_ATTR_MAX + 1] = {
 	[NL80211_NAN_CONF_CLUSTER_ID] =
@@ -1193,6 +1223,7 @@ static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
 	[NL80211_ATTR_NAN_MAX_CHAN_SWITCH_TIME] = { .type = NLA_U16 },
 	[NL80211_ATTR_NAN_PEER_MAPS] =
 		NLA_POLICY_NESTED_ARRAY(nl80211_nan_peer_map_policy),
+	[NL80211_ATTR_NAN_NDP] = NLA_POLICY_NESTED(nl80211_nan_ndp_policy),
 	[NL80211_ATTR_NPCA_PRIMARY_FREQ] = { .type = NLA_U32 },
 	[NL80211_ATTR_NPCA_PUNCT_BITMAP] =
 		NLA_POLICY_FULL_RANGE(NLA_U32, &nl80211_punct_bitmap_range),
@@ -1334,6 +1365,24 @@ nl80211_nan_func_policy[NL80211_NAN_FUNC_ATTR_MAX + 1] = {
 	[NL80211_NAN_FUNC_TX_MATCH_FILTER] = { .type = NLA_NESTED },
 	[NL80211_NAN_FUNC_INSTANCE_ID] = { .type = NLA_U8 },
 	[NL80211_NAN_FUNC_TERM_REASON] = { .type = NLA_U8 },
+	[NL80211_NAN_FUNC_SDEA_CTRL] = { .type = NLA_U16 },
+	[NL80211_NAN_FUNC_PAIRING_BOOTSTRAP_METHODS] = { .type = NLA_U16 },
+	[NL80211_NAN_FUNC_CSIDS] = { .type = NLA_BINARY,
+				     .len = U8_MAX * sizeof(u32) },
+	[NL80211_NAN_FUNC_ND_PMK] =
+		NLA_POLICY_EXACT_LEN(NL80211_NAN_NDP_PMK_LEN),
+	[NL80211_NAN_FUNC_PAIRING_SETUP] = { .type = NLA_FLAG },
+	[NL80211_NAN_FUNC_PAIRING_CACHE] = { .type = NLA_FLAG },
+	[NL80211_NAN_FUNC_PAIRING_VERIFY] = { .type = NLA_FLAG },
+	[NL80211_NAN_FUNC_RANGING_INTERVAL] = { .type = NLA_U32 },
+	[NL80211_NAN_FUNC_INGRESS_DISTANCE] = { .type = NLA_U32 },
+	[NL80211_NAN_FUNC_EGRESS_DISTANCE] = { .type = NLA_U32 },
+	[NL80211_NAN_FUNC_FTMS_PER_BURST] = { .type = NLA_U8 },
+	[NL80211_NAN_FUNC_PREAMBLE] =
+		NLA_POLICY_RANGE(NLA_U32, NL80211_PREAMBLE_LEGACY,
+				 NL80211_PREAMBLE_HE),
+	[NL80211_NAN_FUNC_CHAN] = { .type = NLA_NESTED },
+	[NL80211_NAN_FUNC_RANGE_REPORT] = { .type = NLA_FLAG },
 };
 
 /* policy for Service Response Filter attributes */
@@ -2730,7 +2779,8 @@ nl80211_send_pmsr_ftm_capa(const struct cfg80211_pmsr_capabilities *cap,
 			cap->ftm.min_allowed_ranging_interval_ntb))
 		return -ENOBUFS;
 
-	if (cap->ftm.type.infra_support || cap->ftm.type.pd_support) {
+	if (cap->ftm.type.infra_support || cap->ftm.type.pd_support ||
+	    cap->ftm.type.nan_support) {
 		struct nlattr *pd_caps;
 
 		pd_caps = nla_nest_start_noflag(msg,
@@ -2746,6 +2796,10 @@ nl80211_send_pmsr_ftm_capa(const struct cfg80211_pmsr_capabilities *cap,
 		    nla_put_flag(msg, NL80211_PMSR_FTM_TYPE_CAPA_ATTR_PD_SUPPORT))
 			return -ENOBUFS;
 
+		if (cap->ftm.type.nan_support &&
+		    nla_put_flag(msg, NL80211_PMSR_FTM_TYPE_CAPA_ATTR_NAN_SUPPORT))
+			return -ENOBUFS;
+
 		nla_nest_end(msg, pd_caps);
 	}
 
@@ -3138,6 +3192,14 @@ static int nl80211_put_nan_capa(struct wiphy *wiphy, struct sk_buff *msg)
 	    nla_put_flag(msg, NL80211_NAN_CAPA_INSTANT_COMM))
 		goto fail;
 
+	if ((wiphy->nan_capa.flags & WIPHY_NAN_FLAGS_OFFLOAD_RANGING) &&
+	    nla_put_flag(msg, NL80211_NAN_CAPA_OFFLOAD_RANGING))
+		goto fail;
+
+	if ((wiphy->nan_capa.flags & WIPHY_NAN_FLAGS_OFFLOAD_NDP) &&
+	    nla_put_flag(msg, NL80211_NAN_CAPA_OFFLOAD_NDP))
+		goto fail;
+
 	if (nla_put_u8(msg, NL80211_NAN_CAPA_OP_MODE,
 		       wiphy->nan_capa.op_mode) ||
 	    nla_put_u8(msg, NL80211_NAN_CAPA_NUM_ANTENNAS,
@@ -17383,6 +17445,12 @@ static int nl80211_nan_add_func(struct sk_buff *skb,
 	if (!wdev_running(wdev))
 		return -ENOTCONN;
 
+	if (wdev->wiphy->nan_capa.flags & WIPHY_NAN_FLAGS_USERSPACE_DE) {
+		NL_SET_ERR_MSG(info->extack,
+			       "NAN Discovery Engine is in userspace");
+		return -EOPNOTSUPP;
+	}
+
 	if (!info->attrs[NL80211_ATTR_NAN_FUNC])
 		return -EINVAL;
 
@@ -17558,6 +17626,189 @@ static int nl80211_nan_add_func(struct sk_buff *skb,
 			goto out;
 	}
 
+	if (tb[NL80211_NAN_FUNC_SDEA_CTRL]) {
+		u16 sdea = nla_get_u16(tb[NL80211_NAN_FUNC_SDEA_CTRL]);
+
+		if ((sdea & NL80211_NAN_FUNC_SDEA_CTRL_SECURITY_REQUIRED) &&
+		    !(sdea & NL80211_NAN_FUNC_SDEA_CTRL_DATAPATH_REQUIRED)) {
+			NL_SET_ERR_MSG(info->extack,
+				       "SDEA Security Required requires Data Path Required");
+			err = -EINVAL;
+			goto out;
+		}
+
+		if ((sdea & (NL80211_NAN_FUNC_SDEA_CTRL_SECURITY_REQUIRED |
+			     NL80211_NAN_FUNC_SDEA_CTRL_GTK_REQUIRED)) &&
+		    !wiphy_ext_feature_isset(wdev->wiphy,
+					     NL80211_EXT_FEATURE_SECURE_NAN)) {
+			NL_SET_ERR_MSG(info->extack,
+				       "SDEA security bits require SECURE_NAN");
+			err = -EOPNOTSUPP;
+			goto out;
+		}
+
+		if ((sdea & NL80211_NAN_FUNC_SDEA_CTRL_DATAPATH_REQUIRED) &&
+		    !(wdev->wiphy->nan_capa.flags &
+		      WIPHY_NAN_FLAGS_OFFLOAD_NDP)) {
+			NL_SET_ERR_MSG(info->extack,
+				       "SDEA Data Path bit requires OFFLOAD_NDP");
+			err = -EOPNOTSUPP;
+			goto out;
+		}
+		func->sdea_ctrl = sdea;
+	}
+
+	if (tb[NL80211_NAN_FUNC_PAIRING_BOOTSTRAP_METHODS] ||
+	    tb[NL80211_NAN_FUNC_PAIRING_SETUP] ||
+	    tb[NL80211_NAN_FUNC_PAIRING_CACHE] ||
+	    tb[NL80211_NAN_FUNC_PAIRING_VERIFY] ||
+	    tb[NL80211_NAN_FUNC_CSIDS] ||
+	    tb[NL80211_NAN_FUNC_ND_PMK]) {
+		if (!wiphy_ext_feature_isset(wdev->wiphy,
+					     NL80211_EXT_FEATURE_SECURE_NAN)) {
+			NL_SET_ERR_MSG(info->extack,
+				       "Security attributes require SECURE_NAN");
+			err = -EINVAL;
+			goto out;
+		}
+
+		if (tb[NL80211_NAN_FUNC_PAIRING_BOOTSTRAP_METHODS])
+			func->pairing_bootstrap_methods =
+				nla_get_u16(tb[NL80211_NAN_FUNC_PAIRING_BOOTSTRAP_METHODS]);
+
+		func->pairing_setup =
+			nla_get_flag(tb[NL80211_NAN_FUNC_PAIRING_SETUP]);
+		func->pairing_cache =
+			nla_get_flag(tb[NL80211_NAN_FUNC_PAIRING_CACHE]);
+		func->pairing_verify =
+			nla_get_flag(tb[NL80211_NAN_FUNC_PAIRING_VERIFY]);
+
+		if (tb[NL80211_NAN_FUNC_CSIDS]) {
+			int len = nla_len(tb[NL80211_NAN_FUNC_CSIDS]);
+			int n = len / sizeof(u32);
+
+			if (len % sizeof(u32)) {
+				NL_SET_ERR_MSG_ATTR(info->extack,
+						    tb[NL80211_NAN_FUNC_CSIDS],
+						    "CSIDs must be an array of u32 values");
+				err = -EINVAL;
+				goto out;
+			}
+
+			if (n > 0) {
+				func->csids =
+					kmemdup(nla_data(tb[NL80211_NAN_FUNC_CSIDS]),
+						len, GFP_KERNEL);
+				if (!func->csids) {
+					err = -ENOMEM;
+					goto out;
+				}
+				func->num_csids = n;
+			}
+		}
+
+		if (tb[NL80211_NAN_FUNC_ND_PMK]) {
+			memcpy(func->nd_pmk,
+			       nla_data(tb[NL80211_NAN_FUNC_ND_PMK]),
+			       sizeof(func->nd_pmk));
+			func->nd_pmk_set = true;
+		}
+	}
+
+	if (tb[NL80211_NAN_FUNC_RANGING_INTERVAL] ||
+	    tb[NL80211_NAN_FUNC_INGRESS_DISTANCE] ||
+	    tb[NL80211_NAN_FUNC_EGRESS_DISTANCE] ||
+	    tb[NL80211_NAN_FUNC_FTMS_PER_BURST] ||
+	    tb[NL80211_NAN_FUNC_PREAMBLE] ||
+	    tb[NL80211_NAN_FUNC_CHAN] ||
+	    tb[NL80211_NAN_FUNC_RANGE_REPORT]) {
+		const struct cfg80211_pmsr_capabilities *pmsr_capa =
+			rdev->wiphy.pmsr_capa;
+
+		/* SDEA Ranging Required bit must be set */
+		if (!(func->sdea_ctrl & NL80211_NAN_FUNC_SDEA_CTRL_RANGING_REQUIRED)) {
+			NL_SET_ERR_MSG(info->extack,
+				       "NAN ranging parameters require SDEA Ranging Required bit");
+			err = -EINVAL;
+			goto out;
+		}
+
+		if (!(wdev->wiphy->nan_capa.flags &
+		      WIPHY_NAN_FLAGS_OFFLOAD_RANGING) ||
+		    !pmsr_capa || !pmsr_capa->ftm.supported) {
+			NL_SET_ERR_MSG(info->extack,
+				       "NAN ranging not supported by device");
+			err = -EOPNOTSUPP;
+			goto out;
+		}
+
+		if (tb[NL80211_NAN_FUNC_RANGING_INTERVAL])
+			func->ranging_interval =
+				nla_get_u32(tb[NL80211_NAN_FUNC_RANGING_INTERVAL]);
+
+		if (tb[NL80211_NAN_FUNC_INGRESS_DISTANCE])
+			func->ingress_distance =
+				nla_get_u32(tb[NL80211_NAN_FUNC_INGRESS_DISTANCE]);
+
+		if (tb[NL80211_NAN_FUNC_EGRESS_DISTANCE])
+			func->egress_distance =
+				nla_get_u32(tb[NL80211_NAN_FUNC_EGRESS_DISTANCE]);
+
+		if (tb[NL80211_NAN_FUNC_FTMS_PER_BURST]) {
+			func->ftms_per_burst =
+				nla_get_u8(tb[NL80211_NAN_FUNC_FTMS_PER_BURST]);
+			if (func->ftms_per_burst > 31) {
+				NL_SET_ERR_MSG_ATTR(info->extack,
+						    tb[NL80211_NAN_FUNC_FTMS_PER_BURST],
+						    "NAN FTMs per burst exceeds limit of 31");
+				err = -EINVAL;
+				goto out;
+			}
+			if (pmsr_capa->ftm.max_ftms_per_burst &&
+			    func->ftms_per_burst > pmsr_capa->ftm.max_ftms_per_burst) {
+				NL_SET_ERR_MSG_ATTR(info->extack,
+						    tb[NL80211_NAN_FUNC_FTMS_PER_BURST],
+						    "NAN FTMs per burst exceeds device limit");
+				err = -EINVAL;
+				goto out;
+			}
+		}
+
+		if (tb[NL80211_NAN_FUNC_PREAMBLE]) {
+			func->preamble =
+				nla_get_u32(tb[NL80211_NAN_FUNC_PREAMBLE]);
+			if (!(pmsr_capa->ftm.preambles & BIT(func->preamble))) {
+				NL_SET_ERR_MSG_ATTR(info->extack,
+						    tb[NL80211_NAN_FUNC_PREAMBLE],
+						    "NAN ranging: unsupported preamble");
+				err = -EINVAL;
+				goto out;
+			}
+		}
+
+		if (tb[NL80211_NAN_FUNC_CHAN]) {
+			/* Reuse info->attrs for chandef parsing; the original contents
+			 * are no longer needed.
+			 */
+			memset(info->attrs, 0,
+			       sizeof(*info->attrs) * (NL80211_ATTR_MAX + 1));
+			err = nla_parse_nested(info->attrs, NL80211_ATTR_MAX,
+					       tb[NL80211_NAN_FUNC_CHAN],
+					       nl80211_policy, info->extack);
+			if (err)
+				goto out;
+			err = nl80211_parse_chandef(rdev, info->extack,
+						    info->attrs,
+						    &func->chandef, false);
+			if (err)
+				goto out;
+			func->chandef_valid = true;
+		}
+
+		func->range_report =
+			nla_get_flag(tb[NL80211_NAN_FUNC_RANGE_REPORT]);
+	}
+
 	msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
 	if (!msg) {
 		err = -ENOMEM;
@@ -17757,6 +18008,58 @@ void cfg80211_nan_match(struct wireless_dev *wdev,
 		goto nla_put_failure;
 
 	nla_nest_end(msg, peer_func_attr);
+
+	if (match->sdea_ctrl &&
+	    nla_put_u16(msg, NL80211_NAN_MATCH_SDEA_CTRL, match->sdea_ctrl))
+		goto nla_put_failure;
+
+	if (match->pairing_bootstrap_methods &&
+	    nla_put_u16(msg, NL80211_NAN_MATCH_BOOTSTRAP_METHODS,
+			match->pairing_bootstrap_methods))
+		goto nla_put_failure;
+
+	if (match->csids && match->num_csids &&
+	    nla_put(msg, NL80211_NAN_MATCH_CIPHER_SUITES,
+		    match->num_csids * sizeof(u32),
+		    match->csids))
+		goto nla_put_failure;
+
+	if (match->pairing_setup &&
+	    nla_put_flag(msg, NL80211_NAN_MATCH_PAIRING_SETUP))
+		goto nla_put_failure;
+
+	if (match->pairing_cache &&
+	    nla_put_flag(msg, NL80211_NAN_MATCH_PAIRING_CACHE))
+		goto nla_put_failure;
+
+	if (match->pairing_verify &&
+	    nla_put_flag(msg, NL80211_NAN_MATCH_PAIRING_VERIFY))
+		goto nla_put_failure;
+
+	if (match->extra_info && match->extra_info_len &&
+	    nla_put(msg, NL80211_NAN_MATCH_EXTRA_INFO, match->extra_info_len,
+		    match->extra_info))
+		goto nla_put_failure;
+
+	if (match->ies && match->ies_len &&
+	    nla_put(msg, NL80211_NAN_MATCH_IES, match->ies_len, match->ies))
+		goto nla_put_failure;
+
+	if (match->rssi_valid &&
+	    nla_put_s32(msg, NL80211_NAN_MATCH_RSSI, match->rssi))
+		goto nla_put_failure;
+
+	/* report ranging info only if ranging was indicated */
+	if (match->ranging_indication) {
+		if (nla_put_u8(msg, NL80211_NAN_MATCH_RANGING_INDICATION,
+			       match->ranging_indication))
+			goto nla_put_failure;
+
+		if (nla_put_s32(msg, NL80211_NAN_MATCH_RANGING_MEASUREMENT,
+				match->ranging_measurement))
+			goto nla_put_failure;
+	}
+
 	nla_nest_end(msg, match_attr);
 	genlmsg_end(msg, hdr);
 
@@ -18198,6 +18501,507 @@ static int nl80211_nan_set_peer_sched(struct sk_buff *skb,
 	return rdev_nan_set_peer_sched(rdev, wdev, &sched);
 }
 
+static int nl80211_nan_ndp_initiate(struct sk_buff *skb,
+				    struct genl_info *info)
+{
+	struct cfg80211_registered_device *rdev = info->user_ptr[0];
+	struct wireless_dev *wdev = info->user_ptr[1];
+	struct nlattr *tb[NL80211_NAN_NDP_ATTR_MAX + 1];
+	struct cfg80211_nan_ndp_initiate params = {};
+	int err;
+
+	if (wdev->iftype != NL80211_IFTYPE_NAN) {
+		NL_SET_ERR_MSG(info->extack,
+			       "NDP initiate requires NAN interface");
+		return -EOPNOTSUPP;
+	}
+
+	if (!(rdev->wiphy.nan_capa.flags & WIPHY_NAN_FLAGS_OFFLOAD_NDP)) {
+		NL_SET_ERR_MSG(info->extack,
+			       "NAN NDP offload not supported by driver");
+		return -EOPNOTSUPP;
+	}
+
+	if (!info->attrs[NL80211_ATTR_MAC] ||
+	    !info->attrs[NL80211_ATTR_NAN_NDP]) {
+		NL_SET_ERR_MSG(info->extack,
+			       "NDP initiate requires peer NMI and NDP params");
+		return -EINVAL;
+	}
+
+	err = nla_parse_nested(tb, NL80211_NAN_NDP_ATTR_MAX,
+			       info->attrs[NL80211_ATTR_NAN_NDP],
+			       nl80211_nan_ndp_policy,
+			       info->extack);
+	if (err)
+		return err;
+
+	if (!tb[NL80211_NAN_NDP_ATTR_INIT_NDI] ||
+	    !tb[NL80211_NAN_NDP_ATTR_PUBLISH_ID] ||
+	    !tb[NL80211_NAN_NDP_ATTR_SERVICE_ID]) {
+		NL_SET_ERR_MSG(info->extack,
+			       "NDP initiate requires INIT_NDI, PUBLISH_ID and SERVICE_ID");
+		return -EINVAL;
+	}
+
+	params.peer_nmi = nla_data(info->attrs[NL80211_ATTR_MAC]);
+	params.init_ndi = nla_data(tb[NL80211_NAN_NDP_ATTR_INIT_NDI]);
+	params.publish_id = nla_get_u8(tb[NL80211_NAN_NDP_ATTR_PUBLISH_ID]);
+	memcpy(params.service_id,
+	       nla_data(tb[NL80211_NAN_NDP_ATTR_SERVICE_ID]),
+	       NL80211_NAN_FUNC_SERVICE_ID_LEN);
+
+	if (tb[NL80211_NAN_NDP_ATTR_SSI]) {
+		params.ssi = nla_data(tb[NL80211_NAN_NDP_ATTR_SSI]);
+		params.ssi_len = nla_len(tb[NL80211_NAN_NDP_ATTR_SSI]);
+	}
+
+	if (tb[NL80211_NAN_NDP_ATTR_CIPHER_SUITE])
+		params.cipher_suite =
+			nla_get_u32(tb[NL80211_NAN_NDP_ATTR_CIPHER_SUITE]);
+
+	if (tb[NL80211_NAN_NDP_ATTR_PMK]) {
+		if (!wiphy_ext_feature_isset(&rdev->wiphy,
+					     NL80211_EXT_FEATURE_SECURE_NAN)) {
+			NL_SET_ERR_MSG_ATTR(info->extack,
+					    tb[NL80211_NAN_NDP_ATTR_PMK],
+					    "PMK requires SECURE_NAN feature");
+			return -EOPNOTSUPP;
+		}
+		memcpy(params.pmk,
+		       nla_data(tb[NL80211_NAN_NDP_ATTR_PMK]),
+		       NL80211_NAN_NDP_PMK_LEN);
+		params.pmk_set = true;
+	}
+
+	if (tb[NL80211_NAN_NDP_ATTR_PMKID]) {
+		if (!wiphy_ext_feature_isset(&rdev->wiphy,
+					     NL80211_EXT_FEATURE_SECURE_NAN)) {
+			NL_SET_ERR_MSG_ATTR(info->extack,
+					    tb[NL80211_NAN_NDP_ATTR_PMKID],
+					    "PMKID requires SECURE_NAN feature");
+			return -EOPNOTSUPP;
+		}
+		memcpy(params.pmkid,
+		       nla_data(tb[NL80211_NAN_NDP_ATTR_PMKID]),
+		       NL80211_NAN_NDP_PMKID_LEN);
+		params.pmkid_set = true;
+	}
+
+	if (tb[NL80211_NAN_NDP_ATTR_GTK_REQUIRED]) {
+		if (!wiphy_ext_feature_isset(&rdev->wiphy,
+					     NL80211_EXT_FEATURE_SECURE_NAN)) {
+			NL_SET_ERR_MSG_ATTR(info->extack,
+					    tb[NL80211_NAN_NDP_ATTR_GTK_REQUIRED],
+					    "GTK_REQUIRED requires SECURE_NAN feature");
+			return -EOPNOTSUPP;
+		}
+
+		if (!tb[NL80211_NAN_NDP_ATTR_GTK_CIPHER]) {
+			NL_SET_ERR_MSG_ATTR(info->extack,
+					    tb[NL80211_NAN_NDP_ATTR_GTK_REQUIRED],
+					    "GTK_CIPHER is required when GTK_REQUIRED is set");
+			return -EINVAL;
+		}
+
+		params.gtk_required = true;
+		params.gtk_cipher =
+			nla_get_u32(tb[NL80211_NAN_NDP_ATTR_GTK_CIPHER]);
+	} else if (tb[NL80211_NAN_NDP_ATTR_GTK_CIPHER]) {
+		NL_SET_ERR_MSG_ATTR(info->extack,
+				    tb[NL80211_NAN_NDP_ATTR_GTK_CIPHER],
+				    "GTK_CIPHER requires GTK_REQUIRED");
+		return -EINVAL;
+	}
+
+	if (tb[NL80211_NAN_NDP_ATTR_IPV6_INTF_ID]) {
+		memcpy(params.ipv6_intf_id,
+		       nla_data(tb[NL80211_NAN_NDP_ATTR_IPV6_INTF_ID]),
+		       NL80211_NAN_NDP_IPV6_INTF_ID_LEN);
+		params.ipv6_intf_id_set = true;
+	}
+
+	params.ndpe = nla_get_flag(tb[NL80211_NAN_NDP_ATTR_NDPE]);
+
+	return rdev_nan_ndp_initiate(rdev, wdev, &params);
+}
+
+static int nl80211_nan_ndp_respond(struct sk_buff *skb,
+				   struct genl_info *info)
+{
+	struct cfg80211_registered_device *rdev = info->user_ptr[0];
+	struct wireless_dev *wdev = info->user_ptr[1];
+	struct nlattr *tb[NL80211_NAN_NDP_ATTR_MAX + 1];
+	struct cfg80211_nan_ndp_respond params = {};
+	int err;
+
+	if (wdev->iftype != NL80211_IFTYPE_NAN) {
+		NL_SET_ERR_MSG(info->extack,
+			       "NDP respond requires NAN interface");
+		return -EOPNOTSUPP;
+	}
+
+	if (!(rdev->wiphy.nan_capa.flags & WIPHY_NAN_FLAGS_OFFLOAD_NDP)) {
+		NL_SET_ERR_MSG(info->extack,
+			       "NAN NDP offload not supported by driver");
+		return -EOPNOTSUPP;
+	}
+
+	if (!info->attrs[NL80211_ATTR_MAC] ||
+	    !info->attrs[NL80211_ATTR_NAN_NDP]) {
+		NL_SET_ERR_MSG(info->extack,
+			       "NDP respond requires peer NMI and NDP params");
+		return -EINVAL;
+	}
+
+	err = nla_parse_nested(tb, NL80211_NAN_NDP_ATTR_MAX,
+			       info->attrs[NL80211_ATTR_NAN_NDP],
+			       nl80211_nan_ndp_policy,
+			       info->extack);
+	if (err)
+		return err;
+
+	if (!tb[NL80211_NAN_NDP_ATTR_ID] ||
+	    !tb[NL80211_NAN_NDP_ATTR_INIT_NDI]) {
+		NL_SET_ERR_MSG(info->extack,
+			       "NDP respond requires NDP ID and INIT_NDI");
+		return -EINVAL;
+	}
+
+	params.peer_nmi = nla_data(info->attrs[NL80211_ATTR_MAC]);
+	params.ndp_id = nla_get_u8(tb[NL80211_NAN_NDP_ATTR_ID]);
+	params.init_ndi = nla_data(tb[NL80211_NAN_NDP_ATTR_INIT_NDI]);
+	params.accept = nla_get_flag(tb[NL80211_NAN_NDP_ATTR_ACCEPT]);
+
+	if (params.accept) {
+		if (!tb[NL80211_NAN_NDP_ATTR_RESP_NDI]) {
+			NL_SET_ERR_MSG(info->extack,
+				       "NDP accept requires RESP_NDI");
+			return -EINVAL;
+		}
+		params.resp_ndi = nla_data(tb[NL80211_NAN_NDP_ATTR_RESP_NDI]);
+	} else {
+		if (tb[NL80211_NAN_NDP_ATTR_REASON])
+			params.reason =
+				nla_get_u8(tb[NL80211_NAN_NDP_ATTR_REASON]);
+	}
+
+	if (tb[NL80211_NAN_NDP_ATTR_SSI]) {
+		params.ssi = nla_data(tb[NL80211_NAN_NDP_ATTR_SSI]);
+		params.ssi_len = nla_len(tb[NL80211_NAN_NDP_ATTR_SSI]);
+	}
+
+	if (tb[NL80211_NAN_NDP_ATTR_CIPHER_SUITE])
+		params.cipher_suite =
+			nla_get_u32(tb[NL80211_NAN_NDP_ATTR_CIPHER_SUITE]);
+
+	if (params.accept && tb[NL80211_NAN_NDP_ATTR_PMK]) {
+		if (!wiphy_ext_feature_isset(&rdev->wiphy,
+					     NL80211_EXT_FEATURE_SECURE_NAN)) {
+			NL_SET_ERR_MSG_ATTR(info->extack,
+					    tb[NL80211_NAN_NDP_ATTR_PMK],
+					    "PMK requires SECURE_NAN feature");
+			return -EOPNOTSUPP;
+		}
+		memcpy(params.pmk,
+		       nla_data(tb[NL80211_NAN_NDP_ATTR_PMK]),
+		       NL80211_NAN_NDP_PMK_LEN);
+		params.pmk_set = true;
+	}
+
+	if (params.accept && tb[NL80211_NAN_NDP_ATTR_GTK_REQUIRED]) {
+		if (!wiphy_ext_feature_isset(&rdev->wiphy,
+					     NL80211_EXT_FEATURE_SECURE_NAN)) {
+			NL_SET_ERR_MSG_ATTR(info->extack,
+					    tb[NL80211_NAN_NDP_ATTR_GTK_REQUIRED],
+					    "GTK_REQUIRED requires SECURE_NAN feature");
+			return -EOPNOTSUPP;
+		}
+
+		if (!tb[NL80211_NAN_NDP_ATTR_GTK_CIPHER]) {
+			NL_SET_ERR_MSG_ATTR(info->extack,
+					    tb[NL80211_NAN_NDP_ATTR_GTK_REQUIRED],
+					    "GTK_CIPHER is required when GTK_REQUIRED is set");
+			return -EINVAL;
+		}
+
+		params.gtk_required = true;
+		params.gtk_cipher =
+			nla_get_u32(tb[NL80211_NAN_NDP_ATTR_GTK_CIPHER]);
+	} else if (params.accept && tb[NL80211_NAN_NDP_ATTR_GTK_CIPHER]) {
+		NL_SET_ERR_MSG_ATTR(info->extack,
+				    tb[NL80211_NAN_NDP_ATTR_GTK_CIPHER],
+				    "GTK_CIPHER requires GTK_REQUIRED");
+		return -EINVAL;
+	}
+
+	if (tb[NL80211_NAN_NDP_ATTR_IPV6_INTF_ID]) {
+		memcpy(params.ipv6_intf_id,
+		       nla_data(tb[NL80211_NAN_NDP_ATTR_IPV6_INTF_ID]),
+		       NL80211_NAN_NDP_IPV6_INTF_ID_LEN);
+		params.ipv6_intf_id_set = true;
+	}
+
+	params.ndpe = nla_get_flag(tb[NL80211_NAN_NDP_ATTR_NDPE]);
+
+	return rdev_nan_ndp_respond(rdev, wdev, &params);
+}
+
+static int nl80211_nan_ndp_terminate(struct sk_buff *skb,
+				     struct genl_info *info)
+{
+	struct cfg80211_registered_device *rdev = info->user_ptr[0];
+	struct wireless_dev *wdev = info->user_ptr[1];
+	struct nlattr *tb[NL80211_NAN_NDP_ATTR_MAX + 1];
+	struct cfg80211_nan_ndp_terminate params = {};
+	int err;
+
+	if (wdev->iftype != NL80211_IFTYPE_NAN) {
+		NL_SET_ERR_MSG(info->extack,
+			       "NDP terminate requires NAN interface");
+		return -EOPNOTSUPP;
+	}
+
+	if (!(rdev->wiphy.nan_capa.flags & WIPHY_NAN_FLAGS_OFFLOAD_NDP)) {
+		NL_SET_ERR_MSG(info->extack,
+			       "NAN NDP offload not supported by driver");
+		return -EOPNOTSUPP;
+	}
+
+	if (!info->attrs[NL80211_ATTR_MAC] ||
+	    !info->attrs[NL80211_ATTR_NAN_NDP]) {
+		NL_SET_ERR_MSG(info->extack,
+			       "NDP terminate requires peer NMI and NDP params");
+		return -EINVAL;
+	}
+
+	err = nla_parse_nested(tb, NL80211_NAN_NDP_ATTR_MAX,
+			       info->attrs[NL80211_ATTR_NAN_NDP],
+			       nl80211_nan_ndp_policy,
+			       info->extack);
+	if (err)
+		return err;
+
+	if (!tb[NL80211_NAN_NDP_ATTR_ID] ||
+	    !tb[NL80211_NAN_NDP_ATTR_INIT_NDI]) {
+		NL_SET_ERR_MSG(info->extack,
+			       "NDP terminate requires NDP ID and INIT_NDI");
+		return -EINVAL;
+	}
+
+	params.peer_nmi = nla_data(info->attrs[NL80211_ATTR_MAC]);
+	params.ndp_id = nla_get_u8(tb[NL80211_NAN_NDP_ATTR_ID]);
+	params.init_ndi = nla_data(tb[NL80211_NAN_NDP_ATTR_INIT_NDI]);
+
+	if (tb[NL80211_NAN_NDP_ATTR_REASON])
+		params.reason = nla_get_u8(tb[NL80211_NAN_NDP_ATTR_REASON]);
+
+	return rdev_nan_ndp_terminate(rdev, wdev, &params);
+}
+
+void cfg80211_nan_ndp_request(struct wireless_dev *wdev,
+			      struct cfg80211_nan_ndp_request_params *params,
+			      gfp_t gfp)
+{
+	struct wiphy *wiphy = wdev->wiphy;
+	struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
+	struct nlattr *ndp_attr;
+	struct sk_buff *msg;
+	void *hdr;
+
+	if (WARN_ON(!(wiphy->nan_capa.flags & WIPHY_NAN_FLAGS_OFFLOAD_NDP)))
+		return;
+
+	if (!wdev->owner_nlportid)
+		return;
+
+	msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
+	if (!msg)
+		return;
+
+	hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_NAN_NDP_REQUEST);
+	if (!hdr)
+		goto nla_put_failure;
+
+	if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
+	    nla_put_u64_64bit(msg, NL80211_ATTR_WDEV, wdev_id(wdev),
+			      NL80211_ATTR_PAD) ||
+	    nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, params->peer_nmi))
+		goto nla_put_failure;
+
+	ndp_attr = nla_nest_start(msg, NL80211_ATTR_NAN_NDP);
+	if (!ndp_attr)
+		goto nla_put_failure;
+
+	if (nla_put_u8(msg, NL80211_NAN_NDP_ATTR_ID, params->ndp_id) ||
+	    nla_put(msg, NL80211_NAN_NDP_ATTR_INIT_NDI, ETH_ALEN,
+		    params->init_ndi) ||
+	    nla_put_u8(msg, NL80211_NAN_NDP_ATTR_PUBLISH_ID,
+		       params->publish_id))
+		goto nla_put_failure;
+
+	if (params->ssi && params->ssi_len &&
+	    nla_put(msg, NL80211_NAN_NDP_ATTR_SSI, params->ssi_len,
+		    params->ssi))
+		goto nla_put_failure;
+
+	if (params->cipher_suite &&
+	    nla_put_u32(msg, NL80211_NAN_NDP_ATTR_CIPHER_SUITE,
+			params->cipher_suite))
+		goto nla_put_failure;
+
+	if (params->pmkid_set &&
+	    nla_put(msg, NL80211_NAN_NDP_ATTR_PMKID,
+		    NL80211_NAN_NDP_PMKID_LEN, params->pmkid))
+		goto nla_put_failure;
+
+	if (params->gtk_required &&
+	    nla_put_flag(msg, NL80211_NAN_NDP_ATTR_GTK_REQUIRED))
+		goto nla_put_failure;
+
+	if (params->ipv6_intf_id_set &&
+	    nla_put(msg, NL80211_NAN_NDP_ATTR_IPV6_INTF_ID,
+		    NL80211_NAN_NDP_IPV6_INTF_ID_LEN, params->ipv6_intf_id))
+		goto nla_put_failure;
+
+	if (params->ndpe &&
+	    nla_put_flag(msg, NL80211_NAN_NDP_ATTR_NDPE))
+		goto nla_put_failure;
+
+	nla_nest_end(msg, ndp_attr);
+	genlmsg_end(msg, hdr);
+	genlmsg_unicast(wiphy_net(wiphy), msg, wdev->owner_nlportid);
+	return;
+
+nla_put_failure:
+	nlmsg_free(msg);
+}
+EXPORT_SYMBOL(cfg80211_nan_ndp_request);
+
+void cfg80211_nan_ndp_confirm(struct wireless_dev *wdev,
+			      struct cfg80211_nan_ndp_confirm_params *params,
+			      gfp_t gfp)
+{
+	struct wiphy *wiphy = wdev->wiphy;
+	struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
+	struct nlattr *ndp_attr;
+	struct sk_buff *msg;
+	void *hdr;
+
+	if (WARN_ON(!(wiphy->nan_capa.flags & WIPHY_NAN_FLAGS_OFFLOAD_NDP)))
+		return;
+
+	if (!wdev->owner_nlportid)
+		return;
+
+	if (WARN_ON_ONCE(params->accepted && !params->resp_ndi))
+		return;
+
+	msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
+	if (!msg)
+		return;
+
+	hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_NAN_NDP_CONFIRM);
+	if (!hdr)
+		goto nla_put_failure;
+
+	if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
+	    nla_put_u64_64bit(msg, NL80211_ATTR_WDEV, wdev_id(wdev),
+			      NL80211_ATTR_PAD) ||
+	    nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, params->peer_nmi))
+		goto nla_put_failure;
+
+	ndp_attr = nla_nest_start(msg, NL80211_ATTR_NAN_NDP);
+	if (!ndp_attr)
+		goto nla_put_failure;
+
+	if (nla_put_u8(msg, NL80211_NAN_NDP_ATTR_ID, params->ndp_id) ||
+	    nla_put(msg, NL80211_NAN_NDP_ATTR_INIT_NDI, ETH_ALEN,
+		    params->init_ndi) ||
+	    nla_put_u8(msg, NL80211_NAN_NDP_ATTR_STATUS,
+		       params->accepted ? NL80211_NAN_NDP_STATUS_ACCEPTED :
+					   NL80211_NAN_NDP_STATUS_REJECTED))
+		goto nla_put_failure;
+
+	if (params->accepted && params->resp_ndi &&
+	    nla_put(msg, NL80211_NAN_NDP_ATTR_RESP_NDI, ETH_ALEN,
+		    params->resp_ndi))
+		goto nla_put_failure;
+
+	if (!params->accepted &&
+	    nla_put_u8(msg, NL80211_NAN_NDP_ATTR_REASON, params->reason))
+		goto nla_put_failure;
+
+	if (params->ssi && params->ssi_len &&
+	    nla_put(msg, NL80211_NAN_NDP_ATTR_SSI, params->ssi_len,
+		    params->ssi))
+		goto nla_put_failure;
+
+	if (params->ipv6_intf_id_set &&
+	    nla_put(msg, NL80211_NAN_NDP_ATTR_IPV6_INTF_ID,
+		    NL80211_NAN_NDP_IPV6_INTF_ID_LEN, params->ipv6_intf_id))
+		goto nla_put_failure;
+
+	nla_nest_end(msg, ndp_attr);
+	genlmsg_end(msg, hdr);
+	genlmsg_unicast(wiphy_net(wiphy), msg, wdev->owner_nlportid);
+	return;
+
+nla_put_failure:
+	nlmsg_free(msg);
+}
+EXPORT_SYMBOL(cfg80211_nan_ndp_confirm);
+
+void cfg80211_nan_ndp_terminated(struct wireless_dev *wdev,
+				 struct cfg80211_nan_ndp_terminated_params *params,
+				 gfp_t gfp)
+{
+	struct wiphy *wiphy = wdev->wiphy;
+	struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
+	struct nlattr *ndp_attr;
+	struct sk_buff *msg;
+	void *hdr;
+
+	if (WARN_ON(!(wiphy->nan_capa.flags & WIPHY_NAN_FLAGS_OFFLOAD_NDP)))
+		return;
+
+	if (!wdev->owner_nlportid)
+		return;
+
+	msg = nlmsg_new(NLMSG_DEFAULT_SIZE, gfp);
+	if (!msg)
+		return;
+
+	hdr = nl80211hdr_put(msg, 0, 0, 0, NL80211_CMD_NAN_NDP_TERMINATED);
+	if (!hdr)
+		goto nla_put_failure;
+
+	if (nla_put_u32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx) ||
+	    nla_put_u64_64bit(msg, NL80211_ATTR_WDEV, wdev_id(wdev),
+			      NL80211_ATTR_PAD) ||
+	    nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, params->peer_nmi))
+		goto nla_put_failure;
+
+	ndp_attr = nla_nest_start(msg, NL80211_ATTR_NAN_NDP);
+	if (!ndp_attr)
+		goto nla_put_failure;
+
+	if (nla_put_u8(msg, NL80211_NAN_NDP_ATTR_ID, params->ndp_id) ||
+	    nla_put(msg, NL80211_NAN_NDP_ATTR_INIT_NDI, ETH_ALEN,
+		    params->init_ndi) ||
+	    nla_put_u8(msg, NL80211_NAN_NDP_ATTR_REASON, params->reason))
+		goto nla_put_failure;
+
+	nla_nest_end(msg, ndp_attr);
+	genlmsg_end(msg, hdr);
+	genlmsg_unicast(wiphy_net(wiphy), msg, wdev->owner_nlportid);
+	return;
+
+nla_put_failure:
+	nlmsg_free(msg);
+}
+EXPORT_SYMBOL(cfg80211_nan_ndp_terminated);
+
 static bool nl80211_nan_is_sched_empty(struct cfg80211_nan_local_sched *sched)
 {
 	if (!sched->n_channels)
@@ -21350,6 +22154,24 @@ static const struct genl_small_ops nl80211_small_ops[] = {
 		.internal_flags = IFLAGS(NL80211_FLAG_NEED_NETDEV_UP |
 					 NL80211_FLAG_NO_WIPHY_MTX),
 	},
+	{
+		.cmd = NL80211_CMD_NAN_NDP_INITIATE,
+		.doit = nl80211_nan_ndp_initiate,
+		.flags = GENL_ADMIN_PERM,
+		.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),
+	},
+	{
+		.cmd = NL80211_CMD_NAN_NDP_RESPOND,
+		.doit = nl80211_nan_ndp_respond,
+		.flags = GENL_ADMIN_PERM,
+		.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),
+	},
+	{
+		.cmd = NL80211_CMD_NAN_NDP_TERMINATE,
+		.doit = nl80211_nan_ndp_terminate,
+		.flags = GENL_ADMIN_PERM,
+		.internal_flags = IFLAGS(NL80211_FLAG_NEED_WDEV_UP),
+	},
 };
 
 static struct genl_family nl80211_fam __ro_after_init = {
diff --git a/net/wireless/nl80211.h b/net/wireless/nl80211.h
index bdb065d140549..31a2c2eb62761 100644
--- a/net/wireless/nl80211.h
+++ b/net/wireless/nl80211.h
@@ -126,6 +126,9 @@ void cfg80211_free_coalesce(struct cfg80211_coalesce *coalesce);
 /* peer measurement */
 int nl80211_pmsr_start(struct sk_buff *skb, struct genl_info *info);
 
+extern const struct nla_policy
+nl80211_pmsr_ftm_req_attr_policy[NL80211_PMSR_FTM_REQ_ATTR_MAX + 1];
+
 void nl80211_mlo_reconf_add_done(struct net_device *dev,
 				 struct cfg80211_mlo_reconf_done_data *data);
 
diff --git a/net/wireless/pmsr.c b/net/wireless/pmsr.c
index 97449bcb9a225..bcf5390174e47 100644
--- a/net/wireless/pmsr.c
+++ b/net/wireless/pmsr.c
@@ -306,11 +306,108 @@ static int pmsr_parse_ftm(struct cfg80211_registered_device *rdev,
 	return 0;
 }
 
+static int pmsr_parse_ftm_nan(struct cfg80211_registered_device *rdev,
+			      struct nlattr *ftmreq,
+			      struct cfg80211_pmsr_request_peer *out,
+			      struct genl_info *info)
+{
+	const struct cfg80211_pmsr_capabilities *capa = rdev->wiphy.pmsr_capa;
+	struct nlattr *tb[NL80211_PMSR_FTM_REQ_ATTR_MAX + 1];
+	int err;
+
+	err = nla_parse_nested(tb, NL80211_PMSR_FTM_REQ_ATTR_MAX, ftmreq,
+			       nl80211_pmsr_ftm_req_attr_policy,
+			       info->extack);
+	if (err)
+		return err;
+
+	out->ftm.requested = true;
+
+	/* NAN ranging requires ASAP; reject if not set by userspace */
+	out->ftm.asap = nla_get_flag(tb[NL80211_PMSR_FTM_REQ_ATTR_ASAP]);
+	if (!out->ftm.asap) {
+		NL_SET_ERR_MSG(info->extack,
+			       "FTM: NAN ranging requires ASAP mode");
+		return -EINVAL;
+	}
+	if (!capa->ftm.asap) {
+		NL_SET_ERR_MSG(info->extack,
+			       "FTM: NAN ASAP mode is not supported by device");
+		return -EOPNOTSUPP;
+	}
+
+	/* NAN ranging requires single burst (num_bursts_exp must be 0) */
+	if (!tb[NL80211_PMSR_FTM_REQ_ATTR_NUM_BURSTS_EXP] ||
+	    nla_get_u8(tb[NL80211_PMSR_FTM_REQ_ATTR_NUM_BURSTS_EXP]) != 0) {
+		NL_SET_ERR_MSG(info->extack,
+			       "FTM: NAN ranging requires single burst");
+		return -EINVAL;
+	}
+
+	out->ftm.rsta = !!tb[NL80211_PMSR_FTM_REQ_ATTR_RSTA];
+	out->ftm.range_report =
+		!!tb[NL80211_PMSR_FTM_REQ_ATTR_RANGE_REPORT];
+	if (out->ftm.range_report && !out->ftm.rsta) {
+		NL_SET_ERR_MSG_ATTR(info->extack,
+				    tb[NL80211_PMSR_FTM_REQ_ATTR_RANGE_REPORT],
+				    "FTM: range report is valid only for NAN RSTA");
+		return -EINVAL;
+	}
+
+	if (tb[NL80211_PMSR_FTM_REQ_ATTR_PREAMBLE]) {
+		out->ftm.preamble =
+			nla_get_u32(tb[NL80211_PMSR_FTM_REQ_ATTR_PREAMBLE]);
+		if (!(capa->ftm.preambles & BIT(out->ftm.preamble))) {
+			NL_SET_ERR_MSG_ATTR(info->extack,
+					    tb[NL80211_PMSR_FTM_REQ_ATTR_PREAMBLE],
+					    "FTM: unsupported preamble for NAN ranging");
+			return -EINVAL;
+		}
+	}
+
+	if (tb[NL80211_PMSR_FTM_REQ_ATTR_FTMS_PER_BURST]) {
+		out->ftm.ftms_per_burst =
+			nla_get_u8(tb[NL80211_PMSR_FTM_REQ_ATTR_FTMS_PER_BURST]);
+		if (out->ftm.ftms_per_burst > 31) {
+			NL_SET_ERR_MSG_ATTR(info->extack,
+					    tb[NL80211_PMSR_FTM_REQ_ATTR_FTMS_PER_BURST],
+					    "FTM: NAN FTMs per burst exceeds limit of 31");
+			return -EINVAL;
+		}
+		if (capa->ftm.max_ftms_per_burst &&
+		    out->ftm.ftms_per_burst > capa->ftm.max_ftms_per_burst) {
+			NL_SET_ERR_MSG_ATTR(info->extack,
+					    tb[NL80211_PMSR_FTM_REQ_ATTR_FTMS_PER_BURST],
+					    "FTM: FTMs per burst exceeds device limit");
+			return -EINVAL;
+		}
+	}
+
+	if (tb[NL80211_PMSR_FTM_REQ_ATTR_BURST_DURATION])
+		out->ftm.burst_duration =
+			nla_get_u8(tb[NL80211_PMSR_FTM_REQ_ATTR_BURST_DURATION]);
+
+	if (tb[NL80211_PMSR_FTM_REQ_ATTR_MIN_DELTA_FTM])
+		out->ftm.min_delta_ftm =
+			nla_get_u8(tb[NL80211_PMSR_FTM_REQ_ATTR_MIN_DELTA_FTM]);
+
+	if (tb[NL80211_PMSR_FTM_REQ_ATTR_INGRESS])
+		out->ftm.ingress_distance =
+			nla_get_u64(tb[NL80211_PMSR_FTM_REQ_ATTR_INGRESS]);
+
+	if (tb[NL80211_PMSR_FTM_REQ_ATTR_EGRESS])
+		out->ftm.egress_distance =
+			nla_get_u64(tb[NL80211_PMSR_FTM_REQ_ATTR_EGRESS]);
+
+	return 0;
+}
+
 static int pmsr_parse_peer(struct cfg80211_registered_device *rdev,
 			   struct nlattr *peer,
 			   struct cfg80211_pmsr_request_peer *out,
 			   struct genl_info *info)
 {
+	struct wireless_dev *wdev = info->user_ptr[1];
 	struct nlattr *tb[NL80211_PMSR_PEER_ATTR_MAX + 1];
 	struct nlattr *req[NL80211_PMSR_REQ_ATTR_MAX + 1];
 	bool have_measurement_type = false;
@@ -344,6 +441,22 @@ static int pmsr_parse_peer(struct cfg80211_registered_device *rdev,
 				    "FTM: PD request type not supported by device");
 		return -EINVAL;
 	}
+
+	if (out->ftm.request_type == NL80211_PMSR_FTM_REQ_TYPE_NAN) {
+		if (!rdev->wiphy.pmsr_capa->ftm.type.nan_support) {
+			NL_SET_ERR_MSG_ATTR(info->extack,
+					    tb[NL80211_PMSR_PEER_ATTR_REQ_TYPE],
+					    "FTM: NAN ranging not supported by device");
+			return -EOPNOTSUPP;
+		}
+		if (wdev->iftype != NL80211_IFTYPE_NAN) {
+			NL_SET_ERR_MSG_ATTR(info->extack,
+					    tb[NL80211_PMSR_PEER_ATTR_REQ_TYPE],
+					    "FTM: NAN ranging requires a NAN interface");
+			return -EOPNOTSUPP;
+		}
+	}
+
 	/* reuse info->attrs */
 	memset(info->attrs, 0, sizeof(*info->attrs) * (NL80211_ATTR_MAX + 1));
 	err = nla_parse_nested_deprecated(info->attrs, NL80211_ATTR_MAX,
@@ -390,7 +503,12 @@ static int pmsr_parse_peer(struct cfg80211_registered_device *rdev,
 
 		switch (nla_type(treq)) {
 		case NL80211_PMSR_TYPE_FTM:
-			err = pmsr_parse_ftm(rdev, treq, out, info);
+			if (out->ftm.request_type ==
+			    NL80211_PMSR_FTM_REQ_TYPE_NAN)
+				err = pmsr_parse_ftm_nan(rdev, treq,
+							 out, info);
+			else
+				err = pmsr_parse_ftm(rdev, treq, out, info);
 			break;
 		default:
 			NL_SET_ERR_MSG_ATTR(info->extack, treq,
diff --git a/net/wireless/rdev-ops.h b/net/wireless/rdev-ops.h
index ae15cec9bf8b7..e4b57983d5913 100644
--- a/net/wireless/rdev-ops.h
+++ b/net/wireless/rdev-ops.h
@@ -1183,6 +1183,54 @@ static inline void rdev_stop_pd(struct cfg80211_registered_device *rdev,
 	trace_rdev_return_void(&rdev->wiphy);
 }
 
+static inline int
+rdev_nan_ndp_initiate(struct cfg80211_registered_device *rdev,
+		      struct wireless_dev *wdev,
+		      struct cfg80211_nan_ndp_initiate *params)
+{
+	int ret;
+
+	if (!rdev->ops->nan_ndp_initiate)
+		return -EOPNOTSUPP;
+
+	trace_rdev_nan_ndp_initiate(&rdev->wiphy, wdev, params);
+	ret = rdev->ops->nan_ndp_initiate(&rdev->wiphy, wdev, params);
+	trace_rdev_return_int(&rdev->wiphy, ret);
+	return ret;
+}
+
+static inline int
+rdev_nan_ndp_respond(struct cfg80211_registered_device *rdev,
+		     struct wireless_dev *wdev,
+		     struct cfg80211_nan_ndp_respond *params)
+{
+	int ret;
+
+	if (!rdev->ops->nan_ndp_respond)
+		return -EOPNOTSUPP;
+
+	trace_rdev_nan_ndp_respond(&rdev->wiphy, wdev, params);
+	ret = rdev->ops->nan_ndp_respond(&rdev->wiphy, wdev, params);
+	trace_rdev_return_int(&rdev->wiphy, ret);
+	return ret;
+}
+
+static inline int
+rdev_nan_ndp_terminate(struct cfg80211_registered_device *rdev,
+		       struct wireless_dev *wdev,
+		       struct cfg80211_nan_ndp_terminate *params)
+{
+	int ret;
+
+	if (!rdev->ops->nan_ndp_terminate)
+		return -EOPNOTSUPP;
+
+	trace_rdev_nan_ndp_terminate(&rdev->wiphy, wdev, params);
+	ret = rdev->ops->nan_ndp_terminate(&rdev->wiphy, wdev, params);
+	trace_rdev_return_int(&rdev->wiphy, ret);
+	return ret;
+}
+
 static inline int rdev_set_mac_acl(struct cfg80211_registered_device *rdev,
 				   struct net_device *dev,
 				   struct cfg80211_acl_data *params)
diff --git a/net/wireless/trace.h b/net/wireless/trace.h
index 31000ffebe436..fbe3eb69cd147 100644
--- a/net/wireless/trace.h
+++ b/net/wireless/trace.h
@@ -2552,6 +2552,76 @@ TRACE_EVENT(rdev_nan_set_non_evac_channels,
 				__entry->n_channels, sizeof(u32)))
 );
 
+TRACE_EVENT(rdev_nan_ndp_initiate,
+	TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,
+		 struct cfg80211_nan_ndp_initiate *params),
+	TP_ARGS(wiphy, wdev, params),
+	TP_STRUCT__entry(
+		WIPHY_ENTRY
+		WDEV_ENTRY
+		__array(u8, peer_nmi, ETH_ALEN)
+		__field(u8, publish_id)
+	),
+	TP_fast_assign(
+		WIPHY_ASSIGN;
+		WDEV_ASSIGN;
+		memcpy(__entry->peer_nmi, params->peer_nmi, ETH_ALEN);
+		__entry->publish_id = params->publish_id;
+	),
+	TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT
+		  ", peer: %pM, publish_id: %u",
+		  WIPHY_PR_ARG, WDEV_PR_ARG,
+		  __entry->peer_nmi, __entry->publish_id)
+);
+
+TRACE_EVENT(rdev_nan_ndp_respond,
+	TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,
+		 struct cfg80211_nan_ndp_respond *params),
+	TP_ARGS(wiphy, wdev, params),
+	TP_STRUCT__entry(
+		WIPHY_ENTRY
+		WDEV_ENTRY
+		__array(u8, peer_nmi, ETH_ALEN)
+		__field(u8, ndp_id)
+		__field(bool, accept)
+	),
+	TP_fast_assign(
+		WIPHY_ASSIGN;
+		WDEV_ASSIGN;
+		memcpy(__entry->peer_nmi, params->peer_nmi, ETH_ALEN);
+		__entry->ndp_id = params->ndp_id;
+		__entry->accept = params->accept;
+	),
+	TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT
+		  ", peer: %pM, ndp_id: %u, accept: %d",
+		  WIPHY_PR_ARG, WDEV_PR_ARG,
+		  __entry->peer_nmi, __entry->ndp_id, __entry->accept)
+);
+
+TRACE_EVENT(rdev_nan_ndp_terminate,
+	TP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,
+		 struct cfg80211_nan_ndp_terminate *params),
+	TP_ARGS(wiphy, wdev, params),
+	TP_STRUCT__entry(
+		WIPHY_ENTRY
+		WDEV_ENTRY
+		__array(u8, peer_nmi, ETH_ALEN)
+		__field(u8, ndp_id)
+		__field(u8, reason)
+	),
+	TP_fast_assign(
+		WIPHY_ASSIGN;
+		WDEV_ASSIGN;
+		memcpy(__entry->peer_nmi, params->peer_nmi, ETH_ALEN);
+		__entry->ndp_id = params->ndp_id;
+		__entry->reason = params->reason;
+	),
+	TP_printk(WIPHY_PR_FMT ", " WDEV_PR_FMT
+		  ", peer: %pM, ndp_id: %u, reason: %u",
+		  WIPHY_PR_ARG, WDEV_PR_ARG,
+		  __entry->peer_nmi, __entry->ndp_id, __entry->reason)
+);
+
 TRACE_EVENT(rdev_set_mac_acl,
 	TP_PROTO(struct wiphy *wiphy, struct net_device *netdev,
 		 struct cfg80211_acl_data *params),
diff --git a/net/wireless/util.c b/net/wireless/util.c
index 9d5456defc90b..38fd97e8fac71 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -2820,6 +2820,7 @@ void cfg80211_free_nan_func(struct cfg80211_nan_func *f)
 	kfree(f->serv_spec_info);
 	kfree(f->srf_bf);
 	kfree(f->srf_macs);
+	kfree(f->csids);
 	for (i = 0; i < f->num_rx_filters; i++)
 		kfree(f->rx_filters[i].filter);
 

73/3 2026/10/14 16:49 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 36638
							output: 24
							thoughts: 2119
						

Thoughts:
**KMSAN Evaluation: NDP Offload Support in cfg80211/nl80211**

Okay, let's break this down. My goal is to determine if this patch series necessitates a dedicated KMSAN fuzzing session. The basic rule, as I recall, is that if standard kernel bug detectors (KASAN, LOCKDEP, etc.) can catch a bug, there's no need for KMSAN. KMSAN is for catching reads of uninitialized memory, particularly when passing data to userspace.

First, I need to remind myself of the KMSAN triggers. My understanding is that I should consider KMSAN if there are changes involving kernel structures sent to userspace. This involves things like `copy_to_user`, `put_user`, netlink SKB attributes, ioctl output arguments, socket options, or BPF buffers where fields or padding might be uninitialized. Also, KMSAN comes into play for conditional logic that uses uninitialized variables, and the allocation of complex data structures where uninitialized fields could be read later. Conversely, if it's mostly about out-of-bounds access, use-after-free, or locking issues, then standard checks are sufficient.

This patch introduces NAN Data Path (NDP) offload and NAN ranging support in cfg80211/nl80211. My initial assessment is that this is complex. A large number of structs are introduced or modified in `include/net/cfg80211.h`. There are also new commands, attributes, and enums in `include/uapi/linux/nl80211.h`. The main implementation is in `net/wireless/nl80211.c`.

A key area of concern is netlink. I see new attributes and policies, so I need to check how they're handled. Specifically, I'm focusing on the interaction between the kernel and userspace, where uninitialized memory leaks are a concern.

Looking at the code, I see that `nl80211_nan_add_func` parses new attributes into a `func` structure. I need to understand how the allocation of `func` is handled.  I see that `nl80211_nan_match` is used for sending data to userspace. I'll need to examine how the members of `struct cfg80211_nan_match_params` are handled, such as `sdea_ctrl`, `pairing_bootstrap_methods`, `csids`, `ies`, and particularly the `ranging_indication` and `ranging_measurement` fields. These are all passed via `nla_put` calls, so I need to make sure that these are initialized or set before being copied to userspace.

In addition, I'm seeing zero-initialized stack structures in `nl80211_nan_ndp_initiate`, `nl80211_nan_ndp_respond`, and `nl80211_nan_ndp_terminate`. These appear to be good signs, as zero-initialization helps to prevent uninitialized memory issues.

Finally, `cfg80211_nan_ndp_request`, `cfg80211_nan_ndp_confirm`, and `cfg80211_nan_ndp_terminated` are also sending netlink events to userspace, and it is using the structure `params` through `nla_put`. I have to confirm that those params are initialized.

Before I make a final decision, I will need to grep for `cfg80211_nan_match` in the kernel tree to see how it's called by drivers. This will allow me to assess the context in which these structures are being used. This analysis will determine whether or not KMSAN is actually needed.



74/3 2026/10/14 16:49 tool grepper
0m Args:
{
  "Expression": "cfg80211_nan_match"
}

Results:
{
  "Output": "include/net/cfg80211.h=10808=void cfg80211_free_nan_func(struct cfg80211_nan_func *f);\n--\ninclude/net/cfg80211.h-10810-/**\ninclude/net/cfg80211.h:10811: * struct cfg80211_nan_match_params - NAN match parameters\ninclude/net/cfg80211.h-10812- * @type: the type of the function that triggered a match. If it is\n--\ninclude/net/cfg80211.h-10842- */\ninclude/net/cfg80211.h:10843:struct cfg80211_nan_match_params {\ninclude/net/cfg80211.h-10844-\tenum nl80211_nan_function_type type;\n--\ninclude/net/cfg80211.h-10868-/**\ninclude/net/cfg80211.h:10869: * cfg80211_nan_match - report a match for a NAN function.\ninclude/net/cfg80211.h-10870- * @wdev: the wireless device reporting the match\n--\ninclude/net/cfg80211.h-10877- */\ninclude/net/cfg80211.h:10878:void cfg80211_nan_match(struct wireless_dev *wdev,\ninclude/net/cfg80211.h:10879:\t\t\tstruct cfg80211_nan_match_params *match, gfp_t gfp);\ninclude/net/cfg80211.h-10880-\n--\ninclude/net/mac80211.h=7982=void ieee80211_nan_func_match(struct ieee80211_vif *vif,\ninclude/net/mac80211.h:7983:\t\t\t      struct cfg80211_nan_match_params *match,\ninclude/net/mac80211.h-7984-\t\t\t      gfp_t gfp);\n--\nnet/mac80211/cfg.c=5582=void ieee80211_nan_func_match(struct ieee80211_vif *vif,\nnet/mac80211/cfg.c:5583:\t\t\t      struct cfg80211_nan_match_params *match,\nnet/mac80211/cfg.c-5584-\t\t\t      gfp_t gfp)\n--\nnet/mac80211/cfg.c-5606-\nnet/mac80211/cfg.c:5607:\tcfg80211_nan_match(ieee80211_vif_to_wdev(vif), match, gfp);\nnet/mac80211/cfg.c-5608-}\n--\nnet/wireless/nl80211.c=17932=static int nl80211_stop_pd(struct sk_buff *skb, struct genl_info *info)\n--\nnet/wireless/nl80211.c-17944-\nnet/wireless/nl80211.c:17945:void cfg80211_nan_match(struct wireless_dev *wdev,\nnet/wireless/nl80211.c:17946:\t\t\tstruct cfg80211_nan_match_params *match, gfp_t gfp)\nnet/wireless/nl80211.c-17947-{\n--\nnet/wireless/nl80211.c-18077-}\nnet/wireless/nl80211.c:18078:EXPORT_SYMBOL(cfg80211_nan_match);\nnet/wireless/nl80211.c-18079-\n"
}

75/3 2026/10/14 16:49 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 40658
							output: 27
							thoughts: 43
						

Thoughts:
Okay, here's my take on those thoughts, tailored for an expert audience:

**Diving into the NAN Function Matching**

Alright, I need to understand this NAN function matching logic more deeply. My initial thought is to zero in on `net/mac80211/cfg.c` around line 5582. That's a reasonable starting point, especially considering the likely involvement of configuration or regulatory-related aspects of the driver. I expect that line to be the entry point or a core function relating to this NAN functionality.

More specifically, I'm immediately interested in the callers of `ieee80211_nan_func_match`. It's crucial to understand *how* and *when* this function is being invoked, and what context is passed into it. I'll need to trace those calls to fully grasp the control flow. The calling context will likely reveal critical information about the parameters used to perform matching and what is considered a "match." That will be key. This likely indicates important regulatory aspects related to NAN usage.



76/3 2026/10/14 16:49 tool grepper
0m Args:
{
  "Expression": "ieee80211_nan_func_match"
}

Results:
{
  "Output": "include/net/mac80211.h=7966=void ieee80211_nan_func_terminated(struct ieee80211_vif *vif,\n--\ninclude/net/mac80211.h-7971-/**\ninclude/net/mac80211.h:7972: * ieee80211_nan_func_match - notify about NAN function match event.\ninclude/net/mac80211.h-7973- *\n--\ninclude/net/mac80211.h-7981- */\ninclude/net/mac80211.h:7982:void ieee80211_nan_func_match(struct ieee80211_vif *vif,\ninclude/net/mac80211.h-7983-\t\t\t      struct cfg80211_nan_match_params *match,\n--\nnet/mac80211/cfg.c=5580=EXPORT_SYMBOL(ieee80211_nan_func_terminated);\nnet/mac80211/cfg.c-5581-\nnet/mac80211/cfg.c:5582:void ieee80211_nan_func_match(struct ieee80211_vif *vif,\nnet/mac80211/cfg.c-5583-\t\t\t      struct cfg80211_nan_match_params *match,\n--\nnet/mac80211/cfg.c-5608-}\nnet/mac80211/cfg.c:5609:EXPORT_SYMBOL(ieee80211_nan_func_match);\nnet/mac80211/cfg.c-5610-\n"
}

77/3 2026/10/14 16:49 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 41426
							output: 65
							thoughts: 34
						

Thoughts:
Okay, here's my take on those thoughts, tailored for an expert audience:

**Analyzing NAN Matching Function Calls**

Alright, let's dive in. My immediate thought is, "who's *using* `cfg80211_nan_match` or `ieee80211_nan_func_match`?" These functions are core to Network Awareness Networking (NAN) functionality, specifically in the context of 802.11 standards, so I need to understand their integration. I'm not just looking for the simple call sites; I'm trying to map out the *purpose* of those calls. Are we talking about discovery, advertisement matching, service discovery, or something more nuanced within the NAN protocol state machine? Knowing *why* those functions are being invoked will paint a clearer picture of the NAN implementation's current state and expected behavior. I need to trace the control flow back from those calls, understanding the arguments passed and the data structures manipulated. Are there any unusual or potentially performance-bottlenecking patterns? Are there race conditions that could come into play with these matches? I'll probably start with a static analysis to get a quick overview and then move to dynamic analysis, probably using tracing, to fully understand the execution. Ultimately, I'm looking for the "so what?" – what's the broader architectural implication of these calls, and are they aligned with the intended NAN design and standards compliance?



78/3 2026/10/14 16:50 tool grepper
0m Args:
{
  "Expression": "(cfg80211_nan_match|ieee80211_nan_func_match)",
  "PathPrefixes": [
    "drivers/net/wireless/",
    "net/mac80211/"
  ]
}

Results:
{
  "Output": "net/mac80211/cfg.c=5580=EXPORT_SYMBOL(ieee80211_nan_func_terminated);\nnet/mac80211/cfg.c-5581-\nnet/mac80211/cfg.c:5582:void ieee80211_nan_func_match(struct ieee80211_vif *vif,\nnet/mac80211/cfg.c:5583:\t\t\t      struct cfg80211_nan_match_params *match,\nnet/mac80211/cfg.c-5584-\t\t\t      gfp_t gfp)\n--\nnet/mac80211/cfg.c-5606-\nnet/mac80211/cfg.c:5607:\tcfg80211_nan_match(ieee80211_vif_to_wdev(vif), match, gfp);\nnet/mac80211/cfg.c-5608-}\nnet/mac80211/cfg.c:5609:EXPORT_SYMBOL(ieee80211_nan_func_match);\nnet/mac80211/cfg.c-5610-\n"
}

79/3 2026/10/14 16:50 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 42161
							output: 42
							thoughts: 86
						

Thoughts:
**Examining the NAN Add Function in nl80211.c**

Okay, so I haven't seen any driver implementations utilizing this yet, or perhaps they're using out-of-tree patches, or maybe this feature is slated for a future release. Either way, it's worth a look. Let's delve into `nl80211_nan_add_func` in `net/wireless/nl80211.c`. I'll focus on lines 17440 through 17560. Time to dissect the code and see what's going on under the hood with this NAN add function. I'm keen to see the parameters being handled, the data structures being populated, and the overall flow of this function. Let's get to it!



80/3 2026/10/14 16:50 tool read-file
0m Args:
{
  "File": "net/wireless/nl80211.c",
  "FirstLine": 17445,
  "LineCount": 90
}

Results:
{
  "Contents": "17445:\t\tif (!wdev_running(wdev))\n17446:\t\t\treturn -ENOTCONN;\n17447:\t\n17448:\t\tif (wdev-\u003ewiphy-\u003enan_capa.flags \u0026 WIPHY_NAN_FLAGS_USERSPACE_DE) {\n17449:\t\t\tNL_SET_ERR_MSG(info-\u003eextack,\n17450:\t\t\t\t       \"NAN Discovery Engine is in userspace\");\n17451:\t\t\treturn -EOPNOTSUPP;\n17452:\t\t}\n17453:\t\n17454:\t\tif (!info-\u003eattrs[NL80211_ATTR_NAN_FUNC])\n17455:\t\t\treturn -EINVAL;\n17456:\t\n17457:\t\terr = nla_parse_nested_deprecated(tb, NL80211_NAN_FUNC_ATTR_MAX,\n17458:\t\t\t\t\t\t  info-\u003eattrs[NL80211_ATTR_NAN_FUNC],\n17459:\t\t\t\t\t\t  nl80211_nan_func_policy,\n17460:\t\t\t\t\t\t  info-\u003eextack);\n17461:\t\tif (err)\n17462:\t\t\treturn err;\n17463:\t\n17464:\t\tfunc = kzalloc_obj(*func);\n17465:\t\tif (!func)\n17466:\t\t\treturn -ENOMEM;\n17467:\t\n17468:\t\tfunc-\u003ecookie = cfg80211_assign_cookie(rdev);\n17469:\t\n17470:\t\tif (!tb[NL80211_NAN_FUNC_TYPE]) {\n17471:\t\t\terr = -EINVAL;\n17472:\t\t\tgoto out;\n17473:\t\t}\n17474:\t\n17475:\t\n17476:\t\tfunc-\u003etype = nla_get_u8(tb[NL80211_NAN_FUNC_TYPE]);\n17477:\t\n17478:\t\tif (!tb[NL80211_NAN_FUNC_SERVICE_ID]) {\n17479:\t\t\terr = -EINVAL;\n17480:\t\t\tgoto out;\n17481:\t\t}\n17482:\t\n17483:\t\tmemcpy(func-\u003eservice_id, nla_data(tb[NL80211_NAN_FUNC_SERVICE_ID]),\n17484:\t\t       sizeof(func-\u003eservice_id));\n17485:\t\n17486:\t\tfunc-\u003eclose_range =\n17487:\t\t\tnla_get_flag(tb[NL80211_NAN_FUNC_CLOSE_RANGE]);\n17488:\t\n17489:\t\tif (tb[NL80211_NAN_FUNC_SERVICE_INFO]) {\n17490:\t\t\tfunc-\u003eserv_spec_info_len =\n17491:\t\t\t\tnla_len(tb[NL80211_NAN_FUNC_SERVICE_INFO]);\n17492:\t\t\tfunc-\u003eserv_spec_info =\n17493:\t\t\t\tkmemdup(nla_data(tb[NL80211_NAN_FUNC_SERVICE_INFO]),\n17494:\t\t\t\t\tfunc-\u003eserv_spec_info_len,\n17495:\t\t\t\t\tGFP_KERNEL);\n17496:\t\t\tif (!func-\u003eserv_spec_info) {\n17497:\t\t\t\terr = -ENOMEM;\n17498:\t\t\t\tgoto out;\n17499:\t\t\t}\n17500:\t\t}\n17501:\t\n17502:\t\tif (tb[NL80211_NAN_FUNC_TTL])\n17503:\t\t\tfunc-\u003ettl = nla_get_u32(tb[NL80211_NAN_FUNC_TTL]);\n17504:\t\n17505:\t\tswitch (func-\u003etype) {\n17506:\t\tcase NL80211_NAN_FUNC_PUBLISH:\n17507:\t\t\tif (!tb[NL80211_NAN_FUNC_PUBLISH_TYPE]) {\n17508:\t\t\t\terr = -EINVAL;\n17509:\t\t\t\tgoto out;\n17510:\t\t\t}\n17511:\t\n17512:\t\t\tfunc-\u003epublish_type =\n17513:\t\t\t\tnla_get_u8(tb[NL80211_NAN_FUNC_PUBLISH_TYPE]);\n17514:\t\t\tfunc-\u003epublish_bcast =\n17515:\t\t\t\tnla_get_flag(tb[NL80211_NAN_FUNC_PUBLISH_BCAST]);\n17516:\t\n17517:\t\t\tif ((!(func-\u003epublish_type \u0026 NL80211_NAN_SOLICITED_PUBLISH)) \u0026\u0026\n17518:\t\t\t\tfunc-\u003epublish_bcast) {\n17519:\t\t\t\terr = -EINVAL;\n17520:\t\t\t\tgoto out;\n17521:\t\t\t}\n17522:\t\t\tbreak;\n17523:\t\tcase NL80211_NAN_FUNC_SUBSCRIBE:\n17524:\t\t\tfunc-\u003esubscribe_active =\n17525:\t\t\t\tnla_get_flag(tb[NL80211_NAN_FUNC_SUBSCRIBE_ACTIVE]);\n17526:\t\t\tbreak;\n17527:\t\tcase NL80211_NAN_FUNC_FOLLOW_UP:\n17528:\t\t\tif (!tb[NL80211_NAN_FUNC_FOLLOW_UP_ID] ||\n17529:\t\t\t    !tb[NL80211_NAN_FUNC_FOLLOW_UP_REQ_ID] ||\n17530:\t\t\t    !tb[NL80211_NAN_FUNC_FOLLOW_UP_DEST]) {\n17531:\t\t\t\terr = -EINVAL;\n17532:\t\t\t\tgoto out;\n17533:\t\t\t}\n17534:\t\n"
}

81/3 2026/10/14 16:50 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 44035
							output: 42
							thoughts: 759
						

Thoughts:
**Analyzing the NAN Function Addition in nl80211**

Okay, so I'm looking at this `kzalloc_obj(*func)` call first – that's expected; it zeros out the memory allocated for the new NAN function. Then, I need to understand what happens during the attribute parsing within `nl80211_nan_add_func`. The patch diff is key here.

First, I'm checking the `NL80211_NAN_FUNC_CSIDS` attribute handling.  It checks if the attribute exists, calculates the expected number of CSIDs, and verifies that the provided data is correctly aligned. The code then uses `kmemdup` to copy the provided CSIDs.  Importantly, I see that `cfg80211_free_nan_func` now includes a `kfree(f->csids)` to free the allocated memory. Good, proper memory management.

Now, I'm moving on to `NL80211_NAN_FUNC_CHAN`. Here, the code seems to be reusing `info->attrs` to parse the channel definition. Okay, `memset(info->attrs, 0, sizeof(*info->attrs) * (NL80211_ATTR_MAX + 1));` – wait a second.  It's zeroing `info->attrs`. That's interesting... why would it be zeroing it? And what exactly *is* `info->attrs`? Does this mean `nl80211_nan_add_func` does *not* need `info->attrs` later, since it's being cleared? If it *does* need it, then there's a problem here. I need to trace this further. I'm going to look at the surrounding code to determine how this attribute structure, `info->attrs`, is used later within the function to establish its potential re-use. Let me jump to line 17750 in `net/wireless/nl80211.c` to see how things are set up and used.



82/3 2026/10/14 16:50 tool read-file
0m Args:
{
  "File": "net/wireless/nl80211.c",
  "FirstLine": 17810,
  "LineCount": 50
}

Results:
{
  "Contents": "17810:\t\t}\n17811:\t\n17812:\t\tmsg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);\n17813:\t\tif (!msg) {\n17814:\t\t\terr = -ENOMEM;\n17815:\t\t\tgoto out;\n17816:\t\t}\n17817:\t\n17818:\t\thdr = nl80211hdr_put(msg, info-\u003esnd_portid, info-\u003esnd_seq, 0,\n17819:\t\t\t\t     NL80211_CMD_ADD_NAN_FUNCTION);\n17820:\t\t/* This can't really happen - we just allocated 4KB */\n17821:\t\tif (WARN_ON(!hdr)) {\n17822:\t\t\terr = -ENOMEM;\n17823:\t\t\tgoto out;\n17824:\t\t}\n17825:\t\n17826:\t\terr = rdev_add_nan_func(rdev, wdev, func);\n17827:\tout:\n17828:\t\tif (err \u003c 0) {\n17829:\t\t\tcfg80211_free_nan_func(func);\n17830:\t\t\tnlmsg_free(msg);\n17831:\t\t\treturn err;\n17832:\t\t}\n17833:\t\n17834:\t\t/* propagate the instance id and cookie to userspace  */\n17835:\t\tif (nla_put_u64_64bit(msg, NL80211_ATTR_COOKIE, func-\u003ecookie,\n17836:\t\t\t\t      NL80211_ATTR_PAD))\n17837:\t\t\tgoto nla_put_failure;\n17838:\t\n17839:\t\tfunc_attr = nla_nest_start_noflag(msg, NL80211_ATTR_NAN_FUNC);\n17840:\t\tif (!func_attr)\n17841:\t\t\tgoto nla_put_failure;\n17842:\t\n17843:\t\tif (nla_put_u8(msg, NL80211_NAN_FUNC_INSTANCE_ID,\n17844:\t\t\t       func-\u003einstance_id))\n17845:\t\t\tgoto nla_put_failure;\n17846:\t\n17847:\t\tnla_nest_end(msg, func_attr);\n17848:\t\n17849:\t\tgenlmsg_end(msg, hdr);\n17850:\t\treturn genlmsg_reply(msg, info);\n17851:\t\n17852:\tnla_put_failure:\n17853:\t\tnlmsg_free(msg);\n17854:\t\treturn -ENOBUFS;\n17855:\t}\n17856:\t\n17857:\tstatic int nl80211_nan_del_func(struct sk_buff *skb,\n17858:\t\t\t\t       struct genl_info *info)\n17859:\t{\n"
}

83/3 2026/10/14 16:50 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 46106
							output: 41
							thoughts: 1492
						

Thoughts:
**Uninitialized Memory Risk Assessment**

Okay, so I'm looking at this code and I've noticed something that could potentially be a problem. The `info->attrs` field isn't used after a certain point in the code, and it's also re-used in other parts of `nl80211.c`, specifically in `pmsr_parse_peer` where it's re-initialized with `memset`. This has got me thinking about potential uninitialized memory risks, so I need to go through it carefully.

I need to make sure I don't introduce a flaw with this change. Time for a checklist! I need to evaluate this change based on these four criteria:

1.  Does the patch introduce or modify kernel structures sent to user space (via various methods like `copy_to_user`, `put_user`, netlink SKB attributes, ioctl output, socket options, or BPF buffers), where fields or structure padding might be uninitialized?
2.  Does the patch involve conditional logic or branching that relies on potentially uninitialized variables or struct fields?
3.  Does the patch include allocation or initialization of complex data structures where uninitialized fields could be read later in reachable code paths?
4.  Does the patch affect bounds checks, lengths, or logic in a way that allows surrounding code to access uninitialized bytes of existing buffers?

Let's start looking at the places where data is copied or sent to userspace, or where new structs are created.

First up, `nl80211_send_pmsr_ftm_capa`.  Here's the relevant code:

```c
+		if (cap->ftm.type.nan_support &&
+		    nla_put_flag(msg, NL80211_PMSR_FTM_TYPE_CAPA_ATTR_NAN_SUPPORT))
+			return -ENOBUFS;
```

This looks safe. We're just dealing with a flag attribute which is binary, so no uninitialized memory here.

Next is `nl80211_put_nan_capa`:

```c
+	if ((wiphy->nan_capa.flags & WIPHY_NAN_FLAGS_OFFLOAD_RANGING) &&
+	    nla_put_flag(msg, NL80211_NAN_CAPA_OFFLOAD_RANGING))
+		goto fail;
+
+	if ((wiphy->nan_capa.flags & WIPHY_NAN_FLAGS_OFFLOAD_NDP) &&
+	    nla_put_flag(msg, NL80211_NAN_CAPA_OFFLOAD_NDP))
+		goto fail;
```

Again, this just deals with flag attributes, so no risk here.

Then we have `cfg80211_nan_match`:

```c
+	if (match->sdea_ctrl &&
+	    nla_put_u16(msg, NL80211_NAN_MATCH_SDEA_CTRL, match->sdea_ctrl))
+		goto nla_put_failure;
+
+	if (match->pairing_bootstrap_methods &&
+	    nla_put_u16(msg, NL80211_NAN_MATCH_BOOTSTRAP_METHODS,
+			match->pairing_bootstrap_methods))
+		goto nla_put_failure;
+
+	if (match->csids && match->num_csids &&
+	    nla_put(msg, NL80211_NAN_MATCH_CIPHER_SUITES,
+		    match->num_csids * sizeof(u32),
+		    match->csids))
+		goto nla_put_failure;
+
+	if (match->pairing_setup &&
+	    nla_put_flag(msg, NL80211_NAN_MATCH_PAIRING_SETUP))
+		goto nla_put_failure;
+
+	if (match->pairing_cache &&
+	    nla_put_flag(msg, NL80211_NAN_MATCH_PAIRING_CACHE))
+		goto nla_put_failure;
+
+	if (match->pairing_verify &&
+	    nla_put_flag(msg, NL80211_NAN_MATCH_PAIRING_VERIFY))
+		goto nla_put_failure;
+
+	if (match->extra_info && match->


84/3 2026/10/14 16:50 tool read-file
0m Args:
{
  "File": "net/mac80211/cfg.c",
  "FirstLine": 5575,
  "LineCount": 45
}

Results:
{
  "Contents": "5575:\t\tcfg80211_free_nan_func(func);\n5576:\t\n5577:\t\tcfg80211_nan_func_terminated(ieee80211_vif_to_wdev(vif), inst_id,\n5578:\t\t\t\t\t     reason, cookie, gfp);\n5579:\t}\n5580:\tEXPORT_SYMBOL(ieee80211_nan_func_terminated);\n5581:\t\n5582:\tvoid ieee80211_nan_func_match(struct ieee80211_vif *vif,\n5583:\t\t\t\t      struct cfg80211_nan_match_params *match,\n5584:\t\t\t\t      gfp_t gfp)\n5585:\t{\n5586:\t\tstruct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);\n5587:\t\tstruct cfg80211_nan_func *func;\n5588:\t\n5589:\t\tif (WARN_ON(vif-\u003etype != NL80211_IFTYPE_NAN))\n5590:\t\t\treturn;\n5591:\t\n5592:\t\tif (WARN_ON(sdata-\u003elocal-\u003ehw.wiphy-\u003enan_capa.flags \u0026\n5593:\t\t\t    WIPHY_NAN_FLAGS_USERSPACE_DE))\n5594:\t\t\treturn;\n5595:\t\n5596:\t\tspin_lock_bh(\u0026sdata-\u003eu.nan.de.func_lock);\n5597:\t\n5598:\t\tfunc = idr_find(\u0026sdata-\u003eu.nan.de.function_inst_ids,  match-\u003einst_id);\n5599:\t\tif (WARN_ON(!func)) {\n5600:\t\t\tspin_unlock_bh(\u0026sdata-\u003eu.nan.de.func_lock);\n5601:\t\t\treturn;\n5602:\t\t}\n5603:\t\tmatch-\u003ecookie = func-\u003ecookie;\n5604:\t\n5605:\t\tspin_unlock_bh(\u0026sdata-\u003eu.nan.de.func_lock);\n5606:\t\n5607:\t\tcfg80211_nan_match(ieee80211_vif_to_wdev(vif), match, gfp);\n5608:\t}\n5609:\tEXPORT_SYMBOL(ieee80211_nan_func_match);\n5610:\t\n5611:\tvoid ieee80211_nan_cluster_joined(struct ieee80211_vif *vif,\n5612:\t\t\t\t\t  const u8 *cluster_id, bool new_cluster,\n5613:\t\t\t\t\t  gfp_t gfp)\n5614:\t{\n5615:\t\tstruct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);\n5616:\t\n5617:\t\tif (WARN_ON(vif-\u003etype != NL80211_IFTYPE_NAN))\n5618:\t\t\treturn;\n5619:\t\n"
}

85/3 2026/10/14 16:50 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 49498
							output: 19
							thoughts: 29
						

Thoughts:
Okay, here's my take on those thoughts, tailored for an expert audience:

**Investigating the Callers of `ieee80211_nan_func_match`**

Alright, so `ieee80211_nan_func_match`… that function name rings a bell. But *who* is actually using it? I need to quickly establish the call graph to understand its role within the NAN (Neighbor Awareness Networking) context, and potentially trace a bug. Jumping into the code with a debugger might be the next logical step, but first, let's establish all the callers. A quick `grep` across the entire source tree is the most efficient way to get a bird's-eye view. I'll need to be mindful of case sensitivity, and maybe even use some regular expression magic to catch variations in naming (e.g., potential uses with a struct member, or a prefixed namespace). Knowing the calling context is key.



86/3 2026/10/14 16:50 tool grepper
0m Args:
{
  "Expression": "nan_func_match"
}

Results:
{
  "Output": "include/net/mac80211.h=7966=void ieee80211_nan_func_terminated(struct ieee80211_vif *vif,\n--\ninclude/net/mac80211.h-7971-/**\ninclude/net/mac80211.h:7972: * ieee80211_nan_func_match - notify about NAN function match event.\ninclude/net/mac80211.h-7973- *\n--\ninclude/net/mac80211.h-7981- */\ninclude/net/mac80211.h:7982:void ieee80211_nan_func_match(struct ieee80211_vif *vif,\ninclude/net/mac80211.h-7983-\t\t\t      struct cfg80211_nan_match_params *match,\n--\nnet/mac80211/cfg.c=5580=EXPORT_SYMBOL(ieee80211_nan_func_terminated);\nnet/mac80211/cfg.c-5581-\nnet/mac80211/cfg.c:5582:void ieee80211_nan_func_match(struct ieee80211_vif *vif,\nnet/mac80211/cfg.c-5583-\t\t\t      struct cfg80211_nan_match_params *match,\n--\nnet/mac80211/cfg.c-5608-}\nnet/mac80211/cfg.c:5609:EXPORT_SYMBOL(ieee80211_nan_func_match);\nnet/mac80211/cfg.c-5610-\n"
}

87/3 2026/10/14 16:50 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 50223
							output: 26
							thoughts: 84
						

Thoughts:
Okay, let me think this through.

**Investigating NAN Function Calls in the Wireless Subsystem**

Hmm, it seems like *no* in-tree drivers directly utilize `ieee80211_nan_func_match`, which is interesting. Wait a minute... that doesn't feel right. My brain is telling me to double-check something, and it's nagging at the back of my head. Are there other related functions, perhaps higher-level ones, that *might* be relevant? Oh yeah! What about the `cfg80211` counterparts related to NAN NDP operations, specifically `cfg80211_nan_ndp_request`, `cfg80211_nan_ndp_confirm`, and `cfg80211_nan_ndp_terminated`? They sound like they should be investigated too. I need to see if *anything* within the system calls those functions before I can be sure I have the whole picture, so let's run a quick search and make sure I haven't missed anything important!



88/3 2026/10/14 16:50 tool grepper
0m Args:
{
  "Expression": "cfg80211_nan_ndp_"
}

Results:
{
  "Output": "include/net/cfg80211.h=4325=struct cfg80211_nan_peer_sched {\n--\ninclude/net/cfg80211.h-4337-/**\ninclude/net/cfg80211.h:4338: * struct cfg80211_nan_ndp_initiate - NAN NDP initiate parameters\ninclude/net/cfg80211.h-4339- *\n--\ninclude/net/cfg80211.h-4361- */\ninclude/net/cfg80211.h:4362:struct cfg80211_nan_ndp_initiate {\ninclude/net/cfg80211.h-4363-\tconst u8 *peer_nmi;\n--\ninclude/net/cfg80211.h-4381-/**\ninclude/net/cfg80211.h:4382: * struct cfg80211_nan_ndp_respond - NAN NDP respond parameters\ninclude/net/cfg80211.h-4383- *\n--\ninclude/net/cfg80211.h-4404- */\ninclude/net/cfg80211.h:4405:struct cfg80211_nan_ndp_respond {\ninclude/net/cfg80211.h-4406-\tconst u8 *peer_nmi;\n--\ninclude/net/cfg80211.h-4424-/**\ninclude/net/cfg80211.h:4425: * struct cfg80211_nan_ndp_terminate - NAN NDP terminate parameters\ninclude/net/cfg80211.h-4426- *\n--\ninclude/net/cfg80211.h-4431- */\ninclude/net/cfg80211.h:4432:struct cfg80211_nan_ndp_terminate {\ninclude/net/cfg80211.h-4433-\tconst u8 *peer_nmi;\n--\ninclude/net/cfg80211.h-4439-/**\ninclude/net/cfg80211.h:4440: * struct cfg80211_nan_ndp_request_params - NAN NDP request event parameters\ninclude/net/cfg80211.h-4441- *\n--\ninclude/net/cfg80211.h-4460- */\ninclude/net/cfg80211.h:4461:struct cfg80211_nan_ndp_request_params {\ninclude/net/cfg80211.h-4462-\tconst u8 *peer_nmi;\n--\ninclude/net/cfg80211.h-4477-/**\ninclude/net/cfg80211.h:4478: * struct cfg80211_nan_ndp_confirm_params - NAN NDP confirm event parameters\ninclude/net/cfg80211.h-4479- *\n--\ninclude/net/cfg80211.h-4494- */\ninclude/net/cfg80211.h:4495:struct cfg80211_nan_ndp_confirm_params {\ninclude/net/cfg80211.h-4496-\tconst u8 *peer_nmi;\n--\ninclude/net/cfg80211.h-4508-/**\ninclude/net/cfg80211.h:4509: * struct cfg80211_nan_ndp_terminated_params - NAN NDP terminated event\ninclude/net/cfg80211.h-4510- *\n--\ninclude/net/cfg80211.h-4515- */\ninclude/net/cfg80211.h:4516:struct cfg80211_nan_ndp_terminated_params {\ninclude/net/cfg80211.h-4517-\tconst u8 *peer_nmi;\n--\ninclude/net/cfg80211.h=5582=struct cfg80211_ops {\n--\ninclude/net/cfg80211.h-5916-\t\t\t\t    struct wireless_dev *wdev,\ninclude/net/cfg80211.h:5917:\t\t\t\t    struct cfg80211_nan_ndp_initiate *params);\ninclude/net/cfg80211.h-5918-\tint\t(*nan_ndp_respond)(struct wiphy *wiphy,\ninclude/net/cfg80211.h-5919-\t\t\t\t   struct wireless_dev *wdev,\ninclude/net/cfg80211.h:5920:\t\t\t\t   struct cfg80211_nan_ndp_respond *params);\ninclude/net/cfg80211.h-5921-\tint\t(*nan_ndp_terminate)(struct wiphy *wiphy,\ninclude/net/cfg80211.h-5922-\t\t\t\t     struct wireless_dev *wdev,\ninclude/net/cfg80211.h:5923:\t\t\t\t     struct cfg80211_nan_ndp_terminate *params);\ninclude/net/cfg80211.h-5924-\tint\t(*set_multicast_to_unicast)(struct wiphy *wiphy,\n--\ninclude/net/cfg80211.h=11376=cfg80211_s1g_get_primary_sibling(struct wiphy *wiphy,\n--\ninclude/net/cfg80211.h-11401-/**\ninclude/net/cfg80211.h:11402: * cfg80211_nan_ndp_request - notify userspace of a received NDP request\ninclude/net/cfg80211.h-11403- * @wdev: the wireless device reporting the event\n--\ninclude/net/cfg80211.h-11409- */\ninclude/net/cfg80211.h:11410:void cfg80211_nan_ndp_request(struct wireless_dev *wdev,\ninclude/net/cfg80211.h:11411:\t\t\t      struct cfg80211_nan_ndp_request_params *params,\ninclude/net/cfg80211.h-11412-\t\t\t      gfp_t gfp);\n--\ninclude/net/cfg80211.h-11414-/**\ninclude/net/cfg80211.h:11415: * cfg80211_nan_ndp_confirm - notify userspace that NDP setup is complete\ninclude/net/cfg80211.h-11416- * @wdev: the wireless device reporting the event\n--\ninclude/net/cfg80211.h-11423- */\ninclude/net/cfg80211.h:11424:void cfg80211_nan_ndp_confirm(struct wireless_dev *wdev,\ninclude/net/cfg80211.h:11425:\t\t\t      struct cfg80211_nan_ndp_confirm_params *params,\ninclude/net/cfg80211.h-11426-\t\t\t      gfp_t gfp);\n--\ninclude/net/cfg80211.h-11428-/**\ninclude/net/cfg80211.h:11429: * cfg80211_nan_ndp_terminated - notify userspace that an NDP was terminated\ninclude/net/cfg80211.h-11430- * @wdev: the wireless device reporting the event\n--\ninclude/net/cfg80211.h-11436- */\ninclude/net/cfg80211.h:11437:void cfg80211_nan_ndp_terminated(struct wireless_dev *wdev,\ninclude/net/cfg80211.h:11438:\t\t\t\t struct cfg80211_nan_ndp_terminated_params *params,\ninclude/net/cfg80211.h-11439-\t\t\t\t gfp_t gfp);\n--\nnet/wireless/nl80211.c=18504=static int nl80211_nan_ndp_initiate(struct sk_buff *skb,\n--\nnet/wireless/nl80211.c-18509-\tstruct nlattr *tb[NL80211_NAN_NDP_ATTR_MAX + 1];\nnet/wireless/nl80211.c:18510:\tstruct cfg80211_nan_ndp_initiate params = {};\nnet/wireless/nl80211.c-18511-\tint err;\n--\nnet/wireless/nl80211.c=18629=static int nl80211_nan_ndp_respond(struct sk_buff *skb,\n--\nnet/wireless/nl80211.c-18634-\tstruct nlattr *tb[NL80211_NAN_NDP_ATTR_MAX + 1];\nnet/wireless/nl80211.c:18635:\tstruct cfg80211_nan_ndp_respond params = {};\nnet/wireless/nl80211.c-18636-\tint err;\n--\nnet/wireless/nl80211.c=18750=static int nl80211_nan_ndp_terminate(struct sk_buff *skb,\n--\nnet/wireless/nl80211.c-18755-\tstruct nlattr *tb[NL80211_NAN_NDP_ATTR_MAX + 1];\nnet/wireless/nl80211.c:18756:\tstruct cfg80211_nan_ndp_terminate params = {};\nnet/wireless/nl80211.c-18757-\tint err;\n--\nnet/wireless/nl80211.c-18801-\nnet/wireless/nl80211.c:18802:void cfg80211_nan_ndp_request(struct wireless_dev *wdev,\nnet/wireless/nl80211.c:18803:\t\t\t      struct cfg80211_nan_ndp_request_params *params,\nnet/wireless/nl80211.c-18804-\t\t\t      gfp_t gfp)\n--\nnet/wireless/nl80211.c-18878-}\nnet/wireless/nl80211.c:18879:EXPORT_SYMBOL(cfg80211_nan_ndp_request);\nnet/wireless/nl80211.c-18880-\nnet/wireless/nl80211.c:18881:void cfg80211_nan_ndp_confirm(struct wireless_dev *wdev,\nnet/wireless/nl80211.c:18882:\t\t\t      struct cfg80211_nan_ndp_confirm_params *params,\nnet/wireless/nl80211.c-18883-\t\t\t      gfp_t gfp)\n--\nnet/wireless/nl80211.c-18952-}\nnet/wireless/nl80211.c:18953:EXPORT_SYMBOL(cfg80211_nan_ndp_confirm);\nnet/wireless/nl80211.c-18954-\nnet/wireless/nl80211.c:18955:void cfg80211_nan_ndp_terminated(struct wireless_dev *wdev,\nnet/wireless/nl80211.c:18956:\t\t\t\t struct cfg80211_nan_ndp_terminated_params *params,\nnet/wireless/nl80211.c-18957-\t\t\t\t gfp_t gfp)\n--\nnet/wireless/nl80211.c-19002-}\nnet/wireless/nl80211.c:19003:EXPORT_SYMBOL(cfg80211_nan_ndp_terminated);\nnet/wireless/nl80211.c-19004-\n--\nnet/wireless/rdev-ops.h=1187=rdev_nan_ndp_initiate(struct cfg80211_registered_device *rdev,\nnet/wireless/rdev-ops.h-1188-\t\t      struct wireless_dev *wdev,\nnet/wireless/rdev-ops.h:1189:\t\t      struct cfg80211_nan_ndp_initiate *params)\nnet/wireless/rdev-ops.h-1190-{\n--\nnet/wireless/rdev-ops.h=1203=rdev_nan_ndp_respond(struct cfg80211_registered_device *rdev,\nnet/wireless/rdev-ops.h-1204-\t\t     struct wireless_dev *wdev,\nnet/wireless/rdev-ops.h:1205:\t\t     struct cfg80211_nan_ndp_respond *params)\nnet/wireless/rdev-ops.h-1206-{\n--\nnet/wireless/rdev-ops.h=1219=rdev_nan_ndp_terminate(struct cfg80211_registered_device *rdev,\nnet/wireless/rdev-ops.h-1220-\t\t       struct wireless_dev *wdev,\nnet/wireless/rdev-ops.h:1221:\t\t       struct cfg80211_nan_ndp_terminate *params)\nnet/wireless/rdev-ops.h-1222-{\n--\nnet/wireless/trace.h=2555=TRACE_EVENT(rdev_nan_ndp_initiate,\nnet/wireless/trace.h-2556-\tTP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,\nnet/wireless/trace.h:2557:\t\t struct cfg80211_nan_ndp_initiate *params),\nnet/wireless/trace.h-2558-\tTP_ARGS(wiphy, wdev, params),\n--\nnet/wireless/trace.h=2577=TRACE_EVENT(rdev_nan_ndp_respond,\nnet/wireless/trace.h-2578-\tTP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,\nnet/wireless/trace.h:2579:\t\t struct cfg80211_nan_ndp_respond *params),\nnet/wireless/trace.h-2580-\tTP_ARGS(wiphy, wdev, params),\n--\nnet/wireless/trace.h=2601=TRACE_EVENT(rdev_nan_ndp_terminate,\nnet/wireless/trace.h-2602-\tTP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,\nnet/wireless/trace.h:2603:\t\t struct cfg80211_nan_ndp_terminate *params),\nnet/wireless/trace.h-2604-\tTP_ARGS(wiphy, wdev, params),\n"
}

89/3 2026/10/14 16:50 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 54527
							output: 37
							thoughts: 1636
						

Thoughts:
**Analyzing the `pmsr_parse_ftm_nan` Function**

Alright, let's dive into this `pmsr_parse_ftm_nan` function in `pmsr.c`. It's clearly handling the parsing of FTM (Fine Timing Measurement) requests specifically for NAN (Neighbor Awareness Networking) ranging. I need to understand how the data is being validated and how the request is built.

First, I see the function takes a `struct cfg80211_registered_device *rdev` which gives us access to the device's capabilities, a `struct nlattr *ftmreq` which holds the netlink attributes of the FTM request, a `struct cfg80211_pmsr_request_peer *out` which looks like it will hold the parsed output data, and a `struct genl_info *info` with general netlink information. The `out` struct is the focal point here.

The code starts by parsing the nested attributes within the `ftmreq` netlink attribute using `nla_parse_nested`. The `nl80211_pmsr_ftm_req_attr_policy` likely defines the allowed attributes and their types. Error handling is present with `info->extack` used for detailed error messages.

The function then sets `out->ftm.requested = true` so it knows a FTM request is being processed.

Now, let's step through the checks:
1.  **ASAP Requirement**: It enforces that ASAP (As Soon As Possible) mode must be set. NAN ranging *requires* ASAP, which makes sense for accurate timing. If ASAP isn't set, or if the device doesn't support ASAP, it returns an error. The device capabilities are accessed through `rdev->wiphy.pmsr_capa`.
2.  **Single Burst**: It also enforces that NAN ranging uses a single burst of FTM measurements (`num_bursts_exp` must be 0).
3.  **RSTA and Range Report**: It checks for the `RSTA` (Responder STA) and `range_report` flags. The range report is only valid for RSTA devices, which makes sense. An error is returned if a range report is requested without RSTA.
4.  **Preamble Check**: If a preamble is provided, it validates that it's supported by the device's capabilities using `capa->ftm.preambles`.
5.  **FTMs Per Burst**: It looks at an optional `ftms_per_burst` value and makes sure it's within sensible limits (<= 31), and within the device's supported maximum (if any).
6.  **Burst Duration, Min Delta FTM, Ingress and Egress**: It reads the optional `burst_duration`, `min_delta_ftm`, `ingress` and `egress` settings if they are present.

Now to complete this analysis, I need to know where and how `out` is being allocated and initialized, before this function is ever called. I should look at the function that calls this `pmsr_parse_ftm_nan` to see where the `out` structure is allocated and initialized. This will reveal if it's stack or heap-allocated, and if the calling function sets any default values within the `out` struct.



90/3 2026/10/14 16:50 tool grepper
0m Args:
{
  "Expression": "pmsr_parse_peer",
  "PathPrefixes": [
    "net/wireless/pmsr.c"
  ]
}

Results:
{
  "Output": "net/wireless/pmsr.c=309=static int pmsr_parse_ftm_nan(struct cfg80211_registered_device *rdev,\n--\nnet/wireless/pmsr.c-404-\nnet/wireless/pmsr.c:405:static int pmsr_parse_peer(struct cfg80211_registered_device *rdev,\nnet/wireless/pmsr.c-406-\t\t\t   struct nlattr *peer,\n--\nnet/wireless/pmsr.c=532=int nl80211_pmsr_start(struct sk_buff *skb, struct genl_info *info)\n--\nnet/wireless/pmsr.c-600-\t\t/* NB: this reuses info-\u003eattrs, but we no longer need it */\nnet/wireless/pmsr.c:601:\t\terr = pmsr_parse_peer(rdev, peer, \u0026req-\u003epeers[idx], info);\nnet/wireless/pmsr.c-602-\t\tif (err)\n"
}

91/3 2026/10/14 16:50 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 57208
							output: 37
							thoughts: 25
						

Thoughts:
Okay, here's my take on those thoughts, tailored for an expert audience and presented in the first person:

**Analyzing `req` Allocation in `nl80211_pmsr_start`**

Alright, let's dive into the `nl80211_pmsr_start` function and scrutinize how the `req` structure is allocated. My initial thought is, where exactly is this thing coming from? Is it dynamically allocated, maybe via `kmalloc` or some similar kernel memory allocator? Or is it a statically allocated structure, perhaps part of a larger context or a per-netdev structure? Understanding the allocation strategy is crucial for several reasons.

Firstly, if it's dynamic, I need to know the allocation size to anticipate any potential memory exhaustion scenarios or fragmentation issues. Are there any size limits imposed, or does it dynamically adjust based on parameters?

Secondly, the allocation method directly impacts the life cycle management of `req`. How is it freed? Is there a corresponding `kfree` or a different mechanism used to release the memory when it is no longer required? I'll need to trace the code to ensure we're not leaking memory – a pervasive issue in kernel programming!

Furthermore, I'm already wondering about potential concurrency issues. Is `req` accessed from multiple threads or contexts? If so, are there proper locking mechanisms, such as mutexes or spinlocks, in place to protect against data races? Are there any use-after-free scenarios that I should be on the lookout for? I'll need to carefully consider all code paths that interact with this structure.

Finally, the context of the allocation is important too. Is this allocation done on a per-request basis? If so, what are the implications for performance under heavy load? Are there any optimizations that could be employed, such as pre-allocating a pool of `req` structures to amortize the allocation overhead?

Let's start tracing the code and finding the answer!



92/3 2026/10/14 16:50 tool read-file
0m Args:
{
  "File": "net/wireless/pmsr.c",
  "FirstLine": 580,
  "LineCount": 30
}

Results:
{
  "Contents": " 580:\t\tif (info-\u003eattrs[NL80211_ATTR_MAC]) {\n 581:\t\t\tif (!capa-\u003erandomize_mac_addr) {\n 582:\t\t\t\tNL_SET_ERR_MSG_ATTR(info-\u003eextack,\n 583:\t\t\t\t\t\t    info-\u003eattrs[NL80211_ATTR_MAC],\n 584:\t\t\t\t\t\t    \"device cannot randomize MAC address\");\n 585:\t\t\t\terr = -EINVAL;\n 586:\t\t\t\tgoto out_err;\n 587:\t\t\t}\n 588:\t\n 589:\t\t\terr = nl80211_parse_random_mac(info-\u003eattrs, req-\u003emac_addr,\n 590:\t\t\t\t\t\t       req-\u003emac_addr_mask);\n 591:\t\t\tif (err)\n 592:\t\t\t\tgoto out_err;\n 593:\t\t} else {\n 594:\t\t\tmemcpy(req-\u003emac_addr, wdev_address(wdev), ETH_ALEN);\n 595:\t\t\teth_broadcast_addr(req-\u003emac_addr_mask);\n 596:\t\t}\n 597:\t\n 598:\t\tidx = 0;\n 599:\t\tnla_for_each_nested(peer, peers, rem) {\n 600:\t\t\t/* NB: this reuses info-\u003eattrs, but we no longer need it */\n 601:\t\t\terr = pmsr_parse_peer(rdev, peer, \u0026req-\u003epeers[idx], info);\n 602:\t\t\tif (err)\n 603:\t\t\t\tgoto out_err;\n 604:\t\t\tidx++;\n 605:\t\t}\n 606:\t\n 607:\t\t/* Validate per-role peer limits if advertised */\n 608:\t\tif (capa-\u003eftm.ista.max_peers) {\n 609:\t\t\tpeer_count = 0;\n"
}

93/3 2026/10/14 16:50 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 58182
							output: 37
							thoughts: 27
						

Thoughts:
Okay, here's my take on those thoughts, tailored for an expert audience:

**Analyzing the Allocation of 'req' in nl80211_pmsr_start**

Right, let's trace this back. My immediate focus is on how the `req` structure is allocated within the `nl80211_pmsr_start` function. I need to understand the lifecycle of this structure, especially in the context of power management and station mode. Understanding its allocation strategy will be crucial for debugging any potential memory leaks, race conditions, or incorrect data handling that might arise during the operation of Passive Mode Scan Request in nl80211. I want to see if it's dynamically allocated, statically declared, or perhaps retrieved from a pool. Where and when is it initialized, and critically, how is it freed or released when the PMS request completes or errors out? Knowing the allocation method gives me valuable context to understand how the driver interfaces with this specific data structure in regards to other elements of the WiFi subsystem.



94/3 2026/10/14 16:50 tool read-file
0m Args:
{
  "File": "net/wireless/pmsr.c",
  "FirstLine": 550,
  "LineCount": 30
}

Results:
{
  "Contents": " 550:\t\n 551:\t\tpeers = nla_find(nla_data(reqattr), nla_len(reqattr),\n 552:\t\t\t\t NL80211_PMSR_ATTR_PEERS);\n 553:\t\tif (!peers)\n 554:\t\t\treturn -EINVAL;\n 555:\t\n 556:\t\tcount = 0;\n 557:\t\tnla_for_each_nested(peer, peers, rem) {\n 558:\t\t\tcount++;\n 559:\t\n 560:\t\t\tif (count \u003e capa-\u003emax_peers) {\n 561:\t\t\t\tNL_SET_ERR_MSG_ATTR(info-\u003eextack, peer,\n 562:\t\t\t\t\t\t    \"Too many peers used\");\n 563:\t\t\t\treturn -EINVAL;\n 564:\t\t\t}\n 565:\t\t}\n 566:\t\n 567:\t\tif (!count) {\n 568:\t\t\tNL_SET_ERR_MSG_ATTR(info-\u003eextack, peers, \"No peers specified\");\n 569:\t\t\treturn -EINVAL;\n 570:\t\t}\n 571:\t\n 572:\t\treq = kzalloc_flex(*req, peers, count);\n 573:\t\tif (!req)\n 574:\t\t\treturn -ENOMEM;\n 575:\t\treq-\u003en_peers = count;\n 576:\t\n 577:\t\tif (info-\u003eattrs[NL80211_ATTR_TIMEOUT])\n 578:\t\t\treq-\u003etimeout = nla_get_u32(info-\u003eattrs[NL80211_ATTR_TIMEOUT]);\n 579:\t\n"
}

95/3 2026/10/14 16:50 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 58908
							output: 21
							thoughts: 2089
						

Thoughts:
**Analyzing NAN NDP Initialization and Potential Vulnerabilities**

Okay, so I'm looking at how NAN (Neighbor Awareness Networking) NDP (Neighbor Discovery Protocol) initialization is handled. The initial allocation, `kzalloc_flex`, seems secure with its zero-initialization.  I'm focusing on the tracepoints, specifically `trace_rdev_nan_ndp_initiate`, which gives me a good overview of the key data.  I see that the `params` struct passed to `nl80211_nan_ndp_initiate` is zero-initialized and then populated from Netlink attributes.  Specifically, `peer_nmi`, `init_ndi`, `publish_id`, and `service_id` are populated. The code carefully checks that the required attributes like `NL80211_ATTR_MAC` are actually present before copying data. Critically, `NL80211_ATTR_MAC` is explicitly defined as `NLA_POLICY_EXACT_LEN(ETH_ALEN)`, meaning the length is guaranteed to be correct at least as far as Netlink is concerned. This is important to verify there is sufficient space in the buffer.  The same is true in the `rdev_nan_ndp_respond` and `rdev_nan_ndp_terminate` functions.

Then I shifted my attention to the callbacks `cfg80211_nan_ndp_request`, `cfg80211_nan_ndp_confirm`, and `cfg80211_nan_ndp_terminated`. These are intended for wireless drivers to use.  But, after checking the code base, I can confirm that no drivers *actually* call these functions right now.  Even if they did, the netlink message construction in these functions looks robust: they use `nla_put` and associated functions to construct the messages. All the data is coming from the `params` struct passed by the driver, so the driver *should* be in control of this data, which should mean that the kernel is safe.

Now, my line of reasoning turned toward fuzzing and potential attack vectors.  Could a fuzzer or a malicious user trigger these driver-facing callback functions?  No, because no drivers currently call them.  However, Syzkaller *can* reach the Netlink commands: `NL80211_CMD_NAN_NDP_INITIATE`, `NL80211_CMD_NAN_NDP_RESPOND`, `NL80211_CMD_NAN_NDP_TERMINATE`, `NL80211_CMD_ADD_NAN_FUNCTION`, and `NL80211_CMD_START_PMSR`. These commands pass data from userspace directly to the kernel through Netlink.  I've checked the initialization for the `initiate` command. The stack memory `params` struct is zeroed. The data is validated through netlink attribute validation. Then the driver operation is called. This initial investigation shows a generally secure flow, validating data from Netlink attributes before passing to driver ops.  Now, I'm going to look for which drivers implement those `nan_ndp_initiate` operations to fully understand the landscape and potential weaknesses.



96/3 2026/10/14 16:51 tool grepper
0m Args:
{
  "Expression": "nan_ndp_initiate"
}

Results:
{
  "Output": "include/net/cfg80211.h=4325=struct cfg80211_nan_peer_sched {\n--\ninclude/net/cfg80211.h-4337-/**\ninclude/net/cfg80211.h:4338: * struct cfg80211_nan_ndp_initiate - NAN NDP initiate parameters\ninclude/net/cfg80211.h-4339- *\n--\ninclude/net/cfg80211.h-4361- */\ninclude/net/cfg80211.h:4362:struct cfg80211_nan_ndp_initiate {\ninclude/net/cfg80211.h-4363-\tconst u8 *peer_nmi;\n--\ninclude/net/cfg80211.h=5112=struct mgmt_frame_regs {\n--\ninclude/net/cfg80211.h-5500- *\ninclude/net/cfg80211.h:5501: * @nan_ndp_initiate: Initiate a NAN Data Path session as the initiator.\ninclude/net/cfg80211.h-5502- *\tOnly valid if the driver has set %WIPHY_NAN_FLAGS_OFFLOAD_NDP.\n--\ninclude/net/cfg80211.h=5582=struct cfg80211_ops {\n--\ninclude/net/cfg80211.h-5914-\t\t\t\t\t     struct cfg80211_nan_non_evac_channels *channels);\ninclude/net/cfg80211.h:5915:\tint     (*nan_ndp_initiate)(struct wiphy *wiphy,\ninclude/net/cfg80211.h-5916-\t\t\t\t    struct wireless_dev *wdev,\ninclude/net/cfg80211.h:5917:\t\t\t\t    struct cfg80211_nan_ndp_initiate *params);\ninclude/net/cfg80211.h-5918-\tint\t(*nan_ndp_respond)(struct wiphy *wiphy,\n--\nnet/wireless/nl80211.c=18356=static int nl80211_nan_set_peer_sched(struct sk_buff *skb,\n--\nnet/wireless/nl80211.c-18503-\nnet/wireless/nl80211.c:18504:static int nl80211_nan_ndp_initiate(struct sk_buff *skb,\nnet/wireless/nl80211.c-18505-\t\t\t\t    struct genl_info *info)\n--\nnet/wireless/nl80211.c-18509-\tstruct nlattr *tb[NL80211_NAN_NDP_ATTR_MAX + 1];\nnet/wireless/nl80211.c:18510:\tstruct cfg80211_nan_ndp_initiate params = {};\nnet/wireless/nl80211.c-18511-\tint err;\n--\nnet/wireless/nl80211.c-18625-\nnet/wireless/nl80211.c:18626:\treturn rdev_nan_ndp_initiate(rdev, wdev, \u0026params);\nnet/wireless/nl80211.c-18627-}\n--\nnet/wireless/nl80211.c=21266=static const struct genl_small_ops nl80211_small_ops[] = {\n--\nnet/wireless/nl80211.c-22158-\t\t.cmd = NL80211_CMD_NAN_NDP_INITIATE,\nnet/wireless/nl80211.c:22159:\t\t.doit = nl80211_nan_ndp_initiate,\nnet/wireless/nl80211.c-22160-\t\t.flags = GENL_ADMIN_PERM,\n--\nnet/wireless/rdev-ops.h=1186=static inline int\nnet/wireless/rdev-ops.h:1187:rdev_nan_ndp_initiate(struct cfg80211_registered_device *rdev,\nnet/wireless/rdev-ops.h-1188-\t\t      struct wireless_dev *wdev,\nnet/wireless/rdev-ops.h:1189:\t\t      struct cfg80211_nan_ndp_initiate *params)\nnet/wireless/rdev-ops.h-1190-{\n--\nnet/wireless/rdev-ops.h-1192-\nnet/wireless/rdev-ops.h:1193:\tif (!rdev-\u003eops-\u003enan_ndp_initiate)\nnet/wireless/rdev-ops.h-1194-\t\treturn -EOPNOTSUPP;\nnet/wireless/rdev-ops.h-1195-\nnet/wireless/rdev-ops.h:1196:\ttrace_rdev_nan_ndp_initiate(\u0026rdev-\u003ewiphy, wdev, params);\nnet/wireless/rdev-ops.h:1197:\tret = rdev-\u003eops-\u003enan_ndp_initiate(\u0026rdev-\u003ewiphy, wdev, params);\nnet/wireless/rdev-ops.h-1198-\ttrace_rdev_return_int(\u0026rdev-\u003ewiphy, ret);\n--\nnet/wireless/trace.h=2530=TRACE_EVENT(rdev_nan_set_non_evac_channels,\n--\nnet/wireless/trace.h-2554-\nnet/wireless/trace.h:2555:TRACE_EVENT(rdev_nan_ndp_initiate,\nnet/wireless/trace.h-2556-\tTP_PROTO(struct wiphy *wiphy, struct wireless_dev *wdev,\nnet/wireless/trace.h:2557:\t\t struct cfg80211_nan_ndp_initiate *params),\nnet/wireless/trace.h-2558-\tTP_ARGS(wiphy, wdev, params),\n"
}

97/3 2026/10/14 16:51 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 63315
							output: 26
							thoughts: 2576
						

Thoughts:
**NAN NDP/Ranging Initialization and Data Flow Analysis**

Okay, let's break this down systematically. It appears there are no drivers implementing `nan_ndp_initiate`, which seems to be the core function for NAN NDP and ranging support in the cfg80211 framework.

First, I examined `nl80211_nan_ndp_respond` and `nl80211_nan_ndp_terminate`, and observed that both functions initialize a `params` struct via zero initialization (`params = {};`). Similarly, `nl80211_nan_add_func` uses `kzalloc_obj`, which also guarantees zero-initialization of the `func` struct allocated on the heap. I then reviewed the fields added to this structure: `sdea_ctrl`, `pairing_bootstrap_methods`, `csids`, `nd_pmk`, etc. All of these fields are explicitly initialized or are zeroed out by `kzalloc_obj`.

Next, I turned my attention to `pmsr_parse_ftm_nan`, focusing on the `out` struct, which is obtained via `kzalloc_flex`. The code initializes the `out` struct, which means all of its fields are zeroed out. After zero initialization, fields like `requested`, `asap`, `rsta`, `range_report`, etc., are explicitly assigned values.

I then focused on the potential for information leaks.

I identified the netlink messages sent to userspace. They include:

1.  `nl80211_send_pmsr_ftm_capa`: Sends a flag (`NL80211_PMSR_FTM_TYPE_CAPA_ATTR_NAN_SUPPORT`). Flags inherently have no payload.
2.  `nl80211_put_nan_capa`: Sends flags (`NL80211_NAN_CAPA_OFFLOAD_RANGING` and `NL80211_NAN_CAPA_OFFLOAD_NDP`). Again, flags have no payload.
3.  `cfg80211_nan_match`: This uses `nla_put_u16`, `nla_put`, and `nla_put_s32`, with the data going directly from the stack to the `nla_put`. It includes `nla_put_u16` for scalar u16s, `nla_put` for byte arrays with specified sizes, `nla_put_s32` for scalar s32s, and `nla_put_u8` for scalar u8s. All of these calls construct Netlink TLV attributes, where padding bytes are zeroed out by Netlink helper functions (like `nla_reserve` or `skb_put` etc.). No struct copies are involved, which means no potential for padding leaks.
4.  `cfg80211_nan_ndp_request`: Similar to above, `nla_put` is used with specific scalar types, flags, or explicit length byte arrays.
5.  `cfg80211_nan_ndp_confirm`: Same as above, no issues.
6.  `cfg80211_nan_ndp_terminated`: Again, either `nla_put_u8` or `nla_put` of ETH\_ALEN.

It's clear that the code avoids struct copies and instead utilizes the correct `nla_put` functions, effectively preventing any information leaks due to uninitialized padding. Moreover, all stack variables (in `nl80211_nan_ndp_initiate`, `nl80211_nan_ndp_respond`, `nl80211_nan_ndp_terminate`), and heap allocations are initialized.

Finally, I checked `pmsr_parse_ftm_nan` for potential reads of uninitialized fields. Everything is zeroed by kzalloc. In this function, the variables are set via boolean checks on `tb` arrays (e.g. `!!tb[NL80211_PMSR_FTM_REQ_ATTR_RSTA]`), and there appears to be no potential for using uninitialized data.

However, a potential for uninitialized variable read was observed in `nl80211_nan_add_func` function related to the channel definition. I am unsure if `nl80211_parse_chandef` reads or leaves something uninitialized in `func->chandef`, therefore, I will need to check `nl80211_parse_chandef`.



98/3 2026/10/14 16:51 tool grepper
0m Args:
{
  "Expression": "int nl80211_parse_chandef"
}

Results:
{
  "Output": "net/wireless/nl80211.c=4109=static int _nl80211_parse_chandef(struct cfg80211_registered_device *rdev,\n--\nnet/wireless/nl80211.c-4277-\nnet/wireless/nl80211.c:4278:int nl80211_parse_chandef(struct cfg80211_registered_device *rdev,\nnet/wireless/nl80211.c-4279-\t\t\t  struct netlink_ext_ack *extack,\n--\nnet/wireless/nl80211.h=19=static inline u64 wdev_id(struct wireless_dev *wdev)\n--\nnet/wireless/nl80211.h-24-\nnet/wireless/nl80211.h:25:int nl80211_parse_chandef(struct cfg80211_registered_device *rdev,\nnet/wireless/nl80211.h-26-\t\t\t  struct netlink_ext_ack *extack,\n"
}

99/3 2026/10/14 16:51 llm kmsan-evaluator
4m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 67225
							output: 41
							thoughts: 38
						

Thoughts:
Okay, here's my interpretation of that thought process, tailored for an expert audience, and written in the first person:

**Diving into the Channel Definition Parser**

Alright, time to get my hands dirty. I'm going to take a closer look at the `nl80211_parse_chandef` function. Specifically, I need to check its implementation, and that means jumping straight into `net/wireless/nl80211.c` at line 4278. I want to see exactly how it's handling the channel definition parsing. There's probably something specific I'm interested in, a potential edge case or perhaps some interaction with a recent patch that's got my attention, but let's see what we can find. I anticipate a deeper dive is required to identify a problem.



100/3 2026/10/14 16:56 tool read-file
0m Args:
{
  "File": "net/wireless/nl80211.c",
  "FirstLine": 4278,
  "LineCount": 20
}

Results:
{
  "Contents": "4278:\tint nl80211_parse_chandef(struct cfg80211_registered_device *rdev,\n4279:\t\t\t\t  struct netlink_ext_ack *extack,\n4280:\t\t\t\t  struct nlattr **attrs,\n4281:\t\t\t\t  struct cfg80211_chan_def *chandef,\n4282:\t\t\t\t  bool permit_npca)\n4283:\t{\n4284:\t\treturn _nl80211_parse_chandef(rdev, extack, attrs, false, chandef,\n4285:\t\t\t\t\t      permit_npca);\n4286:\t}\n4287:\t\n4288:\tstatic int __nl80211_set_channel(struct cfg80211_registered_device *rdev,\n4289:\t\t\t\t\t struct net_device *dev,\n4290:\t\t\t\t\t struct genl_info *info,\n4291:\t\t\t\t\t int _link_id)\n4292:\t{\n4293:\t\tstruct cfg80211_chan_def chandef;\n4294:\t\tint result;\n4295:\t\tenum nl80211_iftype iftype = NL80211_IFTYPE_MONITOR;\n4296:\t\tstruct wireless_dev *wdev = NULL;\n4297:\t\tint link_id = _link_id;\n"
}

101/3 2026/10/14 16:56 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 67853
							output: 41
							thoughts: 18
						

Thoughts:
Okay, here's my attempt at summarizing the thought process, tailored for an expert audience, and written in the first person:

**Diving into `_nl80211_parse_chandef`**

Alright, let's take a look at `_nl80211_parse_chandef`. I need to refresh my memory on how this function handles the channel definition parsing within the nl80211 framework. I'm specifically interested in ensuring its correct interpretation of the channel definition passed up from userspace. I'll need to double-check its handling of all the nuances of band, channel width, center frequencies, and any regulatory information embedded in the definition. Any misinterpretation here, especially with the increasingly complex 802.11 standards, could lead to serious issues, from connection failures to regulatory non-compliance. I'll be focused on how it extracts the parameters from the Netlink message and validates them against the expected format and supported values. I'll be paying close attention to any error handling too. Gotta make sure it correctly handles malformed inputs, edge cases and potential security vulnerabilities in parsing. Time to get to it!



102/3 2026/10/14 16:56 tool read-file
0m Args:
{
  "File": "net/wireless/nl80211.c",
  "FirstLine": 4109,
  "LineCount": 25
}

Results:
{
  "Contents": "4109:\tstatic int _nl80211_parse_chandef(struct cfg80211_registered_device *rdev,\n4110:\t\t\t\t\t  struct netlink_ext_ack *extack,\n4111:\t\t\t\t\t  struct nlattr **attrs, bool monitor,\n4112:\t\t\t\t\t  struct cfg80211_chan_def *chandef,\n4113:\t\t\t\t\t  bool permit_npca)\n4114:\t{\n4115:\t\tu32 control_freq;\n4116:\t\n4117:\t\tif (!attrs[NL80211_ATTR_WIPHY_FREQ]) {\n4118:\t\t\tNL_SET_ERR_MSG_ATTR(extack, attrs[NL80211_ATTR_WIPHY_FREQ],\n4119:\t\t\t\t\t    \"Frequency is missing\");\n4120:\t\t\treturn -EINVAL;\n4121:\t\t}\n4122:\t\n4123:\t\tcontrol_freq = MHZ_TO_KHZ(\n4124:\t\t\t\tnla_get_u32(attrs[NL80211_ATTR_WIPHY_FREQ]));\n4125:\t\tif (attrs[NL80211_ATTR_WIPHY_FREQ_OFFSET])\n4126:\t\t\tcontrol_freq +=\n4127:\t\t\t    nla_get_u32(attrs[NL80211_ATTR_WIPHY_FREQ_OFFSET]);\n4128:\t\n4129:\t\tmemset(chandef, 0, sizeof(*chandef));\n4130:\t\tchandef-\u003echan = ieee80211_get_channel_khz(\u0026rdev-\u003ewiphy, control_freq);\n4131:\t\tchandef-\u003ewidth = NL80211_CHAN_WIDTH_20_NOHT;\n4132:\t\tchandef-\u003ecenter_freq1 = KHZ_TO_MHZ(control_freq);\n4133:\t\tchandef-\u003efreq1_offset = control_freq % 1000;\n"
}

103/3 2026/10/14 16:56 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 68687
							output: 557
							thoughts: 2853
						

Thoughts:
**KMSAN Assessment: NAN Data Path (NDP) Offload Patch**

Okay, let's break this down. The code introduces NAN Data Path (NDP) offload and NAN ranging capabilities within `cfg80211` and `nl80211`. My primary concern, given the KMSAN context, is whether this introduces any uninitialized memory reads or information leaks to userspace.

First, I examined memory initialization. The relevant data structures, such as those within the NDP handler functions (`nl80211_nan_ndp_initiate`, `nl80211_nan_ndp_respond`, `nl80211_nan_ndp_terminate`), are all stack-allocated and initialized with `= {}`, effectively zeroing them. Heap allocations, like those for `cfg80211_nan_func` and `cfg80211_pmsr_request`, use `kzalloc_obj` and `kzalloc_flex`, guaranteeing zero-initialization. Dynamic buffers like `func->csids` use `kmemdup` along with explicit length validation to ensure safe copying. The channel definition (`chandef`) is also carefully initialized with `memset`. This is good, strong starting point.

Next, I looked at how information is communicated to userspace through netlink. The new netlink attributes added or modified (including `NL80211_CMD_NAN_NDP_*` events and changes within `cfg80211_nan_match`) utilize primitive TLV encoders (`nla_put_u8`, `nla_put_u16`, `nla_put_u32`, `nla_put_s32`, `nla_put_flag`).  I noticed these are fundamental types, or are using explicit byte arrays with known, validated lengths. Crucially, there's no raw copying of structs with potentially uninitialized fields, nor any use of data structures with internal padding or alignment that could leak kernel data. This is a very important point!

Now, I considered the KMSAN rule: does this patch introduce any *new* risks specifically addressed by KMSAN that aren't already covered by KASAN? I carefully analyzed potential risks for uninitialized reads and information leaks. Any issues related to attribute handling, parsing errors, NULL pointer dereferences, or buffer overflows will be adequately caught by KASAN, and standard kernel debugging tools like lockdep. Specifically, the patch does extensive bounds checking in various aspects of memory handling to prevent OOB access.

In conclusion, I am confident that this patch does *not* introduce any uninitialized memory reads or kernel information leaks that would be uniquely detected by KMSAN. All pertinent data structures are explicitly initialized, and all information sent to userspace is carefully constructed with primitive TLVs or validated byte arrays. Thus, my assessment is that `NeedsKMSAN = false`. I'm ready to document this comprehensively and set the results.



104/3 2026/10/14 16:57 tool set-results
0m Args:
{
  "KMSANReasoning": "The patch series adds support for NAN Data Path (NDP) offload and NAN ranging to cfg80211 and nl80211.\n\n1. Memory Initialization:\n- Stack-allocated structures in nl80211 handlers (`struct cfg80211_nan_ndp_initiate`, `struct cfg80211_nan_ndp_respond`, and `struct cfg80211_nan_ndp_terminate`) are zero-initialized upon declaration using `= {}`.\n- Heap-allocated structures that hold the parsed data (`cfg80211_nan_func` and `cfg80211_pmsr_request`) are allocated using `kzalloc_obj()` and `kzalloc_flex()`, respectively, ensuring all newly added struct fields start in a zeroed state.\n- Dynamic arrays such as `func-\u003ecsids` are allocated and populated with `kmemdup()` after validating that the netlink attribute length is a multiple of `sizeof(u32)`.\n- Channel configuration parsing via `nl80211_parse_chandef()` explicitly zeroes `chandef` with `memset()` before populating it.\n\n2. Kernel-to-Userspace Communication:\n- Netlink notifications to userspace (`cfg80211_nan_match`, `cfg80211_nan_ndp_request`, `cfg80211_nan_ndp_confirm`, and `cfg80211_nan_ndp_terminated`) construct messages using individual typed Netlink helpers (`nla_put_u8`, `nla_put_u16`, `nla_put_u32`, `nla_put_s32`, `nla_put_flag`) and bounded byte buffers (`nla_put`).\n- No raw structs containing uninitialized padding or uninitialized memory fields are copied or leaked to userspace via `copy_to_user` or netlink blobs.\n\n3. KASAN vs KMSAN Applicability:\n- Any risks arising from these changes pertain to Netlink attribute parsing, length validation, or pointer manipulation (such as NULL dereferences or out-of-bounds accesses), which are comprehensively covered by KASAN and standard bug detectors.\n- There are no risks of uninitialized memory reads, conditional branching on uninitialized data, or information leaks. Therefore, a dedicated KMSAN fuzzing session is not warranted.",
  "NeedsKMSAN": false
}

Results:
{
  "KMSANReasoning": "The patch series adds support for NAN Data Path (NDP) offload and NAN ranging to cfg80211 and nl80211.\n\n1. Memory Initialization:\n- Stack-allocated structures in nl80211 handlers (`struct cfg80211_nan_ndp_initiate`, `struct cfg80211_nan_ndp_respond`, and `struct cfg80211_nan_ndp_terminate`) are zero-initialized upon declaration using `= {}`.\n- Heap-allocated structures that hold the parsed data (`cfg80211_nan_func` and `cfg80211_pmsr_request`) are allocated using `kzalloc_obj()` and `kzalloc_flex()`, respectively, ensuring all newly added struct fields start in a zeroed state.\n- Dynamic arrays such as `func-\u003ecsids` are allocated and populated with `kmemdup()` after validating that the netlink attribute length is a multiple of `sizeof(u32)`.\n- Channel configuration parsing via `nl80211_parse_chandef()` explicitly zeroes `chandef` with `memset()` before populating it.\n\n2. Kernel-to-Userspace Communication:\n- Netlink notifications to userspace (`cfg80211_nan_match`, `cfg80211_nan_ndp_request`, `cfg80211_nan_ndp_confirm`, and `cfg80211_nan_ndp_terminated`) construct messages using individual typed Netlink helpers (`nla_put_u8`, `nla_put_u16`, `nla_put_u32`, `nla_put_s32`, `nla_put_flag`) and bounded byte buffers (`nla_put`).\n- No raw structs containing uninitialized padding or uninitialized memory fields are copied or leaked to userspace via `copy_to_user` or netlink blobs.\n\n3. KASAN vs KMSAN Applicability:\n- Any risks arising from these changes pertain to Netlink attribute parsing, length validation, or pointer manipulation (such as NULL dereferences or out-of-bounds accesses), which are comprehensively covered by KASAN and standard bug detectors.\n- There are no risks of uninitialized memory reads, conditional branching on uninitialized data, or information leaks. Therefore, a dedicated KMSAN fuzzing session is not warranted.",
  "NeedsKMSAN": false
}

LLM Calls Summary:
Total Calls Total Tokens Avg Tokens Total Duration (Seconds) Avg Duration (Seconds)
Tool Calls Summary:
Total Calls Total Duration (Seconds) Avg Duration (Seconds)