From patchwork Mon Aug 13 22:42:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 177142 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) by ozlabs.org (Postfix) with ESMTP id 0F3EB2C0092 for ; Tue, 14 Aug 2012 08:40:40 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 760FC9D2F6; Mon, 13 Aug 2012 18:40:37 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lH3ifrGyxKbo; Mon, 13 Aug 2012 18:40:37 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id A09F99D30B; Mon, 13 Aug 2012 18:40:32 -0400 (EDT) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 1B1989D30B for ; Mon, 13 Aug 2012 18:40:32 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Os2kbIO2zzTv for ; Mon, 13 Aug 2012 18:40:28 -0400 (EDT) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id EAD7C9D2F6 for ; Mon, 13 Aug 2012 18:40:27 -0400 (EDT) Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q7DMeRQ1010708 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 13 Aug 2012 18:40:27 -0400 Received: from [10.3.238.205] (vpn-238-205.phx2.redhat.com [10.3.238.205]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q7DMeQUo022577; Mon, 13 Aug 2012 18:40:26 -0400 Message-ID: <1344897735.21212.43.camel@dcbw.foobar.com> Subject: [RFC PATCH] PMKSA: update current cache entry on association and disassociation From: Dan Williams To: j@w1.fi Date: Mon, 13 Aug 2012 17:42:15 -0500 Mime-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Cc: hostap@lists.shmoo.com X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com Ensure the current PMKSA cache entry pointer always points to the current BSSID's cache entry. Signed-hostap: Dan Williams --- src/rsn_supp/wpa.c | 10 +++++++++- src/rsn_supp/wpa.h | 2 +- wpa_supplicant/events.c | 2 +- wpa_supplicant/ibss_rsn.c | 2 +- wpa_supplicant/tests/test_wpa.c | 2 +- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/rsn_supp/wpa.c b/src/rsn_supp/wpa.c index abfef89..296e4f4 100644 --- a/src/rsn_supp/wpa.c +++ b/src/rsn_supp/wpa.c @@ -2103,11 +2103,12 @@ void wpa_sm_deinit(struct wpa_sm *sm) * wpa_sm_notify_assoc - Notify WPA state machine about association * @sm: Pointer to WPA state machine data from wpa_sm_init() * @bssid: The BSSID of the new association + * @network_ctx: Network configuration context for this BSSID * * This function is called to let WPA state machine know that the connection * was established. */ -void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid) +void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid, void *network_ctx) { int clear_ptk = 1; @@ -2123,6 +2124,12 @@ void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid) if (os_memcmp(sm->preauth_bssid, bssid, ETH_ALEN) == 0) rsn_preauth_deinit(sm); + if (!pmksa_cache_set_current(sm, NULL, bssid, network_ctx, 0)) { + wpa_printf(MSG_WARNING, "WPA: expected existing PMKSA cache " + "entry for " MACSTR " but none found", + MAC2STR(sm->bssid)); + } + #ifdef CONFIG_IEEE80211R if (wpa_ft_is_completed(sm)) { /* @@ -2165,6 +2172,7 @@ void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid) void wpa_sm_notify_disassoc(struct wpa_sm *sm) { rsn_preauth_deinit(sm); + pmksa_cache_clear_current (sm); if (wpa_sm_get_state(sm) == WPA_4WAY_HANDSHAKE) sm->dot11RSNA4WayHandshakeFailures++; #ifdef CONFIG_TDLS diff --git a/src/rsn_supp/wpa.h b/src/rsn_supp/wpa.h index 1077b5a..9d172f9 100644 --- a/src/rsn_supp/wpa.h +++ b/src/rsn_supp/wpa.h @@ -94,7 +94,7 @@ struct rsn_supp_config { struct wpa_sm * wpa_sm_init(struct wpa_sm_ctx *ctx); void wpa_sm_deinit(struct wpa_sm *sm); -void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid); +void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid, void *network_ctx); void wpa_sm_notify_disassoc(struct wpa_sm *sm); void wpa_sm_set_pmk(struct wpa_sm *sm, const u8 *pmk, size_t pmk_len); void wpa_sm_set_pmk_from_pmksa(struct wpa_sm *sm); diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index 5b70670..bc5ff9e 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -1583,7 +1583,7 @@ static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s, * smartcard or SIM/USIM. */ wpa_supplicant_scard_init(wpa_s, wpa_s->current_ssid); } - wpa_sm_notify_assoc(wpa_s->wpa, bssid); + wpa_sm_notify_assoc(wpa_s->wpa, bssid, wpa_s->current_ssid); if (wpa_s->l2) l2_packet_notify_auth_start(wpa_s->l2); diff --git a/wpa_supplicant/ibss_rsn.c b/wpa_supplicant/ibss_rsn.c index 046f181..e65163c 100644 --- a/wpa_supplicant/ibss_rsn.c +++ b/wpa_supplicant/ibss_rsn.c @@ -215,7 +215,7 @@ static int ibss_rsn_supp_init(struct ibss_rsn_peer *peer, const u8 *own_addr, return -1; } - wpa_sm_notify_assoc(peer->supp, peer->addr); + wpa_sm_notify_assoc(peer->supp, peer->addr, NULL); return 0; } diff --git a/wpa_supplicant/tests/test_wpa.c b/wpa_supplicant/tests/test_wpa.c index 0d659ad..8ff8e5c 100644 --- a/wpa_supplicant/tests/test_wpa.c +++ b/wpa_supplicant/tests/test_wpa.c @@ -205,7 +205,7 @@ static int supp_init(struct wpa *wpa) return -1; } - wpa_sm_notify_assoc(wpa->supp, wpa->auth_addr); + wpa_sm_notify_assoc(wpa->supp, wpa->auth_addr, NULL); return 0; }