mac80211: Helper function for marking STA authenticated
PATCH 1/3 mac80211: Helper function for marking STA authenticated
Authentication exchange can be completed in both TX and RX paths for SAE, so move this common functionality into a helper function to avoid having to implement practically the same operations in two places when extending SAE implementation in the following commits.
--- net/mac80211/mlme.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-)
net/mac80211/mlme.c +22 -12
@@ -2761,13 +2761,33 @@ static void ieee80211_auth_challenge(struct ieee80211_sub_if_data *sdata, auth_data->key_idx, tx_flags); } +static bool ieee80211_mark_sta_auth (struct ieee80211_sub_if_data *sdata, +const u8 *bssid) +{ +struct sta_info *sta; + +/* move station state to auth */ +mutex_lock (&sdata->local->sta_mtx); + sta =sta_info_get (sdata, bssid); +if (!sta) { +WARN_ONCE (1 ,"%s: STA %pM not found" , sdata->name, bssid); +return false; + } +if (sta_info_move_state (sta,IEEE80211_STA_AUTH )) { +sdata_info (sdata,"failed moving %pM to auth\n" , bssid); +return false; + } +mutex_unlock (&sdata->local->sta_mtx); + +return true; +} +static void ieee80211_rx_mgmt_auth (struct ieee80211_sub_if_data *sdata,struct ieee80211_mgmt *mgmt,size_t len) {struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;u8 bssid[ETH_ALEN ];u16 auth_alg, auth_transaction, status_code; -struct sta_info *sta;struct ieee80211_event event = { .type =MLME_EVENT , .u.mlme.data =AUTH_EVENT ,
@@ -2850,18 +2870,8 @@ static void ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata,return ; } -/* move station state to auth */ -mutex_lock (&sdata->local->sta_mtx); - sta =sta_info_get (sdata, bssid); -if (!sta) { -WARN_ONCE (1 ,"%s: STA %pM not found" , sdata->name, bssid); +if (!ieee80211_mark_sta_auth (sdata, bssid)) goto out_err; - } -if (sta_info_move_state (sta,IEEE80211_STA_AUTH )) { -sdata_info (sdata,"failed moving %pM to auth\n" , bssid); - goto out_err; - } -mutex_unlock (&sdata->local->sta_mtx);cfg80211_rx_mlme_mgmt (sdata->dev, (u8 *)mgmt, len);return ;
Signature · 1 line
2.7.4
PATCH 2/3 mac80211: Move ieee80211_mgd_auth() EBUSY check to be before allocation
This makes it easier to conditionally replace full allocation of auth_data to use reallocation for the case of continuing SAE authentication. Furthermore, there was not really any point in having this check done so late in the function after having already completed number of steps that cannot be used anyway in the error case.
--- net/mac80211/mlme.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
net/mac80211/mlme.c +4 -7
@@ -4922,6 +4922,10 @@ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,return -EOPNOTSUPP ; } +if ((ifmgd->auth_data && !ifmgd->auth_data->done) || + ifmgd->assoc_data) +return -EBUSY ; + auth_data =kzalloc (sizeof (*auth_data) + req->auth_data_len + req->ie_len,GFP_KERNEL );if (!auth_data)
@@ -4957,12 +4961,6 @@ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,/* try to authenticate/probe */ -if ((ifmgd->auth_data && !ifmgd->auth_data->done) || - ifmgd->assoc_data) { - err = -EBUSY ; - goto err_free; - } -if (ifmgd->auth_data)ieee80211_destroy_auth_data (sdata, false);
@@ -5007,7 +5005,6 @@ int ieee80211_mgd_auth(struct ieee80211_sub_if_data *sdata,mutex_lock (&sdata->local->mtx);ieee80211_vif_release_channel (sdata);mutex_unlock (&sdata->local->mtx); - err_free:kfree (auth_data);return err; }
Signature · 1 line
2.7.4
PATCH 3/3 mac80211: Extend SAE authentication in infra BSS STA mode
In reply to Jouni MalinenPrevious implementation of SAE authentication in infrastructure BSS was somewhat restricting and not exactly clean way of handling the two auth() operations. This ended up removing and re-adding the STA entry for the AP in the middle of authentication and also messing up authentication state tracking through the sequence of four Authentication frames. Furthermore, this did not work if the AP ended up sending out SAE Confirm (auth trans #2) immediately after SAE Commit (auth trans #1) before the station had time to transmit its SAE Confirm.
Clean up authentication state handling for the SAE case to allow two rounds of auth() calls without dropping all state between those operations. Track peer Confirmed status and mark authentication completed only once both ends have confirmed.
ieee80211_mgd_auth() check for EBUSY cases is now handling only the pending association (ifmgd->assoc_data) while all pending authentication (ifmgd->auth_data) cases are allowed to proceed to allow user space to start a new connection attempt from scratch even if the previously requested authentication is still waiting completion. This is needed to avoid making SAE error cases with retries take excessive amount of time with no means for the user space to stop that (apart from setting the netdev down).
As an extra bonus, the end of ieee80211_rx_mgmt_auth() can be cleaned up to avoid the extra copy of the cfg80211_rx_mlme_mgmt() call for ongoing SAE authentication since the new ieee80211_mark_sta_auth() helper function can handle both completion of authentication and updates to the STA entry under the same condition and there is no need to return from the function between those operations.
--- net/mac80211/ieee80211_i.h | 1 + net/mac80211/mlme.c | 70 +++++++++++++++++++++++++++++++--------------- 2 files changed, 48 insertions(+), 23 deletions(-)
net/mac80211/ieee80211_i.h +1 -0
@@ -377,6 +377,7 @@ struct ieee80211_mgd_auth_data {u8 key[WLAN_KEY_LEN_WEP104 ];u8 key_len, key_idx;bool done; +bool peer_confirmed;bool timeout_started;u16 sae_trans, sae_status;
net/mac80211/mlme.c +47 -23
126 lines not on this page · raw message
Signature · 1 line
2.7.4