ath9k: add NL80211_EXT_FEATURE_CAN_REPLACE_PTK0 support
authorAlexander Wetzel <alexander@wetzel-home.de>
Tue, 4 Aug 2020 16:41:51 +0000 (18:41 +0200)
committerKalle Valo <kvalo@codeaurora.org>
Mon, 17 Aug 2020 10:22:43 +0000 (13:22 +0300)
The ath9k driver was so far only able to rekey PTK0 keys correctly due
to the best effort queue flush added with commit 62872a9b9a10
("mac80211: Fix PTK rekey freezes and clear text leak").

Add the needed queue flush and set NL80211_EXT_FEATURE_CAN_REPLACE_PTK0
to tell mac80211 that the driver can now rekey PTK0 keys correctly and
no longer needs the best effort flush.

Effectively this prevents mac80211 to warn when rekeying a PTK0 key
only.

Signed-off-by: Alexander Wetzel <alexander@wetzel-home.de>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20200804164152.175375-1-alexander@wetzel-home.de
drivers/net/wireless/ath/ath9k/init.c
drivers/net/wireless/ath/ath9k/main.c

index 289a244..ea1d17a 100644 (file)
@@ -1014,6 +1014,7 @@ static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
        wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_AIRTIME_FAIRNESS);
        wiphy_ext_feature_set(hw->wiphy,
                              NL80211_EXT_FEATURE_MULTICAST_REGISTRATIONS);
+       wiphy_ext_feature_set(hw->wiphy, NL80211_EXT_FEATURE_CAN_REPLACE_PTK0);
 }
 
 int ath9k_init_device(u16 devid, struct ath_softc *sc,
index 0ea3b80..411eece 100644 (file)
@@ -19,6 +19,9 @@
 #include "ath9k.h"
 #include "btcoex.h"
 
+static void ath9k_flush(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
+                       u32 queues, bool drop);
+
 u8 ath9k_parse_mpdudensity(u8 mpdudensity)
 {
        /*
@@ -1701,6 +1704,15 @@ static int ath9k_set_key(struct ieee80211_hw *hw,
                return -EOPNOTSUPP;
        }
 
+       /* There may be MPDUs queued for the outgoing PTK key. Flush queues to
+        * make sure these are not send unencrypted or with a wrong (new) key
+        */
+       if (cmd == DISABLE_KEY && key->flags & IEEE80211_KEY_FLAG_PAIRWISE) {
+               ieee80211_stop_queues(hw);
+               ath9k_flush(hw, vif, 0, true);
+               ieee80211_wake_queues(hw);
+       }
+
        mutex_lock(&sc->mutex);
        ath9k_ps_wakeup(sc);
        ath_dbg(common, CONFIG, "Set HW Key %d\n", cmd);