From: Jouni Malinen Date: Fri, 10 Aug 2012 15:05:03 +0000 (+0300) Subject: PMKSA: Set cur_pmksa pointer during initial association X-Git-Tag: hostap_2_0~450 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a7f10d65f40939d855fd996374e465d7c55b797f;p=thirdparty%2Fhostap.git PMKSA: Set cur_pmksa pointer during initial association cur_pmksa was left to NULL during the initial association. This can result in unexpected behavior, e.g., in expiring PMKSA cache entries since the current entry is not locked in that case. Fix this by updated cur_pmksa when adding the initial PMKSA entry during msg 1/4 processing. Signed-hostap: Jouni Malinen intended-for: hostap-1 --- diff --git a/src/rsn_supp/wpa.c b/src/rsn_supp/wpa.c index c181c51c9..d7d796399 100644 --- a/src/rsn_supp/wpa.c +++ b/src/rsn_supp/wpa.c @@ -190,14 +190,17 @@ static int wpa_supplicant_get_pmk(struct wpa_sm *sm, #endif /* CONFIG_IEEE80211R */ } if (res == 0) { + struct rsn_pmksa_cache_entry *sa = NULL; wpa_hexdump_key(MSG_DEBUG, "WPA: PMK from EAPOL state " "machines", sm->pmk, pmk_len); sm->pmk_len = pmk_len; if (sm->proto == WPA_PROTO_RSN && !wpa_key_mgmt_ft(sm->key_mgmt)) { - pmksa_cache_add(sm->pmksa, sm->pmk, pmk_len, - src_addr, sm->own_addr, - sm->network_ctx, sm->key_mgmt); + sa = pmksa_cache_add(sm->pmksa, + sm->pmk, pmk_len, + src_addr, sm->own_addr, + sm->network_ctx, + sm->key_mgmt); } if (!sm->cur_pmksa && pmkid && pmksa_cache_get(sm->pmksa, src_addr, pmkid, NULL)) @@ -207,6 +210,9 @@ static int wpa_supplicant_get_pmk(struct wpa_sm *sm, "PMKID"); abort_cached = 0; } + + if (!sm->cur_pmksa) + sm->cur_pmksa = sa; } else { wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, "WPA: Failed to get master session key from "