freebsd-skq/sys
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
..
amd64 Update comments for the MD functions managing contexts for new 2016-06-16 12:05:44 +00:00
arm Revert the recent armv6 changes to ALIGNED_POINTER(), restoring the 2016-06-21 17:53:42 +00:00
arm64 Fix a race when the hardware has raised an exception with an unknown or 2016-06-22 12:05:08 +00:00
boot Print a message when disks are found but no logical partition are 2016-06-17 17:09:22 +00:00
bsm
cam Rename CAM_NETFLIX_IOSCHED to CAM_IOSCHED_DYNAMIC to better reflect 2016-06-23 23:20:58 +00:00
cddl fix deadlock-prone code in getzfsvfs() 2016-06-23 07:01:54 +00:00
compat Fix a bug introduced in r283433. 2016-06-26 16:59:59 +00:00
conf Unbreak building of LINT kernels after r302163. 2016-06-25 22:24:16 +00:00
contrib Get closer to a VIMAGE network stack teardown from top to bottom rather 2016-06-21 13:48:49 +00:00
crypto Connect the SHA-512t256 and Skein hashing algorithms to ZFS 2016-05-31 04:12:14 +00:00
ddb Add a small set of logical operators to DDB command language. 2016-05-16 19:42:38 +00:00
dev bhnd(4): Add devinfo allocation and child addition methods, modeled on 2016-06-25 04:36:30 +00:00
fs Rewrite sigdeferstop(9) and sigallowstop(9) into more flexible 2016-06-26 20:07:24 +00:00
gdb
geom Switch geom_disk over to using a pool mutex. 2016-06-23 20:05:59 +00:00
gnu Revert changes for local testing, inadvertantly commited in r300811. 2016-05-26 23:59:42 +00:00
i386 Update comments for the MD functions managing contexts for new 2016-06-16 12:05:44 +00:00
isa sys/isa: minor spelling fixes. 2016-05-03 21:51:52 +00:00
kern When filt_proc() removes event from the knlist due to the process 2016-06-27 21:52:17 +00:00
kgssapi kgssapi: insignificant spelling fix. 2016-05-03 22:05:03 +00:00
libkern sys: Make use of our rounddown() macro when sys/param.h is available. 2016-04-30 14:41:18 +00:00
mips Replace mips/sentry5 with mips/broadcom 2016-06-25 04:34:54 +00:00
modules Change the default build behavior so we don't compile extra TCP modules by 2016-06-10 19:06:11 +00:00
net Update pf(4) and pflog(4) to survive basic VNET testing, which includes 2016-06-23 21:34:38 +00:00
net80211 [net80211] re-revert the ibss "is this local to the bss" patch. 2016-06-25 20:31:20 +00:00
netgraph Get closer to a VIMAGE network stack teardown from top to bottom rather 2016-06-21 13:48:49 +00:00
netinet This patch fixes two bugs related to the SCTP message recovery 2016-06-26 16:38:42 +00:00
netinet6 Don't consider the socket when processing an incoming ICMP/ICMP6 packet, 2016-06-23 09:13:15 +00:00
netipsec Get closer to a VIMAGE network stack teardown from top to bottom rather 2016-06-21 13:48:49 +00:00
netnatm kernel: use our nitems() macro when it is available through param.h. 2016-04-19 23:48:27 +00:00
netpfil The void isn't void. 2016-06-24 11:53:12 +00:00
netsmb sys/net*: minor spelling fixes. 2016-05-03 18:05:43 +00:00
nfs NFS: spelling fixes on comments. 2016-04-29 16:07:25 +00:00
nfsclient
nfsserver
nlm When sleeping waiting for either local or remote advisory lock, 2016-06-26 20:08:42 +00:00
ofed Fix bug in iwcm that caused a panic in iw_cm_wq when krping is run 2016-06-14 20:58:05 +00:00
opencrypto sys/opencrypto: minor spelling fixes. 2016-05-06 23:37:19 +00:00
pc98 Move 'device pci' for the PCI bus driver to the MI NOTES file. 2016-04-29 23:53:55 +00:00
powerpc Enter 64-bit mode as early as possible in the 64-bit PowerPC boot sequence. 2016-06-26 18:43:42 +00:00
riscv Update comments for the MD functions managing contexts for new 2016-06-16 12:05:44 +00:00
rpc Deobfuscate cleanup path in clnt_bck_create(..) 2016-06-10 17:53:28 +00:00
security Implement AUE_PREAD and AUE_PWRITE BSM conversion support, eliminating 2016-06-13 09:22:20 +00:00
sparc64 Update comments for the MD functions managing contexts for new 2016-06-16 12:05:44 +00:00
sys When filt_proc() removes event from the knlist due to the process 2016-06-27 21:52:17 +00:00
teken
tests
tools
ufs arc4random() returns 0 to (2**32)−1, use an alternative to initialize 2016-05-22 14:31:20 +00:00
vm In vm_page_xunbusy_maybelocked(), add fast path for unbusy when no 2016-06-23 08:28:13 +00:00
x86 Add a tunable to disable migration of MSI-X interrupts. 2016-06-24 22:49:32 +00:00
xdr RPC: for pointers replace 0 with NULL. 2016-04-14 17:06:37 +00:00
xen xen: Correct typo in #undef for symbol NBPL 2016-06-06 14:55:46 +00:00
Makefile