linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] mac80211: fix racy usage of chanctx->refcount
@ 2014-03-07 11:19 Michal Kazior
  2014-03-07 11:19 ` [PATCH 2/3] mac80211: include ieee80211_local in chanctx Michal Kazior
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Michal Kazior @ 2014-03-07 11:19 UTC (permalink / raw)
  To: linux-wireless; +Cc: johannes, Michal Kazior

Channel context refcount is protected by
chanctx_mtx. Accessing the value without holding
the mutex is racy. RCU section didn't guarantee
anything here.

Theoretically ieee80211_channel_switch() could
fail to see refcount change and read "1" instead
of, e.g. "2". This means mac80211 could accept CSA
even though it shouldn't have.

Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
---
 net/mac80211/cfg.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index aaa59d7..a79875c 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -3233,23 +3233,23 @@ int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
 				       &sdata->vif.bss_conf.chandef))
 		return -EINVAL;
 
-	rcu_read_lock();
+	mutex_lock(&local->chanctx_mtx);
 	chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
 	if (!chanctx_conf) {
-		rcu_read_unlock();
+		mutex_unlock(&local->chanctx_mtx);
 		return -EBUSY;
 	}
 
 	/* don't handle for multi-VIF cases */
 	chanctx = container_of(chanctx_conf, struct ieee80211_chanctx, conf);
 	if (chanctx->refcount > 1) {
-		rcu_read_unlock();
+		mutex_unlock(&local->chanctx_mtx);
 		return -EBUSY;
 	}
 	num_chanctx = 0;
 	list_for_each_entry_rcu(chanctx, &local->chanctx_list, list)
 		num_chanctx++;
-	rcu_read_unlock();
+	mutex_unlock(&local->chanctx_mtx);
 
 	if (num_chanctx > 1)
 		return -EBUSY;
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2014-03-19 14:05 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-07 11:19 [PATCH 1/3] mac80211: fix racy usage of chanctx->refcount Michal Kazior
2014-03-07 11:19 ` [PATCH 2/3] mac80211: include ieee80211_local in chanctx Michal Kazior
2014-03-10 20:27   ` Johannes Berg
2014-03-11  7:36     ` Michal Kazior
2014-03-07 11:19 ` [PATCH 3/3] mac80211: compute chanctx refcount dynamically Michal Kazior
2014-03-07 14:44   ` Johannes Berg
2014-03-08  4:34     ` Zhao, Gang
2014-03-09  9:47   ` Eliad Peller
2014-03-09 15:15     ` Eliad Peller
2014-03-11  7:46   ` Michal Kazior
2014-03-11 13:16     ` Johannes Berg
2014-03-11 13:33       ` Michal Kazior
2014-03-19 14:05         ` Johannes Berg
2014-03-09  9:40 ` [PATCH 1/3] mac80211: fix racy usage of chanctx->refcount Eliad Peller
2014-03-10 20:29   ` Johannes Berg

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).