]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
SAE: Fix sm->cur_pmksa assignment
authorHu Wang <huw@codeaurora.org>
Mon, 25 Oct 2021 10:58:38 +0000 (16:28 +0530)
committerJouni Malinen <j@w1.fi>
Mon, 25 Oct 2021 16:03:32 +0000 (19:03 +0300)
Commit b0f457b6191 ("SAE: Do not expire the current PMKSA cache entry")
depends on sm->cur_pmksa to determine if it is the current PMKSA cache
entry, but sm->cur_pmksa was not always correct for SAE in the current
implementation.

Set sm->cur_pmksa in wpa_sm_set_pmk() (which is used with SAE), and skip
clearing of sm->cur_pmksa for SAE in wpa_find_assoc_pmkid(). This latter
case was added by commit c2080e8657f8 ("Clear current PMKSA cache
selection on association/roam") for driver-based roaming indication and
Suite B, so skipping it for SAE should be fine.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
src/rsn_supp/wpa.c
wpa_supplicant/events.c

index 8aa649ac45795d17499eb0129d5a81b988db8fc5..0a2f8778750487b6568c3a9f91f093010b96246c 100644 (file)
@@ -3132,9 +3132,11 @@ void wpa_sm_set_pmk(struct wpa_sm *sm, const u8 *pmk, size_t pmk_len,
 #endif /* CONFIG_IEEE80211R */
 
        if (bssid) {
-               pmksa_cache_add(sm->pmksa, pmk, pmk_len, pmkid, NULL, 0,
-                               bssid, sm->own_addr,
-                               sm->network_ctx, sm->key_mgmt, NULL);
+               sm->cur_pmksa = pmksa_cache_add(sm->pmksa, pmk, pmk_len,
+                                               pmkid, NULL, 0, bssid,
+                                               sm->own_addr,
+                                               sm->network_ctx, sm->key_mgmt,
+                                               NULL);
        }
 }
 
index 7b892dac2a5c76f22a8e87f68949ca2335276118..6fe3426d0884c4c802c739df7e5947ad88eb84f4 100644 (file)
@@ -356,9 +356,14 @@ static void wpa_find_assoc_pmkid(struct wpa_supplicant *wpa_s)
        struct wpa_ie_data ie;
        int pmksa_set = -1;
        size_t i;
-
-       /* Start with assumption of no PMKSA cache entry match */
-       pmksa_cache_clear_current(wpa_s->wpa);
+       struct rsn_pmksa_cache_entry *cur_pmksa;
+
+       /* Start with assumption of no PMKSA cache entry match for cases other
+        * than SAE. In particular, this is needed to generate the PMKSA cache
+        * entries for Suite B cases with driver-based roaming indication. */
+       cur_pmksa = pmksa_cache_get_current(wpa_s->wpa);
+       if (cur_pmksa && !wpa_key_mgmt_sae(cur_pmksa->akmp))
+               pmksa_cache_clear_current(wpa_s->wpa);
 
        if (wpa_sm_parse_own_wpa_ie(wpa_s->wpa, &ie) < 0 ||
            ie.pmkid == NULL)