freebsd kernel with SKQ
Go to file
rwatson 9487c057e2 Correct a number of serious and closely related bugs in the UNIX domain
socket file descriptor garbage collection code, which is intended to
detect and clear cycles of orphaned file descriptors that are "in-flight"
in a socket when that socket is closed before they are received.  The
algorithm present was both run at poor times (resulting in recursion and
reentrance), and also buggy in the presence of parallelism.  In order to
fix these problems, make the following changes:

- When there are in-flight sockets and a UNIX domain socket is destroyed,
  asynchronously schedule the garbage collector, rather than running it
  synchronously in the current context.  This avoids lock order issues
  when the garbage collection code reenters the UNIX domain socket code,
  avoiding lock order reversals, deadlocks, etc.  Run the code
  asynchronously in a task queue.

- In the garbage collector, when skipping file descriptors that have
  entered a closing state (i.e., have f_count == 0), re-test the FDEFER
  flag, and decrement unp_defer.  As file descriptors can now transition
  to a closed state, while the garbage collector is running, it is no
  longer the case that unp_defer will remain an accurate count of
  deferred sockets in the mark portion of the GC algorithm.  Otherwise,
  the garbage collector will loop waiting waiting for unp_defer to reach
  zero, which it will never do as it is skipping file descriptors that
  were marked in an earlier pass, but now closed.

- Acquire the UNIX domain socket subsystem lock in unp_discard() when
  modifying the unp_rights counter, or a read/write race is risked with
  other threads also manipulating the counter.

While here:

- Remove #if 0'd code regarding acquiring the socket buffer sleep lock in
  the garbage collector, this is not required as we are able to use the
  socket buffer receive lock to protect scanning the receive buffer for
  in-flight file descriptors on the socket buffer.

- Annotate that the description of the garbage collector implementation
  is increasingly inaccurate and needs to be updated.

- Add counters of the number of deferred garbage collections and recycled
  file descriptors.  This will be removed and is here temporarily for
  debugging purposes.

With these changes in place, the unp_passfd regression test now appears
to be passed consistently on UP and SMP systems for extended runs,
whereas before it hung quickly or panicked, depending on which bug was
triggered.

Reported by:	Philip Kizer <pckizer at nostrum dot com>
MFC after:	2 weeks
2005-11-10 16:06:04 +00:00
bin Mention the non-standardness of the -I option in ls(1). 2005-11-10 14:26:50 +00:00
contrib This commit was generated by cvs2svn to compensate for changes in r151970, 2005-11-02 14:05:49 +00:00
crypto Correct a man-in-the-middle SSL version rollback vulnerability. 2005-10-11 11:50:36 +00:00
etc Backout r1.11... 2005-11-10 10:40:15 +00:00
games Fix typo 2005-10-19 06:37:39 +00:00
gnu Suggest the user to use 'diff -urN' instead of 'diff -crN'. 2005-11-03 03:49:57 +00:00
include Add POSIX timer interfaces. 2005-10-30 03:15:05 +00:00
kerberos5 Bump the shared library version number of all libraries that have not 2005-07-22 17:19:05 +00:00
lib Bump the maximum number of archive formats that can be 2005-11-08 07:44:39 +00:00
libexec Style: move .PATH to where it belongs. 2005-10-14 15:41:09 +00:00
release em(4) works on all archs now, so this can be removed. 2005-11-09 22:05:41 +00:00
rescue Respect the YES_HESIOD build variable. 2005-08-06 16:53:55 +00:00
sbin Fix malloc size (visible on amd64, with "kldconfig -r"). 2005-11-07 19:22:20 +00:00
secure Update for OpenSSH 4.2p1. 2005-09-03 07:10:33 +00:00
share Use .Nx macro for NetBSD. 2005-11-10 15:42:51 +00:00
sys Correct a number of serious and closely related bugs in the UNIX domain 2005-11-10 16:06:04 +00:00
tools Add unix_passfd, a simple set of regression tests for UNIX domain socket 2005-11-09 21:41:20 +00:00
usr.bin Align output. 2005-11-09 15:12:57 +00:00
usr.sbin - Document last change to ARP behavior. 2005-11-10 11:35:53 +00:00
COPYRIGHT Complete 2005 transition. 2005-01-01 07:29:20 +00:00
LOCKS Document the previously existing RELENG_[45]_* security branch locks. 2005-06-02 22:57:30 +00:00
MAINTAINERS Note that bugmaster would like to review commits to send-pr. 2005-10-24 08:15:58 +00:00
Makefile Add delete-old and delete-old-libs targets: 2005-07-23 14:23:30 +00:00
Makefile.inc1 Require DESTDIR to be set when installing for a different architecture. 2005-11-07 15:03:04 +00:00
ObsoleteFiles.inc Record renaming rc.d/ppp-user to rc.d/ppp. 2005-10-29 05:27:32 +00:00
README
UPDATING Record renaming rc.d/ppp-user to rc.d/ppp. 2005-10-29 05:27:32 +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