aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/mlme.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2014-03-19 04:11:19 -0400
committerJohannes Berg <johannes.berg@intel.com>2014-03-19 16:29:53 -0400
commitc9c3a0604614344f7c73523176b6d0a85cba6eab (patch)
tree0794174f0ec4835ef18530c305b7dadb27b785a9 /net/mac80211/mlme.c
parentd2722f8b87fb172ff2f31d3a2816b31d58678d40 (diff)
mac80211: verify deauthentication and return error on failure
When still authenticating the mac80211 code handling a deauthentication requests from userspace doesn't verify that the request is valid in any way, fix that. Additionally, it never returns an error, even if there's no connection or authentication attempt, fix that as well. While at it, move the message to not print a message in the error case and to distinguish between the two cases. Also simplify the code by duplicating the cfg80211 call. Reviewed-by: Luciano Coelho <luciano.coelho@intel.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/mac80211/mlme.c')
-rw-r--r--net/mac80211/mlme.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 423816f18b55..5ade21eb3602 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -4393,37 +4393,41 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata,
4393 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 4393 struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
4394 u8 frame_buf[IEEE80211_DEAUTH_FRAME_LEN]; 4394 u8 frame_buf[IEEE80211_DEAUTH_FRAME_LEN];
4395 bool tx = !req->local_state_change; 4395 bool tx = !req->local_state_change;
4396 bool report_frame = false;
4397 4396
4398 sdata_info(sdata, 4397 if (ifmgd->auth_data &&
4399 "deauthenticating from %pM by local choice (Reason: %u=%s)\n", 4398 ether_addr_equal(ifmgd->auth_data->bss->bssid, req->bssid)) {
4400 req->bssid, req->reason_code, ieee80211_get_reason_code_string(req->reason_code)); 4399 sdata_info(sdata,
4400 "aborting authentication with %pM by local choice (Reason: %u=%s)\n",
4401 req->bssid, req->reason_code,
4402 ieee80211_get_reason_code_string(req->reason_code));
4401 4403
4402 if (ifmgd->auth_data) {
4403 drv_mgd_prepare_tx(sdata->local, sdata); 4404 drv_mgd_prepare_tx(sdata->local, sdata);
4404 ieee80211_send_deauth_disassoc(sdata, req->bssid, 4405 ieee80211_send_deauth_disassoc(sdata, req->bssid,
4405 IEEE80211_STYPE_DEAUTH, 4406 IEEE80211_STYPE_DEAUTH,
4406 req->reason_code, tx, 4407 req->reason_code, tx,
4407 frame_buf); 4408 frame_buf);
4408 ieee80211_destroy_auth_data(sdata, false); 4409 ieee80211_destroy_auth_data(sdata, false);
4410 cfg80211_tx_mlme_mgmt(sdata->dev, frame_buf,
4411 IEEE80211_DEAUTH_FRAME_LEN);
4409 4412
4410 report_frame = true; 4413 return 0;
4411 goto out;
4412 } 4414 }
4413 4415
4414 if (ifmgd->associated && 4416 if (ifmgd->associated &&
4415 ether_addr_equal(ifmgd->associated->bssid, req->bssid)) { 4417 ether_addr_equal(ifmgd->associated->bssid, req->bssid)) {
4418 sdata_info(sdata,
4419 "deauthenticating from %pM by local choice (Reason: %u=%s)\n",
4420 req->bssid, req->reason_code,
4421 ieee80211_get_reason_code_string(req->reason_code));
4422
4416 ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH, 4423 ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH,
4417 req->reason_code, tx, frame_buf); 4424 req->reason_code, tx, frame_buf);
4418 report_frame = true;
4419 }
4420
4421 out:
4422 if (report_frame)
4423 cfg80211_tx_mlme_mgmt(sdata->dev, frame_buf, 4425 cfg80211_tx_mlme_mgmt(sdata->dev, frame_buf,
4424 IEEE80211_DEAUTH_FRAME_LEN); 4426 IEEE80211_DEAUTH_FRAME_LEN);
4427 return 0;
4428 }
4425 4429
4426 return 0; 4430 return -ENOTCONN;
4427} 4431}
4428 4432
4429int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata, 4433int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata,