freebsd-dev/sys
Adrian Chadd e94527beaf 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
..
amd64 Add a new capability, VM_CAP_ENABLE_INVPCID, that can be enabled to expose 2013-10-16 18:20:27 +00:00
arm Add the Raspberry Pi SPI controller driver. 2013-10-24 16:27:33 +00:00
boot Add the Raspberry Pi SPI controller driver. 2013-10-24 16:27:33 +00:00
bsm Change the cap_rights_t type from uint64_t to a structure that we can extend 2013-09-05 00:09:56 +00:00
cam Some microoptimizations for da and ada drivers: 2013-10-24 14:05:44 +00:00
cddl Improve ZFS N-way mirror read performance by using load and locality 2013-10-23 09:54:58 +00:00
compat Add padding to match the compat32 struct stat32 definition to the real 2013-10-04 22:05:23 +00:00
conf Add an OFW SPI compatible bus. Fix the spibus probe to return 2013-10-24 16:56:38 +00:00
contrib Update firmware for run(4) to version 0.33. 2013-10-18 07:40:50 +00:00
crypto Use the fact that the AES-NI instructions can be pipelined to improve 2013-09-03 18:31:23 +00:00
ddb
dev Add an OFW SPI compatible bus. Fix the spibus probe to return 2013-10-24 16:56:38 +00:00
fs UFS2: make di_extsize unsigned. 2013-10-24 00:33:29 +00:00
gdb rename scheduler->swapper and SI_SUB_RUN_SCHEDULER->SI_SUB_LAST 2013-07-24 09:45:31 +00:00
geom Improve ZFS N-way mirror read performance by using load and locality 2013-10-23 09:54:58 +00:00
gnu/fs/reiserfs
i386 Document XENHVM and xenpci are mutually inclusive. 2013-10-11 19:40:28 +00:00
ia64 The pmap function pmap_clear_reference() is no longer used. Remove it. 2013-09-20 04:30:18 +00:00
isa
kern Redefine the io provider using the SDT(9) macros instead of doing everything 2013-10-24 02:39:07 +00:00
kgssapi Add support for host-based (Kerberos 5 service principal) initiator 2013-07-09 01:05:28 +00:00
libkern Fix ixp425 boot2 with ARM EABI: 2013-09-29 15:19:34 +00:00
mips MFP4: 2013-10-23 21:35:39 +00:00
modules Redefine the io provider using the SDT(9) macros instead of doing everything 2013-10-24 02:39:07 +00:00
net Add a note that lacp_compose_key() should be updated, when new media 2013-10-21 07:49:36 +00:00
net80211 Fix a use-after-free node reference issue when waiting for a return 2013-10-24 17:04:16 +00:00
netatalk Remove ifa_init() and provide ifa_alloc() that will allocate and setup 2013-10-15 10:31:42 +00:00
netgraph Improve locking model used to protect netgraph topology: 2013-10-15 17:44:35 +00:00
netinet Finish r254925 and remove the last remaining sysctl name list macro. The 2013-10-23 13:22:50 +00:00
netinet6 - Utilize counter(9) to accumulate statistics on interface addresses. Add 2013-10-15 11:37:57 +00:00
netipsec Remove most of the remaining sysctl name list macros. They were only 2013-08-26 18:16:05 +00:00
netipx Remove ifa_init() and provide ifa_alloc() that will allocate and setup 2013-10-15 10:31:42 +00:00
netnatm Fix the length calculation for the final block of a sendfile(2) 2013-09-10 10:05:59 +00:00
netpfil Use the correct EtherType for logging IPv6 packets. 2013-09-28 15:49:36 +00:00
netsmb Change the cap_rights_t type from uint64_t to a structure that we can extend 2013-09-05 00:09:56 +00:00
nfs Changes to allow using BOOTP_NFSROOT and mounting an nfs root filesystem 2013-07-31 19:14:00 +00:00
nfsclient A problem with the old NFS client where large writes to large files 2013-07-04 00:54:23 +00:00
nfsserver Change the cap_rights_t type from uint64_t to a structure that we can extend 2013-09-05 00:09:56 +00:00
nlm Intermittent crashes in the NLM (rpc.lockd) code during system 2013-09-06 23:14:31 +00:00
ofed Fix resource free. 2013-10-17 12:19:36 +00:00
opencrypto Make sendfile() a method in the struct fileops. Currently only 2013-08-15 07:54:31 +00:00
pc98 MFi386: r254619 2013-08-22 16:39:59 +00:00
pci Add preliminary support for RTL8106E PCIe FastEthernet. 2013-10-21 06:27:20 +00:00
powerpc Allow PIC drivers to translate firmware sense codes for themselves. This 2013-10-24 15:37:32 +00:00
rpc It was reported via email that the cu_sent field used by the 2013-09-06 02:34:34 +00:00
security Fix some typos that were causing probe argument types to show up as unknown. 2013-10-01 15:40:27 +00:00
sparc64 Implement GET_STACK_USAGE. 2013-09-29 13:09:25 +00:00
sys Revert addition of sbintime and getsbintime that crept into r256963. 2013-10-23 14:28:42 +00:00
teken
tools
ufs UFS2: make di_extsize unsigned. 2013-10-24 00:33:29 +00:00
vm Tidy up the output of "sysctl vm.phys_free". 2013-10-10 16:11:45 +00:00
x86 Add a va_copy() to our fall-back stdarg implementation for use with lint(1) 2013-10-07 10:01:23 +00:00
xdr
xen Remove redundant redeclaration of gdtset in sys/xen/xen-os.h, to silence 2013-10-18 17:06:13 +00:00
Makefile