Find a file
Konstantin Belousov 9e590ff04b When filt_proc() removes event from the knlist due to the process
exiting (NOTE_EXIT->knlist_remove_inevent()), two things happen:
- knote kn_knlist pointer is reset
- INFLUX knote is removed from the process knlist.
And, there are two consequences:
- KN_LIST_UNLOCK() on such knote is nop
- there is nothing which would block exit1() from processing past the
  knlist_destroy() (and knlist_destroy() resets knlist lock pointers).
Both consequences result either in leaked process lock, or
dereferencing NULL function pointers for locking.

Handle this by stopping embedding the process knlist into struct proc.
Instead, the knlist is allocated together with struct proc, but marked
as autodestroy on the zombie reap, by knlist_detach() function.  The
knlist is freed when last kevent is removed from the list, in
particular, at the zombie reap time if the list is empty.  As result,
the knlist_remove_inevent() is no longer needed and removed.

Other changes:

In filt_procattach(), clear NOTE_EXEC and NOTE_FORK desired events
from kn_sfflags for knote registered by kernel to only get NOTE_CHILD
notifications.  The flags leak resulted in excessive
NOTE_EXEC/NOTE_FORK reports.

Fix immediate note activation in filt_procattach().  Condition should
be either the immediate CHILD_NOTE activation, or immediate NOTE_EXIT
report for the exiting process.

In knote_fork(), do not perform racy check for KN_INFLUX before kq
lock is taken.  Besides being racy, it did not accounted for notes
just added by scan (KN_SCAN).

Some minor and incomplete style fixes.

Analyzed and tested by:	Eric Badger <eric@badgerio.us>
Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Approved by:	re (gjb)
Differential revision:	https://reviews.freebsd.org/D6859
2016-06-27 21:52:17 +00:00
bin WITH_META_MODE: Fix bin/csh rebuilding tc.const.h 2016-06-14 16:19:49 +00:00
cddl Raise the WARNS level in cddl/lib 2016-06-23 15:02:57 +00:00
contrib MFV r302218: file 5.28. 2016-06-27 01:29:17 +00:00
crypto Revert r301551, which added blacklistd(8) to sshd(8). 2016-06-24 23:22:42 +00:00
etc Remove reference to mroute6d in /etc/netstart. 2016-06-25 12:54:27 +00:00
gnu WITH_META_MODE: Don't expect a .meta file for side-effect generated files. 2016-06-15 23:57:53 +00:00
include Commit the bits of nda that were missed. This should fix the build. 2016-06-10 06:04:53 +00:00
kerberos5 DIRDEPS_BUILD: Update dependencies 2016-06-14 16:55:05 +00:00
lib Fix build: explicitly reference the generated magic.h as dependency 2016-06-27 06:41:11 +00:00
libexec DIRDEPS_BUILD: Update dependencies 2016-06-14 16:55:05 +00:00
release Update the release notes following r302182. 2016-06-24 23:42:33 +00:00
rescue DIRDEPS_BUILD: Fix and hookup rescue/rescue to the build. 2016-05-26 23:20:40 +00:00
sbin Fix "sysctl vm.vmtotal" output on machines with > 2TB virtual memory 2016-06-24 14:58:37 +00:00
secure Revert r301551, which added blacklistd(8) to sshd(8). 2016-06-24 23:22:42 +00:00
share Regenerate 2016-06-24 20:00:39 +00:00
sys When filt_proc() removes event from the knlist due to the process 2016-06-27 21:52:17 +00:00
targets Add clang-format under WITH_CLANG_EXTRAS. 2016-06-17 16:46:58 +00:00
tests Fix bitstring allocation on 32-bit platforms 2016-06-24 21:44:46 +00:00
tools makeroot: zero out subsecond component of time= keywords 2016-06-23 19:19:44 +00:00
usr.bin Skip lastcomm and sa tests on unsupported architectures 2016-06-26 00:53:31 +00:00
usr.sbin bhyve: improve memory size documentation 2016-06-26 14:44:01 +00:00
.arcconfig Remove project.name which is a product of a bygone era. 2016-04-21 04:33:07 +00:00
.arclint phabricator related changes: 2015-04-20 20:33:22 +00:00
COPYRIGHT Bump copyright year. 2015-12-31 11:21:45 +00:00
LOCKS Explicitly require Security Officer's approval for kernel PRNG bits. 2013-09-17 14:19:05 +00:00
MAINTAINERS Add myself to MAINTAINERS. 2016-03-14 16:27:43 +00:00
Makefile WITH_META_MODE: Whitelist 'make kernel-toolchain' 2016-06-22 19:07:41 +00:00
Makefile.inc1 Fix native powerpc64 build of lib32 with in-tree GCC. 2016-06-15 23:58:03 +00:00
Makefile.libcompat Fix native powerpc64 build of lib32 with in-tree GCC. 2016-06-15 23:58:03 +00:00
ObsoleteFiles.inc Replace _pam_verbose_error() with a macro. This was the last difference 2016-06-08 11:47:19 +00:00
README README: remove nonexistent 'games' directory. 2016-05-18 10:43:13 +00:00
UPDATING Fix two typos in r302152. 2016-06-23 21:09:07 +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.  See build(7)
and 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.  See build(7), config(8),
and http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig.html
for more information.

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 kernel configuration files reside in the sys/<arch>/conf
sub-directory.  GENERIC is the default configuration used in release builds.
NOTES contains entries and documentation for all possible
devices, not just those commonly used.


Source Roadmap:
---------------

bin		System/user commands.

cddl		Various commands and libraries under the Common Development
		and Distribution License.

contrib		Packages contributed by 3rd parties.

crypto		Cryptography stuff (see crypto/README).

etc		Template files for /etc.

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.

tests		Regression tests which can be run by Kyua.  See tests/README
		for additional information.

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