freebsd-skq/sys/net80211
adrian 151389a51e Fix a use-after-free node reference issue when waiting for a return
from a management frame transmission.

This bug is a bit loopy, so here goes.

The underlying cause is pretty easy to understand - the node isn't
referenced before passing into the callout, so if the node is deleted
before the callout fires, it'll dereference free'd memory.

The code path however is slightly more convoluted.

The functions _say_ mgt_tx - ie management transmit - which is partially
true.  Yes, that callback is attached to the mbuf for some management
frames.  However, it's only for frames relating to scanning and
authentication attempts.  It helpfully drives the VAP state back to
"SCAN" if the transmission fails _OR_ (as I subsequently found out!)
if the transmission succeeds but the state machine doesn't make progress
towards being authenticated and active.

Now, the code itself isn't terribly clear about this.

It _looks_ like it's just handling the transmit failure case.

However, when you look at what goes on in the transmit success case, it's
moving the VAP state back to SCAN if it hasn't changed state since
the time the callback was scheduled.  Ie, if it's in ASSOC or AUTH still,
it'll go back to SCAN.  But if it has transitioned to the RUN state,
the comparison will fail and it'll not transition things back to the
SCAN state.

So, to fix this, I decided to leave everything the way it is and merely
fix the locking and remove the node reference.

The _better_ fix would be to turn this callout into a "assoc/auth request"
timeout callback and make the callout locked, thus eliminating all races.
However, until all the drivers have been fixed so that transmit completions
occur outside of any locking that's going on, it's going to be impossible
to do this without introducing LORs.  So, I leave some of the evilness
in there.

Tested:

* AR5212, ath(4), STA mode
* 5100 and 4965 wifi, iwn(4), STA mode
2013-10-24 17:04:16 +00:00
..
_ieee80211.h Add a check for dynamic OFDM/CCK channel types. 2012-07-01 04:25:49 +00:00
ieee80211_acl.c Remove now redundant mac argument. 2011-12-17 10:32:31 +00:00
ieee80211_action.c Replace the homegrown implementation of nitems() with calls to nitems() 2013-08-14 04:24:25 +00:00
ieee80211_action.h
ieee80211_adhoc.c Disable this variable; the code using it is also disabled. 2013-02-18 01:37:55 +00:00
ieee80211_adhoc.h
ieee80211_ageq.c Fix memset sizeofs 2011-07-07 15:41:40 +00:00
ieee80211_ageq.h
ieee80211_alq.c Re-commit this - store the alq payload in network order. 2012-03-21 03:19:50 +00:00
ieee80211_alq.h .. revert out a local change that I hadn't yet completely finished fleshing 2012-03-18 21:54:59 +00:00
ieee80211_amrr.c Document the current 11n rate selection shortcoming in the AMRR code. 2013-07-05 00:03:53 +00:00
ieee80211_amrr.h
ieee80211_crypto_ccmp.c
ieee80211_crypto_none.c
ieee80211_crypto_tkip.c
ieee80211_crypto_wep.c
ieee80211_crypto.c
ieee80211_crypto.h
ieee80211_ddb.c Update ddb to print mesh routing table. 2013-02-07 21:29:48 +00:00
ieee80211_dfs.c Add a DFS debugging mode which is useful when doing automated DFS 2012-01-31 00:03:49 +00:00
ieee80211_dfs.h Add a DFS debugging mode which is useful when doing automated DFS 2012-01-31 00:03:49 +00:00
ieee80211_freebsd.c Fix the "am I a net80211 vap" check for bpf listeners. 2013-10-10 19:56:31 +00:00
ieee80211_freebsd.h Add in some backwards compatability hacks to make -HEAD net80211 compile 2013-08-22 05:53:47 +00:00
ieee80211_hostap.c Add in some backwards compatability hacks to make -HEAD net80211 compile 2013-08-22 05:53:47 +00:00
ieee80211_hostap.h Migrate the power-save functions to be overridable VAP methods. 2012-10-02 17:45:19 +00:00
ieee80211_ht.c Fix a VAP BSS node reference in the HT code to actually take a reference 2013-05-10 09:37:58 +00:00
ieee80211_ht.h Migrate the net80211 TX aggregation state to be from per-AC to per-TID. 2012-04-15 20:29:39 +00:00
ieee80211_hwmp.c Convert net80211 over to using if_transmit for the dispatch from the 2013-08-08 05:09:35 +00:00
ieee80211_input.c Add in some backwards compatability hacks to make -HEAD net80211 compile 2013-08-22 05:53:47 +00:00
ieee80211_input.h Fix some corner cases in the net80211 sequence number retransmission 2011-05-04 02:23:59 +00:00
ieee80211_ioctl.c Don't panic the kernel if we run wpa_supplicant on a hostap VAP. 2013-06-29 06:36:42 +00:00
ieee80211_ioctl.h Update net80211 mesh struct ieee80211_meshgann_ie. 2013-02-07 21:20:28 +00:00
ieee80211_mesh.c Convert net80211 over to using if_transmit for the dispatch from the 2013-08-08 05:09:35 +00:00
ieee80211_mesh.h HWMP: ic->raw_xmit didn't always point to correct ni. 2013-02-07 21:26:40 +00:00
ieee80211_monitor.c
ieee80211_monitor.h
ieee80211_node.c Replace the homegrown implementation of nitems() with calls to nitems() 2013-08-14 04:24:25 +00:00
ieee80211_node.h Stop a mesh STA from flooding with peer frames. 2013-02-07 21:12:55 +00:00
ieee80211_output.c Fix a use-after-free node reference issue when waiting for a return 2013-10-24 17:04:16 +00:00
ieee80211_phy.c Replace the homegrown implementation of nitems() with calls to nitems() 2013-08-14 04:24:25 +00:00
ieee80211_phy.h Implement basic 802.11n awareness in the PHY and AMRR rate control code. 2013-07-04 21:16:49 +00:00
ieee80211_power.c Blank m_nextpkt before passing it up. 2013-08-12 22:27:53 +00:00
ieee80211_power.h Migrate the power-save functions to be overridable VAP methods. 2012-10-02 17:45:19 +00:00
ieee80211_proto.c Fix a use-after-free node reference issue when waiting for a return 2013-10-24 17:04:16 +00:00
ieee80211_proto.h Fix a use-after-free node reference issue when waiting for a return 2013-10-24 17:04:16 +00:00
ieee80211_radiotap.c Extend the radiotap code to be aware of the size of any extra vendor 2012-06-18 02:08:04 +00:00
ieee80211_radiotap.h Add in the missing radiotap definitions from the sipsolutions.net 2013-01-08 06:59:21 +00:00
ieee80211_ratectl_none.c
ieee80211_ratectl.c
ieee80211_ratectl.h
ieee80211_regdomain.c Add basic HT channel setup to ieee80211_init_channels(), this will be 2012-04-03 17:48:42 +00:00
ieee80211_regdomain.h Add a new 900MHz GSM regulatory SKU for the Xagyl Communications XC900M. 2012-12-07 06:34:46 +00:00
ieee80211_rssadapt.c
ieee80211_rssadapt.h
ieee80211_scan_sta.c Replace the homegrown implementation of nitems() with calls to nitems() 2013-08-14 04:24:25 +00:00
ieee80211_scan.c Migrate the power-save functions to be overridable VAP methods. 2012-10-02 17:45:19 +00:00
ieee80211_scan.h Add 802.11h quiet time element support into net80211. 2011-11-08 04:00:24 +00:00
ieee80211_sta.c Handle ath-specific and WME IE's in adhoc mode. 2012-12-09 22:56:29 +00:00
ieee80211_sta.h Handle ath-specific and WME IE's in adhoc mode. 2012-12-09 22:56:29 +00:00
ieee80211_superg.c Migrate the ff_encap1() routine out into the normal output code. 2013-08-26 09:52:05 +00:00
ieee80211_superg.h Atheros SuperG bug fixes, as part of hunting down kern/174283. 2012-12-09 19:20:28 +00:00
ieee80211_tdma.c Don't return ENOTSUPP here - the net80211 pluggable ioctl API will treat 2013-08-18 23:40:30 +00:00
ieee80211_tdma.h
ieee80211_var.h Allow net80211 to compile on stable/9 and stable/8. 2013-08-07 22:01:43 +00:00
ieee80211_wds.c Convert net80211 over to using if_transmit for the dispatch from the 2013-08-08 05:09:35 +00:00
ieee80211_wds.h
ieee80211_xauth.c
ieee80211.c Replace the homegrown implementation of nitems() with calls to nitems() 2013-08-14 04:24:25 +00:00
ieee80211.h Add ieee80211_add_{qos,wpa,rsn}() functions since they are needed by an 2013-07-25 06:23:26 +00:00