From 41638606054a09867fe3f9a2b5523aa4678cbfa5 Mon Sep 17 00:00:00 2001 From: Vinayak Yadawad Date: Thu, 30 Jun 2022 09:37:53 +0530 Subject: [PATCH] Mark authorization completed on driver indication during 4-way HS offload In case of drivers supporting 4-way handshake offload, mark port authorized and state completion only if the driver advertizes authorized state in the connect event. Otherwise there are fair chances of the driver port authorization API getting called while 4-way handshake is in progress at the lower layer. In order to avoid this possible race condition always update port authorization and supplicant state WPA_COMPLETED setting from EVENT_PORT_AUTHORIZED context when the driver is done with the 4-way handshake. Signed-off-by: Vinayak Yadawad --- wpa_supplicant/events.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index 35f3694a0..788ef5bdf 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -3671,14 +3671,23 @@ static void wpa_supplicant_event_assoc(struct wpa_supplicant *wpa_s, eapol_sm_notify_eap_success(wpa_s->eapol, true); } else if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE_PSK) && wpa_key_mgmt_wpa_psk(wpa_s->key_mgmt)) { - /* - * We are done; the driver will take care of RSN 4-way - * handshake. - */ - wpa_supplicant_cancel_auth_timeout(wpa_s); - wpa_supplicant_set_state(wpa_s, WPA_COMPLETED); - eapol_sm_notify_portValid(wpa_s->eapol, true); - eapol_sm_notify_eap_success(wpa_s->eapol, true); + if (already_authorized) { + /* + * We are done; the driver will take care of RSN 4-way + * handshake. + */ + wpa_supplicant_cancel_auth_timeout(wpa_s); + wpa_supplicant_set_state(wpa_s, WPA_COMPLETED); + eapol_sm_notify_portValid(wpa_s->eapol, true); + eapol_sm_notify_eap_success(wpa_s->eapol, true); + } else { + /* Update port, WPA_COMPLETED state from the + * EVENT_PORT_AUTHORIZED handler when the driver is done + * with the 4-way handshake. + */ + wpa_msg(wpa_s, MSG_DEBUG, + "ASSOC INFO: wait for driver port authorized indication"); + } } else if ((wpa_s->drv_flags & WPA_DRIVER_FLAGS_4WAY_HANDSHAKE_8021X) && wpa_key_mgmt_wpa_ieee8021x(wpa_s->key_mgmt)) { /*