freebsd-skq/sys
jah 8f43a81524 Implement cycle-detecting garbage collector for AF_UNIX sockets
The existing AF_UNIX socket garbage collector destroys any socket
which may potentially be in a cycle, as indicated by its file reference
count being equal to its enqueue count. However, this can produce false
positives for in-flight sockets which aren't part of a cycle but are
part of one or more SCM_RIGHTS mssages and which have been closed
on the sending side. If the garbage collector happens to run at
exactly the wrong time, destruction of these sockets will render them
unusable on the receiving side, such that no previously-written data
may be read.

This change rewrites the garbage collector to precisely detect cycles:

1. The existing check of msgcount==f_count is still used to determine
   whether the socket is potentially in a cycle.
2. The socket is now placed on a local "dead list", which is used to
   reduce iteration time (and therefore contention on the global
   unp_link_rwlock).
3. The first pass through the dead list removes each potentially-dead
   socket's outgoing references from the graph of potentially-dead
   sockets, using a gc-specific copy of the original reference count.
4. The second series of passes through the dead list removes from the
   list any socket whose remaining gc refcount is non-zero, as this
   indicates the socket is actually accessible outside of any possible
   cycle.  Iteration is repeated until no further sockets are removed
   from the dead list.
5. Sockets remaining in the dead list are destroyed as before.

PR:		227285
Submitted by:	jan.kokemueller@gmail.com (prior version)
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D23142
2020-01-25 08:57:26 +00:00
..
amd64 Regen. 2020-01-21 17:28:36 +00:00
arm zilinx/zy7_qspi: Add a qspi driver for Zynq platforms. 2020-01-19 20:04:44 +00:00
arm64 Print missing ID_AA64PFR{0,1}_EL1 register fields. 2020-01-23 16:10:38 +00:00
bsm
cam In compatibility structure substitute 'struct callout_handle' 2020-01-22 05:31:37 +00:00
cddl Map ECKSUM and EFRAGS from ZFS onto real errnos. 2020-01-13 22:06:16 +00:00
compat Implement mmget_not_zero() in the LinuxKPI. 2020-01-24 13:05:53 +00:00
conf Include the PCI stack to the riscv GENERIC kernel. 2020-01-24 17:10:21 +00:00
contrib MFV: r356607 2020-01-10 22:49:14 +00:00
crypto
ddb Add KERNEL_PANICKED macro for use in place of direct panicstr tests 2020-01-12 06:07:54 +00:00
dev Enter the network epoch in RX processing taskqueue. 2020-01-25 00:06:18 +00:00
dts zilinx/zy7_qspi: Add a qspi driver for Zynq platforms. 2020-01-19 20:04:44 +00:00
fs Don't hold the object lock while calling getpages. 2020-01-19 23:47:32 +00:00
gdb Add KERNEL_PANICKED macro for use in place of direct panicstr tests 2020-01-12 06:07:54 +00:00
geom GEOM label: strip leading/trailing space synthesizing devfs names 2020-01-18 03:33:44 +00:00
gnu
i386 Fix 64-bit syscall argument fetching in 32-bit Linux syscall handlers. 2020-01-21 17:28:22 +00:00
isa sc(4) md bits: stop setting sc->kbd entirely 2019-12-30 02:07:55 +00:00
kern Implement cycle-detecting garbage collector for AF_UNIX sockets 2020-01-25 08:57:26 +00:00
kgssapi
libkern random(9): Deprecate random(9), remove meaningless srandom(9) 2019-12-26 19:41:09 +00:00
mips Introduce flag IFF_NEEDSEPOCH that marks Ethernet interfaces that 2020-01-23 01:41:09 +00:00
modules vmxnet3: add support for RSS kernel option 2020-01-23 11:05:03 +00:00
net Since now drivers that support pfil run their interrupts in the network 2020-01-23 01:49:22 +00:00
net80211 net80211: Move rate printing in amrr_node_stats() to a separate method 2020-01-17 22:04:11 +00:00
netgraph ng_nat: Pass IPv6 packets through. 2020-01-23 16:45:48 +00:00
netinet Don't delay the ACK for a TCP segment with the CWR flag set. 2020-01-24 22:50:23 +00:00
netinet6 Enter network epoch when calling in_pcbconnect() for IPv6 mapped to IPv4 2020-01-22 17:06:55 +00:00
netipsec
netpfil pf: Apply kif flags to new group members 2020-01-23 22:13:41 +00:00
netsmb
nfs vfs: drop the mostly unused flags argument from VOP_UNLOCK 2020-01-03 22:29:58 +00:00
nfsclient
nfsserver
nlm vfs: drop the mostly unused flags argument from VOP_UNLOCK 2020-01-03 22:29:58 +00:00
ofed Make sure the VNET is properly set when reaping mbufs in ipoib. 2020-01-11 12:02:16 +00:00
opencrypto Add stricter checking on mac key lengths. 2020-01-09 18:29:59 +00:00
powerpc This is Ethernet driver so mark the interrupt appropriately. 2020-01-23 01:46:05 +00:00
riscv Include the PCI stack to the riscv GENERIC kernel. 2020-01-24 17:10:21 +00:00
rpc
security vfs: eliminate v_tag from struct vnode 2020-01-07 04:29:34 +00:00
sparc64 sparc64: Busy the TSB page before freeing it in pmap_release(). 2020-01-23 17:18:58 +00:00
sys Implement cycle-detecting garbage collector for AF_UNIX sockets 2020-01-25 08:57:26 +00:00
teken
tests
tools Add a 'SINGLETON' directive to kobj interface definition 2020-01-18 02:39:38 +00:00
ufs vfs: stop handling VI_OWEINACT in vget 2020-01-24 07:45:59 +00:00
vm Handle a race of collapse with a retrying fault. 2020-01-24 19:42:53 +00:00
x86 cpufreq(4): Fix missing MODULE_DEPEND on hwpstate_intel 2020-01-23 23:52:57 +00:00
xdr
xen
Makefile