freebsd-nq/sys
Bill Paul a787e5ecf8 Add sanity checks to the ndis_packet and ndis_buffer pool handling
routines to guard against problems caused by (possibly) buggy drivers.

The RealTek 8180 wireless driver calls NdisFreeBuffer() to release
some of its buffers _after_ it's already called NdisFreeBufferPool()
to destroy the pool to which the buffers belong. In our implementation,
this error causes NdisFreeBuffer() to touch stale heap memory.

If you are running a release kernel, and hence have INVARIANTS et al
turned off, it turns out nothing happens. But if you're using a
development kernel config with INVARIANTS on, the malloc()/free()
sanity checks will scribble over the pool memory with 0xdeadc0de
once it's released so that any attempts to touch it will cause a
trap, and indeed this is what happens. It happens that I run 5.2-RELEASE
on my laptop, so when I tested the rtl8180.sys driver, it worked fine
for me, but people trying to run it with development systems checked
out or cvsupped from -current would get a page fault on driver load.

I can't find any reason why the NDISulator would cause the RealTek
driver to do the NdisFreeBufferPool() prematurely, and the same driver
obviously works with Windows -- or at least, it doesn't cause a crash:
the Microsoft documentation for NdisFreeBufferPool() says that failing
to return all buffers to the pool before calling  NdisFreeBufferPool()
causes a memory leak.

I've written to my contacts at RealTek asking them to check if this
is indeed a bug in their driver. In the meantime, these new sanity checks
will catch this problem and issue a warning rather than causing a trap.
The trick is to keep a count of outstanding buffers for each buffer pool,
and if the driver tries to call NdisFreeBufferPool() while there are still
buffers outstanding, we mark the pool for deletion and then defer
destroying it until after the last buffer has been reclaimed.
2004-03-04 00:17:14 +00:00
..
alpha The previous commit fixed -current on alpha for machines with 2004-03-01 19:19:15 +00:00
amd64 Sync with i386/NOTES rev. 1.1131. 2004-03-03 09:26:40 +00:00
arm Add sysentvec->sv_fixlimits() hook so that we can catch cases on 64 bit 2003-09-25 01:10:26 +00:00
boot While I'm here, add linprocfs (but not pseudofs, since it is no use on 2004-03-01 18:42:16 +00:00
cam Compare the *number* of patterns to zero, not the *pointer* to the 2004-02-28 12:59:56 +00:00
coda Device megapatch 5/6: 2004-02-21 21:32:15 +00:00
compat Add sanity checks to the ndis_packet and ndis_buffer pool handling 2004-03-04 00:17:14 +00:00
conf Add rules for font.h atkbdmap.h ukbdmap.h so more of LINT can be built. 2004-03-03 09:37:44 +00:00
contrib This commit was generated by cvs2svn to compensate for changes in r126520, 2004-03-03 05:47:09 +00:00
crypto Fix a reentrancy issue in md5_calc(). 2004-01-27 18:57:21 +00:00
ddb Give DDB a "watchdog" command which disables all watchdogs. 2004-02-29 09:55:32 +00:00
dev Change to acpi_{Get,Set}Integer to provide both methods. Convert all 2004-03-03 18:34:42 +00:00
fs Change __FUNCTION__ to __func__ 2004-03-03 07:43:34 +00:00
geom - Remove d_valid field, we can use d_consumer field to check if disk 2004-03-03 22:29:24 +00:00
gnu Enforce the file size limit in VOP_WRITE() as well as VOP_TRUNCATE(); 2004-02-19 09:06:06 +00:00
i4b Device megapatch 4/6: 2004-02-21 21:10:55 +00:00
i386 Add ctau (Cronyx/Tau-ISA) device driver entry. 2004-03-03 12:43:59 +00:00
ia64 Do not pre-map the I/O port space. On the Intel Tiger 4 this conflicts 2004-02-22 02:10:48 +00:00
isa Remove unused FDNUMTOUNIT() macro 2004-02-29 10:21:40 +00:00
isofs/cd9660 Fix comment containing vop_readdir_args contents: a_cookies is really 2004-02-23 01:43:00 +00:00
kern Use different dummy wait channels to avoid panic in msleep(). 2004-03-03 23:03:18 +00:00
libkern Remove register keyword and constify tmp values. This fixes 2004-02-12 03:23:13 +00:00
modules Add proper support for DbgPrint(): only print messages if bootverbose 2004-03-03 17:57:05 +00:00
net Two minor follow-ups on the MT_TAG removal: 2004-03-02 14:37:23 +00:00
net80211 Change WI_RID_SCAN_RES compatibility interface to return the result after 2004-01-19 05:25:43 +00:00
netatalk Rename dup_sockaddr() to sodupsockaddr() for consistency with other 2004-03-01 03:14:23 +00:00
netatm Don't remove the first mbuf in the chain if it got empty. 2004-02-21 12:55:07 +00:00
netgraph Netgraph node type for IEEE 802.1Q VLAN tagging. 2004-03-01 17:22:16 +00:00
netinet Add some missing DUMMYNET_UNLOCK() in config_pipe(). 2004-03-03 01:33:22 +00:00
netinet6 - stlye and comments 2004-03-03 14:33:16 +00:00
netipsec Fix type in a sysctl. It used to be: net.key.prefered_oldsa 2004-02-16 17:09:53 +00:00
netipx Rename dup_sockaddr() to sodupsockaddr() for consistency with other 2004-03-01 03:14:23 +00:00
netkey avoid duplicate free. 2004-01-25 17:18:12 +00:00
netnatm Rename dup_sockaddr() to sodupsockaddr() for consistency with other 2004-03-01 03:14:23 +00:00
netncp Split the mlock() kernel code into two parts, mlock(), which unpacks 2004-02-26 00:27:04 +00:00
netsmb Rename dup_sockaddr() to sodupsockaddr() for consistency with other 2004-03-01 03:14:23 +00:00
nfs University of Michigan's Citi NFSv4 kernel client code. 2003-11-14 20:54:10 +00:00
nfs4client NFSv4 fixes from Connectathon 2004: 2004-02-27 19:37:43 +00:00
nfsclient Rename dup_sockaddr() to sodupsockaddr() for consistency with other 2004-03-01 03:14:23 +00:00
nfsserver Rename dup_sockaddr() to sodupsockaddr() for consistency with other 2004-03-01 03:14:23 +00:00
opencrypto Device megapatch 4/6: 2004-02-21 21:10:55 +00:00
pc98 Remove unused FDNUMTOUNIT() macro 2004-02-29 10:21:40 +00:00
pccard Device megapatch 4/6: 2004-02-21 21:10:55 +00:00
pci Device megapatch 4/6: 2004-02-21 21:10:55 +00:00
posix4 The sem_timedwait() and ksem_timedwait() functions both 2004-02-03 22:27:03 +00:00
powerpc Increase kernel VA from 256Mb to 512Mb by shifting the segment used 2004-03-02 06:49:21 +00:00
rpc Don't panic because of RPC proto mismatches. Whitespace cleanup. 2004-01-17 21:25:05 +00:00
security Define BPFD_LOCK_ASSERT() to assert the BPF descriptor lock. 2004-02-29 15:33:56 +00:00
sparc64 Device megapatch 4/6: 2004-02-21 21:10:55 +00:00
sys Rename NET_PICKUP_GIANT() to NET_LOCK_GIANT(), and NET_DROP_GIANT() 2004-03-01 22:37:01 +00:00
tools Attempt to clean up the emu10k1-alsa.h stuff so that config doesn't 2004-02-05 22:51:16 +00:00
ufs A more accurate test in the new ufs_lock than that in 1.235. 2004-02-23 19:05:05 +00:00
vm Modify contigmalloc1() so that the free page queues lock is not held when 2004-03-02 08:25:58 +00:00
Makefile Replaced outdated comment. 2004-01-17 03:28:27 +00:00