summaryrefslogtreecommitdiffstats
path: root/sys/net80211/ieee80211_proto.c
diff options
context:
space:
mode:
authoradrian <adrian@FreeBSD.org>2011-10-02 02:42:31 +0000
committeradrian <adrian@FreeBSD.org>2011-10-02 02:42:31 +0000
commite4db1744452286cf0ae874147a0706e4eef80e5e (patch)
tree41799f0a121c731123911edcc80de132275765d6 /sys/net80211/ieee80211_proto.c
parent5f61f37453ab1ec33e8e5eda58b46a0d1f11f78a (diff)
downloadFreeBSD-src-e4db1744452286cf0ae874147a0706e4eef80e5e.zip
FreeBSD-src-e4db1744452286cf0ae874147a0706e4eef80e5e.tar.gz
Fix a panic in the wifi stack when a software beacon miss occurs in the wrong state.
The ieee80211_swbmiss() callout is not called with the ic lock held, so it's quite possible the scheduler will run the callout during a state change. This patch: * changes the swbmiss callout to be locked by the ic lock * enforces the ic lock being held across the beacon vap functions by grabbing it inside beacon_miss() and beacon_swmiss(). This ensures that the ic lock is held (and thus the VAP state stays constant) during beacon miss and software miss processing. Since the callout is removed whilst the ic lock is held, it also ensures that the ic lock can't be called during a state change or exhibit any race conditions seen above. Both Edgar and Joel report that this patch fixes the crash and doesn't introduce new issues. Reported by: Edgar Martinez <emartinez@kbcnetworks.com> Reported by: Joel Dahl <joel@vnode.se> Reported by: emaste
Diffstat (limited to 'sys/net80211/ieee80211_proto.c')
-rw-r--r--sys/net80211/ieee80211_proto.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/sys/net80211/ieee80211_proto.c b/sys/net80211/ieee80211_proto.c
index 8dee3f7..b4288b7 100644
--- a/sys/net80211/ieee80211_proto.c
+++ b/sys/net80211/ieee80211_proto.c
@@ -193,7 +193,7 @@ ieee80211_proto_vattach(struct ieee80211vap *vap)
vap->iv_rtsthreshold = IEEE80211_RTS_DEFAULT;
vap->iv_fragthreshold = IEEE80211_FRAG_DEFAULT;
vap->iv_bmiss_max = IEEE80211_BMISS_MAX;
- callout_init(&vap->iv_swbmiss, CALLOUT_MPSAFE);
+ callout_init_mtx(&vap->iv_swbmiss, IEEE80211_LOCK_OBJ(ic), 0);
callout_init(&vap->iv_mgtsend, CALLOUT_MPSAFE);
TASK_INIT(&vap->iv_nstate_task, 0, ieee80211_newstate_cb, vap);
TASK_INIT(&vap->iv_swbmiss_task, 0, beacon_swmiss, vap);
@@ -1403,7 +1403,7 @@ beacon_miss(void *arg, int npending)
struct ieee80211com *ic = arg;
struct ieee80211vap *vap;
- /* XXX locking */
+ IEEE80211_LOCK(ic);
TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
/*
* We only pass events through for sta vap's in RUN state;
@@ -1415,18 +1415,21 @@ beacon_miss(void *arg, int npending)
vap->iv_bmiss != NULL)
vap->iv_bmiss(vap);
}
+ IEEE80211_UNLOCK(ic);
}
static void
beacon_swmiss(void *arg, int npending)
{
struct ieee80211vap *vap = arg;
+ struct ieee80211com *ic = vap->iv_ic;
- if (vap->iv_state != IEEE80211_S_RUN)
- return;
-
- /* XXX Call multiple times if npending > zero? */
- vap->iv_bmiss(vap);
+ IEEE80211_LOCK(ic);
+ if (vap->iv_state == IEEE80211_S_RUN) {
+ /* XXX Call multiple times if npending > zero? */
+ vap->iv_bmiss(vap);
+ }
+ IEEE80211_UNLOCK(ic);
}
/*
@@ -1440,6 +1443,8 @@ ieee80211_swbmiss(void *arg)
struct ieee80211vap *vap = arg;
struct ieee80211com *ic = vap->iv_ic;
+ IEEE80211_LOCK_ASSERT(ic);
+
/* XXX sleep state? */
KASSERT(vap->iv_state == IEEE80211_S_RUN,
("wrong state %d", vap->iv_state));
OpenPOWER on IntegriCloud