freebsd kernel with SKQ
Go to file
kib f068898e84 It seems that there are at least three issues with IPC_RMID operation
on SysV semaphores.

  The squeeze of the semaphore array in the kern_semctl() modifies
  sem_base for the semaphores with sem_base greater then sem_base of
  the removed semaphore, as well as the values of the semaphores,
  without locking their mutex. This can lead to (killable) hangs or
  unexpected behaviour of the processes performing any sem operations
  while other process does IPC_RMID.

  The semexit_myhook() eventhandler unlocks SEMUNDO_LOCK() while
  accessing *suptr. This allows for IPC_RMID for the sem id to be
  performed in parallel with undo hook referenced by the current undo
  structure. This leads to the panic("semexit - semid not allocated") [1].

  The semaphore creation is protected by Giant, while IPC_RMID is done
  while only semaphore mutex is held. This seems to result in invalid
  values for semtot, causing random ENOSPC error returns [2].

Redo the locking of the semaphores lifetime cycle. Delegate the
sem_mtx to the sole purpose of protecting semget() and
semctl(IPC_RMID). Introduce new sem_undo_mtx to protect SEM_UNDO
handling. Remove the Giant remnants from the code.
Note that  mac_sysvsem_check_semget() and mac_sysvsem_create() are
now called while sem_mtx is held, as well as mac_sysvsem_cleanup() [3].

When semaphore is removed, acquire semaphore locks for all semaphores
with sem_base that is going to be changed by squeeze of the sema
array. The lock order is not important there, because the region is
protected by sem_mtx.

Organize both used and free sem_undo structures into the lists,
protected by sem_undo_mtx. In semexit_myhook(), remove sem_undo
structure that is being processed, from used list, without putting it
onto the free to prevent modifications by other threads. This allows
for sem_undo_lock to be dropped to acquire individial semaphore locks
without violating lock order. Since IPC_RMID may no longer find this
sem_undo, do tolerate references to unallocated semaphores in undo
structure, and check sequential number to not undo unrelated semaphore
with the same id.

While there, convert functions definitions to ANSI C and fix small
style(9) glitches.

Reported by:	Omer Faruk Sen <omerfsen gmail com> [1], pho [2]
Reviewed by:	rwatson [3]
Tested by:	pho
MFC after:	1 month
2009-01-14 15:20:13 +00:00
bin o Fix a typo. Bump .Dd for the previous delta. 2009-01-13 18:25:56 +00:00
cddl Include param.h instead of types.h before mount.h so that the nested 2008-12-29 18:59:50 +00:00
contrib Merge OpenBSM alpha 5 from OpenBSM vendor branch to head, both 2009-01-14 10:44:16 +00:00
crypto Prevent cross-site forgery attacks on lukemftpd(8) due to splitting 2009-01-07 20:17:55 +00:00
etc Fix typo to install 400.status-pkg, again. 2009-01-14 09:00:30 +00:00
games netcat is "now" in base, so point people at nc(1) instead of the port. 2009-01-12 19:17:43 +00:00
gnu There's no need to redundantly redefine atomicity.h. 2008-12-31 07:39:23 +00:00
include Merge the resolver part of BIND 9.4.3 into HEAD. 2008-12-14 19:39:53 +00:00
kerberos5 Add strndup(3) prototype to string.h. 2008-12-08 21:04:24 +00:00
lib Merge OpenBSM alpha 5 from OpenBSM vendor branch to head, both 2009-01-14 10:44:16 +00:00
libexec Prevent cross-site forgery attacks on ftpd(8) due to splitting 2008-12-23 01:23:09 +00:00
release Note new fetch if-modified-since support in the userland section, and 2009-01-09 03:52:12 +00:00
rescue Take a moment to tidy some white space while I'm here. No functional 2008-09-13 19:56:37 +00:00
sbin Some small fixes submitted by Christoph Mallon, specifically: 2009-01-13 23:36:38 +00:00
secure Enable getaudit_addr(2) for sshd again. This will un-break the subject 2008-11-30 15:35:24 +00:00
share o note need for options AH_SUPPORT_5416 2009-01-13 23:57:15 +00:00
sys It seems that there are at least three issues with IPC_RMID operation 2009-01-14 15:20:13 +00:00
tools Add support for two new event source types: 2009-01-13 16:44:18 +00:00
usr.bin o Respect -ss flags (suppress zero counters) for icmp6 "histogram 2009-01-13 07:58:57 +00:00
usr.sbin Extend the geom-related info and put in the NOTE section, not 2009-01-13 21:55:39 +00:00
COPYRIGHT Bump the odometer of the years. A little early this year for 7.1R. 2008-12-30 04:46:25 +00:00
LOCKS Update LOCKS syntax. 2008-06-05 19:47:58 +00:00
MAINTAINERS Update description text 2008-06-06 21:32:01 +00:00
Makefile Permit digits at the beginning and end of kernel config file names for 2008-12-27 15:07:51 +00:00
Makefile.inc1 Add the kerberos5 libs to the install32 target. 2008-11-12 04:43:55 +00:00
ObsoleteFiles.inc Add an obsolete file. 2009-01-03 11:25:50 +00:00
README
UPDATING ng_tty(4) module updated to match the new TTY subsystem. 2008-12-25 10:05:00 +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 ``world''
target should only be used in cases where the source tree has not
changed from the currently running version.  See:
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/makeworld.html
for more information, including setting make(1) variables.

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.

rescue		Build system for statically linked /rescue utilities.

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