freebsd-skq/sys
Mark Johnston ccdadf1a9b Simplify unix socket connection peer locking.
unp_pcb_owned_lock2() has some sharp edges and forces callers to deal
with a bunch of cases.  Simplify it:

- Rename to unp_pcb_lock_peer().
- Return the connected peer instead of forcing callers to load it
  beforehand.
- Handle self-connected sockets.
- In unp_connectat(), just lock the accept socket directly.  It should
  not be possible for the nascent socket to participate in any other
  lock orders.
- Get rid of connect_internal().  It does not provide any useful
  checking anymore.
- Block in unp_connectat() when a different thread is concurrently
  attempting to lock both sides of a connection.  This provides simpler
  semantics for callers of unp_pcb_lock_peer().
- Make unp_connectat() return EISCONN if the socket is already
  connected.  This fixes a race[1] when multiple threads attempt to
  connect() to different addresses using the same datagram socket.
  Upper layers will disconnect a connected datagram socket before
  calling the protocol connect's method, but there is no synchronization
  between this and protocol-layer code.

Reported by:	syzkaller [1]
Tested by:	pho
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D26299
2020-09-15 19:23:22 +00:00
..
amd64 Move SV_ABI_ERRNO translation into linux-specific code, to simplify 2020-09-15 16:41:21 +00:00
arm Move SV_ABI_ERRNO translation into linux-specific code, to simplify 2020-09-15 16:41:21 +00:00
arm64 Move SV_ABI_ERRNO translation into linux-specific code, to simplify 2020-09-15 16:41:21 +00:00
bsm bsm: add AUE_CLOSERANGE 2020-04-24 01:27:25 +00:00
cam mmc_da: universally use uint8_t for the partition index 2020-09-08 06:19:23 +00:00
cddl dtrace: fix fbt return probes on RISC-V 2020-09-11 09:15:49 +00:00
compat Add emulation support for the Linux kcov(4) ioctl API. 2020-09-04 00:12:28 +00:00
conf Use MACHINE_CPUARCH when checking for arm64 2020-09-14 16:12:28 +00:00
contrib ice_ddp: Fix 1.3.16.0 package 2020-09-10 04:00:13 +00:00
crypto Don't return errors from the cryptodev_process() method. 2020-09-08 22:41:35 +00:00
ddb ddb: clean up empty lines in .c and .h files 2020-09-01 22:14:30 +00:00
dev Don't do the busy dance in icee_open/close 2020-09-14 23:30:04 +00:00
dts Remove licenses 2020-06-04 17:20:58 +00:00
fs Fix a case where the NFSv4.0 server might crash if delegations are enabled. 2020-09-14 00:44:50 +00:00
gdb gdb(4): Support empty qSupported queries 2020-08-18 20:59:10 +00:00
geom We don't need the sc_ekeys_lock in standalone environment. 2020-09-14 23:51:14 +00:00
gnu Import DTS files for arm, arm64, riscv from Linux 5.8 2020-08-04 19:44:43 +00:00
i386 Move SV_ABI_ERRNO translation into linux-specific code, to simplify 2020-09-15 16:41:21 +00:00
isa
kern Simplify unix socket connection peer locking. 2020-09-15 19:23:22 +00:00
kgssapi kgssapi: clean up empty lines in .c and .h files 2020-09-01 22:15:02 +00:00
libkern arm64: check for CRC32 support via HWCAP 2020-09-08 15:39:19 +00:00
mips Refine the busdma template interface. Provide tools for filling in fields 2020-09-14 05:58:12 +00:00
modules [PowerPC64LE] Ensure nvram is built on powerpc64le. 2020-09-13 18:24:15 +00:00
net Fix RADIX_MPATH build broken by r365521. 2020-09-10 07:05:31 +00:00
net80211 net: clean up empty lines in .c and .h files 2020-09-01 21:19:14 +00:00
netgraph ng_ether: Enter NET_EPOCH where required 2020-09-02 11:49:22 +00:00
netinet Export the name of the congestion control. This will be used by sockstat 2020-09-13 09:06:50 +00:00
netinet6 net: clean up empty lines in .c and .h files 2020-09-01 21:19:14 +00:00
netipsec net: clean up empty lines in .c and .h files 2020-09-01 21:19:14 +00:00
netpfil net: clean up empty lines in .c and .h files 2020-09-01 21:19:14 +00:00
netsmb net: clean up empty lines in .c and .h files 2020-09-01 21:19:14 +00:00
nfs nfs: clean up empty lines in .c and .h files 2020-09-01 21:25:39 +00:00
nfsclient nfs: clean up empty lines in .c and .h files 2020-09-01 21:25:39 +00:00
nfsserver nfs: clean up empty lines in .c and .h files 2020-09-01 21:25:39 +00:00
nlm nlm: clean up empty lines in .c and .h files 2020-09-01 22:14:52 +00:00
ofed infiniband: Appease Coverty 2020-08-31 16:17:28 +00:00
opencrypto Include sys/types.h here 2020-09-15 15:21:29 +00:00
powerpc Move SV_ABI_ERRNO translation into linux-specific code, to simplify 2020-09-15 16:41:21 +00:00
riscv Refine the busdma template interface. Provide tools for filling in fields 2020-09-14 05:58:12 +00:00
rpc Fix a potential memory leak in the NFS over TLS handling code. 2020-09-05 00:50:52 +00:00
security mac_framework.h: fix build with DEBUG_VFS_LOCKS and !MAC 2020-09-03 20:30:52 +00:00
sys Simplify unix socket connection peer locking. 2020-09-15 19:23:22 +00:00
teken
tests Add small tool to invoke kernel test framework tests. 2020-09-02 09:20:40 +00:00
tools makesyscalls.lua: improve syscall ordering validation 2020-08-04 21:49:13 +00:00
ufs ufs: clean up empty lines in .c and .h files 2020-09-01 21:23:00 +00:00
vm Support for userspace non-transparent superpages (largepages). 2020-09-09 22:12:51 +00:00
x86 Refine the busdma template interface. Provide tools for filling in fields 2020-09-14 05:58:12 +00:00
xdr xdr: clean up empty lines in .c and .h files 2020-09-01 22:13:28 +00:00
xen xen: clean up empty lines in .c and .h files 2020-09-01 21:21:55 +00:00
Makefile