freebsd-dev/sys
Mark Johnston c17b531bed sctp: Fix races around sctp_inpcb_free()
sctp_close() and sctp_abort() disassociate the PCB from its socket.
As a part of this, they attempt to free the PCB, which may end up
lingering.  Fix some bugs in this area:

- For some reason, sctp_close() and sctp_abort() set
  SCTP_PCB_FLAGS_SOCKET_GONE using an atomic compare-and-set without the
  PCB lock held.  This is racy since sctp_flags is normally updated
  without atomics, using the PCB lock to synchronize.  So, the update
  can be lost, which can cause all sort of races with other SCTP
  components which look for the _GONE flag.  Fix the problem simply by
  acquiring the PCB lock in order to set the flag.  Note that we have to
  drop and re-acquire the lock again in sctp_inpcb_free(), but I don't
  see a good way around that for now.  If it's a real problem, the _GONE
  flag could be split out of sctp_flags and into a dedicated sctp_inpcb
  field.
- In sctp_inpcb_free(), load sctp_socket after acquiring the PCB lock,
  to avoid possible races with parallel sctp_inpcb_free() calls.
- Add an assertion sctp_inpcb_free() to verify that _ALLGONE is not set.

Reviewed by:	tuexen
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D31811
2021-09-07 11:19:29 -04:00
..
amd64 vmd(4): Major driver refactoring 2021-09-02 20:58:02 -04:00
arm Revert "arm: Bump KSTACK_PAGES default to match i386/amd64" 2021-09-01 13:13:27 -07:00
arm64 qoriq_dw_pci: Fix typo in link status checking code 2021-08-31 06:22:33 +02:00
bsm
cam ses: Guard the elm_type_names declaration by _KERNEL 2021-09-02 14:47:18 -06:00
cddl Create sys/reg.h for the common code previously in machine/reg.h 2021-08-30 12:50:53 +01:00
compat syscalls.master: switch to CAPENABLED flags 2021-09-01 21:58:16 +01:00
conf vmd(4): Major driver refactoring 2021-09-02 20:58:02 -04:00
contrib zfs: merge openzfs/zfs@3b89d9518 (master) into main 2021-08-31 09:02:21 +02:00
crypto crypto(4): Fix a few typos in camellia.c 2021-09-04 13:02:11 +02:00
ddb Create sys/reg.h for the common code previously in machine/reg.h 2021-08-30 12:50:53 +01:00
dev ixgbe: increase the timeout 2021-09-06 21:17:19 -07:00
dts
fs unionfs: style 2021-09-01 07:55:37 -07:00
gdb
geom graid: Avoid tasting devices with small sector sizes 2021-08-31 17:09:52 -04:00
gnu
i386 vmd(4): Major driver refactoring 2021-09-02 20:58:02 -04:00
isa
kern kqueue: drain kqueue taskqueue if syscall tickled it 2021-09-07 02:43:34 +03:00
kgssapi
libkern libkern: remove bcopy 2021-08-24 11:24:07 +00:00
mips Fix a common typo in source code comments 2021-09-04 12:56:57 +02:00
modules vmd(4): Major driver refactoring 2021-09-02 20:58:02 -04:00
net pf: remove unused function prototype 2021-09-07 16:38:49 +02:00
net80211 net80211: add func/line information to IEEE80211_DISCARD* macros 2021-09-04 09:24:51 +00:00
netgraph routing: Allow using IPv6 next-hops for IPv4 routes (RFC 5549). 2021-08-22 22:56:08 +00:00
netinet sctp: Fix races around sctp_inpcb_free() 2021-09-07 11:19:29 -04:00
netinet6 inet6(4): Fix a few common typos in source code comments 2021-08-28 18:53:59 +02:00
netipsec
netpfil pf: ensure states passed to pf_free_state() are always unlinked 2021-09-03 09:36:19 +02:00
netsmb
nfs
nfsclient
nfsserver
nlm
ofed routing: Allow using IPv6 next-hops for IPv4 routes (RFC 5549). 2021-08-22 22:56:08 +00:00
opencrypto ktls: Support asynchronous dispatch of AEAD ciphers. 2021-08-30 13:11:52 -07:00
powerpc powerpc: Fix typo in thread register copy 2021-09-04 11:44:02 -05:00
riscv sifive_spi: Add missing case for SPIBUS_MODE_NONE 2021-08-30 23:38:02 +01:00
rpc Fix a common typo in source code comments 2021-09-04 12:56:57 +02:00
security
sys kqueue: drain kqueue taskqueue if syscall tickled it 2021-09-07 02:43:34 +03:00
teken
tests
tools makesyscalls.lua: add a CAPENABLED flag 2021-09-01 21:58:06 +01:00
ufs ffs: remove unused thread argument from ffs_reload() 2021-09-04 12:25:10 -08:00
vm vm: use __func__ for the correct function name 2021-08-22 17:43:12 +00:00
x86 Create sys/reg.h for the common code previously in machine/reg.h 2021-08-30 12:50:53 +01:00
xdr
xen
Makefile