freebsd with flexible iflib nic queues
Go to file
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
bin Fixes to output of ls -lh for certain file sizes: 2004-03-01 19:25:27 +00:00
contrib Add local define of HTONL() as it was decided to protect this by _KERNEL 2004-02-28 18:41:43 +00:00
crypto Update VersionAddendum in config files and man pages. 2004-02-26 11:54:03 +00:00
etc Some (most?) processes don't cleanup their pid files when 2004-03-03 15:28:44 +00:00
games Label @ as being AC (since it's constructed like a prosign). 2004-02-20 13:46:39 +00:00
gnu Fixed "make clean". 2004-03-03 17:04:49 +00:00
include Add skeleton build dirs for pf userland: 2004-02-28 21:50:50 +00:00
kerberos5 style.Makefile(5). 2004-02-05 18:51:52 +00:00
lib Document missing EFAULT errno value. 2004-03-03 14:51:11 +00:00
libexec Add skeleton build dirs for pf userland: 2004-02-28 21:50:50 +00:00
release Modified release notes: More ports affected by thread-safe resolver 2004-02-29 02:20:21 +00:00
rescue Revision 1.7 of this file added information 2004-01-18 22:24:23 +00:00
sbin Make this WARNS=2 clean by: 2004-03-03 20:21:15 +00:00
secure Update for 3.8p1, including workaround for a bug in gss-genr.c. 2004-02-26 11:26:46 +00:00
share Add acpi_video(4) man page. 2004-03-03 16:34:03 +00:00
sys Add sanity checks to the ndis_packet and ndis_buffer pool handling 2004-03-04 00:17:14 +00:00
tools Add regression tests for geom_concat class. 2004-03-03 21:52:49 +00:00
usr.bin Typo fix. 2004-03-03 09:15:07 +00:00
usr.sbin Minor style(9) fixes. remove a register keyword, correct two indents. 2004-03-03 02:44:52 +00:00
COPYRIGHT Update the COPYRIGHT file to include FreeBSD's compilation copyright 2003-12-31 22:35:22 +00:00
installworld_newk Commit the first set of files for changing time_t on freebsd/sparc64 2004-03-03 19:36:20 +00:00
installworld_oldk Commit the first set of files for changing time_t on freebsd/sparc64 2004-03-03 19:36:20 +00:00
MAINTAINERS Update for reality. 2004-03-01 16:34:39 +00:00
Makefile Protect shell expansions. 2004-03-02 14:32:23 +00:00
Makefile.inc1 Commit the first set of files for changing time_t on freebsd/sparc64 2004-03-03 19:36:20 +00:00
README
UPDATING Add a note explaining how to use libmap.conf to work around problems 2004-03-03 09:17:06 +00:00
UPDATING.64BTT Commit the first set of files for changing time_t on freebsd/sparc64 2004-03-03 19:36:20 +00:00

This is the top level of the FreeBSD source directory.  This file
was last revised on:
$FreeBSD$

For copyright information, please see the file COPYRIGHT in this
directory (additional copyright information also exists for some
sources in this tree - please see the specific source directories for
more information).

The Makefile in this directory supports a number of targets for
building components (or all) of the FreeBSD source tree, the most
commonly used one being ``world'', which rebuilds and installs
everything in the FreeBSD system from the source tree except the
kernel, the kernel-modules and the contents of /etc.  The
``buildkernel'' and ``installkernel'' targets build and install
the kernel and the modules (see below).  Please see the top of
the Makefile in this directory for more information on the
standard build targets and compile-time flags.

Building a kernel is a somewhat more involved process, documentation
for which can be found at:
   http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig.html
And in the config(8) man page.
Note: If you want to build and install the kernel with the
``buildkernel'' and ``installkernel'' targets, you might need to build
world before.  More information is available in the handbook.

The sample kernel configuration files reside in the sys/<arch>/conf
sub-directory (assuming that you've installed the kernel sources), the
file named GENERIC being the one used to build your initial installation
kernel.  The file NOTES contains entries and documentation for all possible
devices, not just those commonly used.  It is the successor of the ancient
LINT file, but in contrast to LINT, it is not buildable as a kernel but a
pure reference and documentation file.


Source Roadmap:
---------------
bin		System/user commands.

contrib		Packages contributed by 3rd parties.

crypto		Cryptography stuff (see crypto/README).

etc		Template files for /etc.

games		Amusements.

gnu		Various commands and libraries under the GNU Public License.
		Please see gnu/COPYING* for more information.

include		System include files.

kerberos5	Kerberos5 (Heimdal) package.

lib		System libraries.

libexec		System daemons.

release		Release building Makefile & associated tools.

sbin		System commands.

secure		Cryptographic libraries and commands.

share		Shared resources.

sys		Kernel sources.

tools		Utilities for regression testing and miscellaneous tasks.

usr.bin		User commands.

usr.sbin	System administration commands.


For information on synchronizing your source tree with one or more of
the FreeBSD Project's development branches, please see:

  http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/synching.html