From b4a41abad4821223c39b5fbb236d55ac99d60df1 Mon Sep 17 00:00:00 2001 From: Vamsi Krishna Date: Fri, 18 Dec 2020 22:50:00 +0530 Subject: [PATCH] nl80211: Do not ignore disconnection event after a connection event After a disconnect command is issued, wpa_supplicant generates a disconnection event to self and ignores the next disconnection event coming from the driver. In a race condition in which the driver generates a connected event due to roaming just before receiving the disconnect command from userspace, wpa_supplicant processes the connected event after processing the self-generated disconnection event and enters WPA_COMPLETED state. The driver sends a disconnection event after processing the disconnect command sent by wpa_supplicant but the disconnection event is ignored by wpa_supplicant as the disconnection event is considered to be a result of locally generated disconnect command. Thus, wpa_supplicant continues to be in the connected (WPA_COMPLETED) state though the driver is in disconnected state. Fix this out-of-sync behavior between the driver and wpa_supplicant by not ignoring the disconnection event from the driver because of the locally generated disconnect command sent to the driver if there is a connection event received after issuing the disconnect command to the driver. Signed-off-by: Jouni Malinen --- src/drivers/driver_nl80211_event.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/drivers/driver_nl80211_event.c b/src/drivers/driver_nl80211_event.c index a3e2eee93..3af13f410 100644 --- a/src/drivers/driver_nl80211_event.c +++ b/src/drivers/driver_nl80211_event.c @@ -571,6 +571,13 @@ static void mlme_event_connect(struct wpa_driver_nl80211_data *drv, event.assoc_info.fils_pmkid = nla_data(fils_pmkid); wpa_supplicant_event(drv->ctx, EVENT_ASSOC, &event); + + /* Avoid a race condition by stopping to ignore any following + * disconnection events now that the driver has indicated it is + * connected since that connection could have been triggered by a roam + * operation that happened in parallel with the disconnection request. + */ + drv->ignore_next_local_disconnect = 0; }