linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
To: johannes@sipsolutions.net
Cc: linux-wireless@vger.kernel.org, Johannes Berg <johannes.berg@intel.com>
Subject: [PATCH 04/16] mac80211: fix another suspend vs. association race
Date: Sun,  1 Mar 2015 09:10:03 +0200	[thread overview]
Message-ID: <1425193815-17785-5-git-send-email-emmanuel.grumbach@intel.com> (raw)
In-Reply-To: <1425193815-17785-1-git-send-email-emmanuel.grumbach@intel.com>

From: Johannes Berg <johannes.berg@intel.com>

Since cfg80211 disconnects, but has no insight into the association
process, it can happen that it disconnects while association is in
progress. We then try to abort association in mac80211, but this is
only later so the association can complete between the two.

This results in removing an interface from the driver while bound
to the channel context, obviously causing confusion and issues.

Solve this by also checking if we're associated during quiesce and
if so deauthenticating. The frame will no longer go out to the AP
which is a bit unfortunate, but it'll resolve the crash (and before
we would have suspended without telling the AP as well.)

I'm working on a better, but more complex solution as well, which
should avoid that problem.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 net/mac80211/mlme.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index cf3ae93..c5f3bd6 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -3985,6 +3985,34 @@ void ieee80211_mgd_quiesce(struct ieee80211_sub_if_data *sdata)
 				      IEEE80211_DEAUTH_FRAME_LEN);
 	}
 
+	/* This is a bit of a hack - we should find a better and more generic
+	 * solution to this. Normally when suspending, cfg80211 will in fact
+	 * deauthenticate. However, it doesn't (and cannot) stop an ongoing
+	 * auth (not so important) or assoc (this is the problem) process.
+	 *
+	 * As a consequence, it can happen that we are in the process of both
+	 * associating and suspending, and receive an association response
+	 * after cfg80211 has checked if it needs to disconnect, but before
+	 * we actually set the flag to drop incoming frames. This will then
+	 * cause the workqueue flush to process the association response in
+	 * the suspend, resulting in a successful association just before it
+	 * tries to remove the interface from the driver, which now though
+	 * has a channel context assigned ... this results in issues.
+	 *
+	 * To work around this (for now) simply deauth here again if we're
+	 * now connected.
+	 */
+	if (ifmgd->associated && !sdata->local->wowlan) {
+		u8 bssid[ETH_ALEN];
+		struct cfg80211_deauth_request req = {
+			.reason_code = WLAN_REASON_DEAUTH_LEAVING,
+			.bssid = bssid,
+		};
+
+		memcpy(bssid, ifmgd->associated->bssid, ETH_ALEN);
+		ieee80211_mgd_deauth(sdata, &req);
+	}
+
 	sdata_unlock(sdata);
 }
 
-- 
1.9.1


  parent reply	other threads:[~2015-03-01  7:10 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-01  7:09 [PATCH 00/16] Various patches from our internal tree Emmanuel Grumbach
2015-03-01  7:10 ` [PATCH 01/16] mac80211: Update beacon's timing and DTIM count on every beacon Emmanuel Grumbach
2015-03-01  7:10 ` [PATCH 02/16] cfg80211: add operating classes 128-130 Emmanuel Grumbach
2015-03-01  7:10 ` [PATCH 03/16] mac80211: TDLS: support VHT between peers Emmanuel Grumbach
2015-03-01  7:10 ` Emmanuel Grumbach [this message]
2015-03-01  7:10 ` [PATCH 05/16] mac80211: handle drv_add_interface failures properly during reconfig Emmanuel Grumbach
2015-03-01  7:10 ` [PATCH 06/16] mac80211: tell drivers the user TX power restriction Emmanuel Grumbach
2015-03-04  9:34   ` Johannes Berg
2015-03-01  7:10 ` [PATCH 07/16] mac80211: don't do driver suspend with auth/assoc in progress Emmanuel Grumbach
2015-03-01  7:10 ` [PATCH 08/16] mac80211: remove useless double check for open_count in __ieee80211_suspend() Emmanuel Grumbach
2015-03-01  7:10 ` [PATCH 09/16] mac80211: start queues if driver rejected wowlan Emmanuel Grumbach
2015-03-01  7:10 ` [PATCH 10/16] mac80211: allow TDLS setup code to take wdev lock Emmanuel Grumbach
2015-03-01  7:10 ` [PATCH 11/16] mac80211: remove duplicate check for quiescing when queueing work Emmanuel Grumbach
2015-03-01  7:10 ` [PATCH 12/16] mac80211: update TDLS sta spatial streams before auth Emmanuel Grumbach
2015-03-01  7:10 ` [PATCH 13/16] mac80211: check and dequeue skb in ieee80211_tx_prepare_skb() Emmanuel Grumbach
2015-03-01  7:10 ` [PATCH 14/16] nl80211: prohibit mixing 'any' and regular wowlan triggers Emmanuel Grumbach
2015-03-01  7:10 ` [PATCH 15/16] mac80211: remove channel_switch_beacon operation Emmanuel Grumbach
2015-03-01  7:10 ` [PATCH 16/16] mac80211: allow iterating inactive interfaces Emmanuel Grumbach
2015-03-03  9:47 ` [PATCH 00/16] Various patches from our internal tree Johannes Berg
2015-03-03 10:01   ` Johannes Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1425193815-17785-5-git-send-email-emmanuel.grumbach@intel.com \
    --to=emmanuel.grumbach@intel.com \
    --cc=johannes.berg@intel.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).