* [PATCH v2] mac80211: verify deauthentication and return error on failure
@ 2014-03-19 8:28 Johannes Berg
2014-03-19 8:35 ` Luca Coelho
0 siblings, 1 reply; 2+ messages in thread
From: Johannes Berg @ 2014-03-19 8:28 UTC (permalink / raw)
To: linux-wireless; +Cc: Johannes Berg
From: Johannes Berg <johannes.berg@intel.com>
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.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
net/mac80211/mlme.c | 30 +++++++++++++++++-------------
1 file 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,
struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
u8 frame_buf[IEEE80211_DEAUTH_FRAME_LEN];
bool tx = !req->local_state_change;
- bool report_frame = false;
- sdata_info(sdata,
- "deauthenticating from %pM by local choice (Reason: %u=%s)\n",
- req->bssid, req->reason_code, ieee80211_get_reason_code_string(req->reason_code));
+ if (ifmgd->auth_data &&
+ ether_addr_equal(ifmgd->auth_data->bss->bssid, req->bssid)) {
+ sdata_info(sdata,
+ "aborting authentication with %pM by local choice (Reason: %u=%s)\n",
+ req->bssid, req->reason_code,
+ ieee80211_get_reason_code_string(req->reason_code));
- if (ifmgd->auth_data) {
drv_mgd_prepare_tx(sdata->local, sdata);
ieee80211_send_deauth_disassoc(sdata, req->bssid,
IEEE80211_STYPE_DEAUTH,
req->reason_code, tx,
frame_buf);
ieee80211_destroy_auth_data(sdata, false);
+ cfg80211_tx_mlme_mgmt(sdata->dev, frame_buf,
+ IEEE80211_DEAUTH_FRAME_LEN);
- report_frame = true;
- goto out;
+ return 0;
}
if (ifmgd->associated &&
ether_addr_equal(ifmgd->associated->bssid, req->bssid)) {
+ sdata_info(sdata,
+ "deauthenticating from %pM by local choice (Reason: %u=%s)\n",
+ req->bssid, req->reason_code,
+ ieee80211_get_reason_code_string(req->reason_code));
+
ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH,
req->reason_code, tx, frame_buf);
- report_frame = true;
- }
-
- out:
- if (report_frame)
cfg80211_tx_mlme_mgmt(sdata->dev, frame_buf,
IEEE80211_DEAUTH_FRAME_LEN);
+ return 0;
+ }
- return 0;
+ return -ENOTCONN;
}
int ieee80211_mgd_disassoc(struct ieee80211_sub_if_data *sdata,
--
1.8.5.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] mac80211: verify deauthentication and return error on failure
2014-03-19 8:28 [PATCH v2] mac80211: verify deauthentication and return error on failure Johannes Berg
@ 2014-03-19 8:35 ` Luca Coelho
0 siblings, 0 replies; 2+ messages in thread
From: Luca Coelho @ 2014-03-19 8:35 UTC (permalink / raw)
To: Johannes Berg; +Cc: linux-wireless, Johannes Berg
On Wed, 2014-03-19 at 09:28 +0100, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg@intel.com>
>
> 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.
>
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
> ---
Reviewed-by: Luciano Coelho <luciano.coelho@intel.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-03-19 8:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-19 8:28 [PATCH v2] mac80211: verify deauthentication and return error on failure Johannes Berg
2014-03-19 8:35 ` Luca Coelho
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).