wcn36xx_rx_skb() unconditionally sets RX_FLAG_IV_STRIPPED, RX_FLAG_MMIC_STRIPPED, and RX_FLAG_DECRYPTED on every received frame, regardless of whether hardware decryption actually took place. This causes two issues: - Management frames (which WCNSS firmware delivers untouched with bd->dpu_ne == 1 when rmf == 0) are falsely marked as decrypted, preventing mac80211 from performing software decryption/MIC verification on robust management frames and bypassing ieee80211_drop_unencrypted_mgmt(). - Unencrypted data frames such as 4-way handshake EAPOL frames (fc 0x0288), where WCN3620 hardware leaves bd->dpu_ne == 0, are falsely reported as decrypted and bypass ieee80211_drop_unencrypted(). Only set the hardware decryption flags when bd->dpu_ne is clear, the frame is not a management frame, and IEEE80211_FCTL_PROTECTED is set in the 802.11 header (verified on WCN3620 that hardware preserves the Protected bit on both CCMP and TKIP hardware-decrypted data frames). Signed-off-by: Vladimir Bely --- drivers/net/wireless/ath/wcn36xx/txrx.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/ath/wcn36xx/txrx.c b/drivers/net/wireless/ath/wcn36xx/txrx.c index 882699879..a554c59de 100644 --- a/drivers/net/wireless/ath/wcn36xx/txrx.c +++ b/drivers/net/wireless/ath/wcn36xx/txrx.c @@ -355,9 +355,11 @@ int wcn36xx_rx_skb(struct wcn36xx *wcn, struct sk_buff *skb) status.antenna = 1; status.flag = 0; status.rx_flags = 0; - status.flag |= RX_FLAG_IV_STRIPPED | - RX_FLAG_MMIC_STRIPPED | - RX_FLAG_DECRYPTED; + if (!bd->dpu_ne && !ieee80211_is_mgmt(hdr->frame_control) && + ieee80211_has_protected(hdr->frame_control)) + status.flag |= RX_FLAG_IV_STRIPPED | + RX_FLAG_MMIC_STRIPPED | + RX_FLAG_DECRYPTED; wcn36xx_dbg(WCN36XX_DBG_RX, "status.flags=%x\n", status.flag); -- 2.43.0 wcn36xx_set_rekey_data() sets vif_priv->rekey_data.valid = true, but the flag is never cleared on disconnect or checked in wcn36xx_suspend() and wcn36xx_resume(). As a result, firmware GTK offload is enabled even on open networks or with stale KEK/KCK data from a previous association. Check vif_priv->rekey_data.valid before enabling/disabling GTK offload during suspend/resume, and clear it on disassociation/BSSID teardown. Additionally, skip enabling firmware GTK offload when MFP is active (sta->mfp), as BIP/IGTK is handled in software by mac80211 and older WCNSS firmware cannot safely offload SAE or IGTK rekeying; waking the host on group rekey frames lets wpa_supplicant and mac80211 update both GTK and IGTK consistently. Signed-off-by: Vladimir Bely --- drivers/net/wireless/ath/wcn36xx/main.c | 35 +++++++++++++++++++++---- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c index ad8a4bd91..f7e0a4aa8 100644 --- a/drivers/net/wireless/ath/wcn36xx/main.c +++ b/drivers/net/wireless/ath/wcn36xx/main.c @@ -835,6 +835,7 @@ static void wcn36xx_bss_info_changed(struct ieee80211_hw *hw, bss_conf->bssid, false); } else { vif_priv->is_joining = false; + vif_priv->rekey_data.valid = false; wcn36xx_smd_delete_bss(wcn, vif); wcn36xx_smd_set_link_st(wcn, bss_conf->bssid, vif->addr, WCN36XX_HAL_LINK_IDLE_STATE); @@ -906,6 +907,7 @@ static void wcn36xx_bss_info_changed(struct ieee80211_hw *hw, vif->addr, vif->cfg.aid); vif_priv->sta_assoc = false; + vif_priv->rekey_data.valid = false; wcn36xx_smd_set_link_st(wcn, bss_conf->bssid, vif->addr, @@ -1102,15 +1104,19 @@ static int wcn36xx_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wow) vif = wcn36xx_get_first_assoc_vif(wcn); if (vif) { + struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif); + ret = wcn36xx_smd_arp_offload(wcn, vif, true); if (ret) goto out; ret = wcn36xx_smd_ipv6_ns_offload(wcn, vif, true); if (ret) goto out; - ret = wcn36xx_smd_gtk_offload(wcn, vif, true); - if (ret) - goto out; + if (vif_priv->rekey_data.valid) { + ret = wcn36xx_smd_gtk_offload(wcn, vif, true); + if (ret) + goto out; + } ret = wcn36xx_smd_set_power_params(wcn, true); if (ret) goto out; @@ -1138,10 +1144,14 @@ static int wcn36xx_resume(struct ieee80211_hw *hw) mutex_lock(&wcn->conf_mutex); vif = wcn36xx_get_first_assoc_vif(wcn); if (vif) { + struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif); + wcn36xx_smd_host_resume(wcn); wcn36xx_smd_set_power_params(wcn, false); - wcn36xx_smd_gtk_offload_get_info(wcn, vif); - wcn36xx_smd_gtk_offload(wcn, vif, false); + if (vif_priv->rekey_data.valid) { + wcn36xx_smd_gtk_offload_get_info(wcn, vif); + wcn36xx_smd_gtk_offload(wcn, vif, false); + } wcn36xx_smd_ipv6_ns_offload(wcn, vif, false); wcn36xx_smd_arp_offload(wcn, vif, false); } @@ -1160,15 +1170,30 @@ static void wcn36xx_set_rekey_data(struct ieee80211_hw *hw, { struct wcn36xx *wcn = hw->priv; struct wcn36xx_vif *vif_priv = wcn36xx_vif_to_priv(vif); + struct ieee80211_sta *sta; mutex_lock(&wcn->conf_mutex); + /* + * With MFP active, BIP/IGTK is handled in software by mac80211 and + * firmware GTK offload cannot safely handle SAE/IGTK rekeying. + */ + rcu_read_lock(); + sta = ieee80211_find_sta(vif, vif->bss_conf.bssid); + if (sta && sta->mfp) { + rcu_read_unlock(); + vif_priv->rekey_data.valid = false; + goto out; + } + rcu_read_unlock(); + memcpy(vif_priv->rekey_data.kek, data->kek, NL80211_KEK_LEN); memcpy(vif_priv->rekey_data.kck, data->kck, NL80211_KCK_LEN); vif_priv->rekey_data.replay_ctr = cpu_to_le64(be64_to_cpup((__be64 *)data->replay_ctr)); vif_priv->rekey_data.valid = true; +out: mutex_unlock(&wcn->conf_mutex); } -- 2.43.0 wcn36xx does not currently advertise IEEE80211_HW_MFP_CAPABLE or BIP cipher suites, which prevents connecting to networks requiring 802.11w Management Frame Protection (MFP), including WPA3-SAE, OWE, and WPA2-PSK-SHA256 with MFPR (cfg80211 rejects IGTK installation with -EINVAL). Enable MFP using mac80211 software crypto for protected management frames while keeping data frames on the hardware DPU, following the same pattern as ath9k, ath5k, carl9170, and rtl8xxxu: - Advertise IEEE80211_HW_MFP_CAPABLE and the four BIP cipher suites (AES-CMAC, BIP-CMAC-256, BIP-GMAC-128, BIP-GMAC-256) in wcn36xx_init_ieee80211(). - Return -EOPNOTSUPP without logging an error for BIP ciphers in wcn36xx_set_key() so mac80211 installs them as software keys. - Set IEEE80211_KEY_FLAG_SW_MGMT_TX on CCMP keys during SET_KEY so mac80211 encrypts unicast robust management frames in software, matching wcn36xx_set_tx_mgmt() which always sets bd->dpu_ne = 1. Note that WCN36XX_TXBD_SSN_FILL_DPU_NON_QOS in wcn36xx_set_tx_mgmt() does not invalidate CCMP or BIP MICs, since the 802.11 sequence number is masked out of CCMP AAD and excluded from BIP AAD. Using software crypto for low-rate management frames works uniformly across WCN36xx firmware versions and supports all four BIP ciphers. Tested on Samsung Galaxy A3 (SM-A300F, MSM8916, WCN3620, firmware CNSS-PR-2-0-1-c8-00048) across Open, OWE, WPA2-PSK-TKIP, WPA2-PSK-CCMP, WPA2-PSK-SHA256 with MFPR, WPA2/WPA3-Transition (both PSK and SAE), and WPA3-SAE/SAE-EXT-KEY networks, including encrypted TX/RX Deauth and AddBA Action frames as well as broadcast BIP Deauth. Signed-off-by: Vladimir Bely --- drivers/net/wireless/ath/wcn36xx/main.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/net/wireless/ath/wcn36xx/main.c b/drivers/net/wireless/ath/wcn36xx/main.c index f7e0a4aa8..f31a55f4e 100644 --- a/drivers/net/wireless/ath/wcn36xx/main.c +++ b/drivers/net/wireless/ath/wcn36xx/main.c @@ -530,6 +530,13 @@ static int wcn36xx_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, case WLAN_CIPHER_SUITE_TKIP: vif_priv->encrypt_type = WCN36XX_HAL_ED_TKIP; break; + case WLAN_CIPHER_SUITE_AES_CMAC: + case WLAN_CIPHER_SUITE_BIP_CMAC_256: + case WLAN_CIPHER_SUITE_BIP_GMAC_128: + case WLAN_CIPHER_SUITE_BIP_GMAC_256: + /* Handled in software by mac80211 */ + ret = -EOPNOTSUPP; + goto out; default: wcn36xx_err("Unsupported key type 0x%x\n", key_conf->cipher); @@ -539,6 +546,8 @@ static int wcn36xx_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, switch (cmd) { case SET_KEY: + if (key_conf->cipher == WLAN_CIPHER_SUITE_CCMP) + key_conf->flags |= IEEE80211_KEY_FLAG_SW_MGMT_TX; if (WCN36XX_HAL_ED_TKIP == vif_priv->encrypt_type) { /* * Supplicant is sending key in the wrong order: @@ -1447,6 +1456,10 @@ static int wcn36xx_init_ieee80211(struct wcn36xx *wcn) WLAN_CIPHER_SUITE_WEP104, WLAN_CIPHER_SUITE_TKIP, WLAN_CIPHER_SUITE_CCMP, + WLAN_CIPHER_SUITE_AES_CMAC, + WLAN_CIPHER_SUITE_BIP_CMAC_256, + WLAN_CIPHER_SUITE_BIP_GMAC_128, + WLAN_CIPHER_SUITE_BIP_GMAC_256, }; ieee80211_hw_set(wcn->hw, TIMING_BEACON_ONLY); @@ -1456,6 +1469,7 @@ static int wcn36xx_init_ieee80211(struct wcn36xx *wcn) ieee80211_hw_set(wcn->hw, HAS_RATE_CONTROL); ieee80211_hw_set(wcn->hw, SINGLE_SCAN_ON_ALL_BANDS); ieee80211_hw_set(wcn->hw, REPORTS_TX_ACK_STATUS); + ieee80211_hw_set(wcn->hw, MFP_CAPABLE); wcn->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | -- 2.43.0