freebsd-dev/sys/netinet6
Mark Johnston 2d5c48eccd sctp: Tighten up locking around sctp_aloc_assoc()
All callers of sctp_aloc_assoc() mark the PCB as connected after a
successful call (for one-to-one-style sockets).  In all cases this is
done without the PCB lock, so the PCB's flags can be corrupted.  We also
do not atomically check whether a one-to-one-style socket is a listening
socket, which violates various assumptions in solisten_proto().

We need to hold the PCB lock across all of sctp_aloc_assoc() to fix
this.  In order to do that without introducing lock order reversals, we
have to hold the global info lock as well.

So:
- Convert sctp_aloc_assoc() so that the inp and info locks are
  consistently held.  It returns with the association lock held, as
  before.
- Fix an apparent bug where we failed to remove an association from a
  global hash if sctp_add_remote_addr() fails.
- sctp_select_a_tag() is called when initializing an association, and it
  acquires the global info lock.  To avoid lock recursion, push locking
  into its callers.
- Introduce sctp_aloc_assoc_connected(), which atomically checks for a
  listening socket and sets SCTP_PCB_FLAGS_CONNECTED.

There is still one edge case in sctp_process_cookie_new() where we do
not update PCB/socket state correctly.

Reviewed by:	tuexen
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D31908
2021-09-11 10:15:21 -04:00
..
dest6.c Fix m_pullup() problem after removing PULLDOWN_TESTs and KAME EXT_*macros. 2019-12-01 00:22:04 +00:00
frag6.c frag6: do less work in frag6_slowtimo if possible 2021-08-14 18:51:00 +02:00
icmp6.c lltable: Add support for "child" LLEs holding encap for IPv4oIPv6 entries. 2021-08-21 17:34:35 +00:00
icmp6.h
in6_cksum.c net: clean up empty lines in .c and .h files 2020-09-01 21:19:14 +00:00
in6_fib_algo.c Fix dpdk/ldradix fib lookup algorithm preference calculation. 2021-03-07 22:17:53 +00:00
in6_fib.c Fix unused-function waring when compiling with FIB_ALGO. 2021-01-30 23:25:56 +00:00
in6_fib.h Add modular fib lookup framework. 2020-12-25 11:33:17 +00:00
in6_gif.c net: Introduce IPV6_DSCP(), IPV6_ECN() and IPV6_TRAFFIC_CLASS() macros 2021-03-04 20:56:48 +01:00
in6_ifattach.c nd6: Mark several callouts as MPSAFE 2021-08-09 13:27:52 -04:00
in6_ifattach.h
in6_jail.c
in6_mcast.c Fix panic in IPv6 multicast code. 2021-08-06 12:57:59 +03:00
in6_pcb.c Fix some common typos in comments 2021-08-08 10:16:06 +02:00
in6_pcb.h Filter TCP connections to SO_REUSEPORT_LB listen sockets by NUMA domain 2020-12-19 22:04:46 +00:00
in6_pcbgroup.c
in6_proto.c inet6(4): add a missing IPPROTO_ETHERIP entry 2021-08-27 17:14:35 +09:00
in6_rmx.c Introduce scalable route multipath. 2020-10-03 10:47:17 +00:00
in6_rss.c Implement flowid calculation for outbound connections to balance 2020-10-18 17:15:47 +00:00
in6_rss.h Implement flowid calculation for outbound connections to balance 2020-10-18 17:15:47 +00:00
in6_src.c Remove per-packet ifa refcounting from IPv6 fast path. 2021-02-15 22:33:12 +00:00
in6_var.h Remove per-packet ifa refcounting from IPv6 fast path. 2021-02-15 22:33:12 +00:00
in6.c lltable: fix crash introduced in c541bd368f. 2021-08-22 08:49:18 +00:00
in6.h Expose nonstandard IPv6 kernel definitions to standalone builds. 2020-12-04 21:51:47 +00:00
ip6_ecn.h
ip6_fastfwd.c net: clean up empty lines in .c and .h files 2020-09-01 21:19:14 +00:00
ip6_forward.c ipv6: quit dropping packets looping back on p2p interfaces 2020-08-31 01:45:48 +00:00
ip6_gre.c Introduce NET_EPOCH_CALL() macro and use it everywhere where we free 2020-01-15 06:05:20 +00:00
ip6_id.c
ip6_input.c socket: Implement SO_RERROR 2021-07-28 09:35:09 -07:00
ip6_mroute.c ip6mrouter: Make the expiration callout MPSAFE 2021-09-07 11:19:29 -04:00
ip6_mroute.h
ip6_output.c ipv6: Fix getsockopt() for some IPPROTO_IPV6 level socket options 2021-08-09 09:29:13 +02:00
ip6_var.h Convert route caching to nexthop caching. 2020-04-25 09:06:11 +00:00
ip6.h
ip6protosw.h
ip_fw_nat64.h
ip_fw_nptv6.h net: clean up empty lines in .c and .h files 2020-09-01 21:19:14 +00:00
mld6_var.h icmpv6: Fix mbuf change in mld 2019-11-18 21:59:47 +00:00
mld6.c net: clean up empty lines in .c and .h files 2020-09-01 21:19:14 +00:00
mld6.h
nd6_nbr.c nd6: Make the DAD callout MPSAFE 2021-09-07 11:19:29 -04:00
nd6_rtr.c lltable: fix crash introduced in c541bd368f. 2021-08-22 08:49:18 +00:00
nd6.c inet6(4): Fix a few common typos in source code comments 2021-08-28 18:53:59 +02:00
nd6.h lltable: Add support for "child" LLEs holding encap for IPv4oIPv6 entries. 2021-08-21 17:34:35 +00:00
pim6_var.h
pim6.h
raw_ip6.c socket: Implement SO_RERROR 2021-07-28 09:35:09 -07:00
raw_ip6.h
route6.c Fix m_pullup() problem after removing PULLDOWN_TESTs and KAME EXT_*macros. 2019-12-01 00:22:04 +00:00
scope6_var.h Make net.inet6.ip6.deembed_scopeid behaviour default & remove sysctl. 2020-08-15 11:37:44 +00:00
scope6.c net: clean up empty lines in .c and .h files 2020-09-01 21:19:14 +00:00
sctp6_usrreq.c sctp: Tighten up locking around sctp_aloc_assoc() 2021-09-11 10:15:21 -04:00
sctp6_var.h
send.c socket: Implement SO_RERROR 2021-07-28 09:35:09 -07:00
send.h
tcp6_var.h tcp: add support for TCP over UDP 2021-04-18 16:16:42 +02:00
udp6_usrreq.c socket: Implement SO_RERROR 2021-07-28 09:35:09 -07:00
udp6_var.h