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
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
in6_fib_algo.c
in6_fib.c
in6_fib.h
in6_gif.c
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
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
in6_rss.c
in6_rss.h
in6_src.c
in6_var.h
in6.c lltable: fix crash introduced in c541bd368f. 2021-08-22 08:49:18 +00:00
in6.h
ip6_ecn.h
ip6_fastfwd.c
ip6_forward.c
ip6_gre.c
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
ip6.h
ip6protosw.h
ip_fw_nat64.h
ip_fw_nptv6.h
mld6_var.h
mld6.c
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
scope6_var.h
scope6.c
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