freebsd-skq/sys/netinet
Robert Watson 0daccb9c94 In the current world order, solisten() implements the state transition of
a socket from a regular socket to a listening socket able to accept new
connections.  As part of this state transition, solisten() calls into the
protocol to update protocol-layer state.  There were several bugs in this
implementation that could result in a race wherein a TCP SYN received
in the interval between the protocol state transition and the shortly
following socket layer transition would result in a panic in the TCP code,
as the socket would be in the TCPS_LISTEN state, but the socket would not
have the SO_ACCEPTCONN flag set.

This change does the following:

- Pushes the socket state transition from the socket layer solisten() to
  to socket "library" routines called from the protocol.  This permits
  the socket routines to be called while holding the protocol mutexes,
  preventing a race exposing the incomplete socket state transition to TCP
  after the TCP state transition has completed.  The check for a socket
  layer state transition is performed by solisten_proto_check(), and the
  actual transition is performed by solisten_proto().

- Holds the socket lock for the duration of the socket state test and set,
  and over the protocol layer state transition, which is now possible as
  the socket lock is acquired by the protocol layer, rather than vice
  versa.  This prevents additional state related races in the socket
  layer.

This permits the dual transition of socket layer and protocol layer state
to occur while holding locks for both layers, making the two changes
atomic with respect to one another.  Similar changes are likely require
elsewhere in the socket/protocol code.

Reported by:		Peter Holm <peter@holm.cc>
Review and fixes from:	emax, Antoine Brodin <antoine.brodin@laposte.net>
Philosophical head nod:	gnn
2005-02-21 21:58:17 +00:00
..
libalias Sort sections. 2005-01-20 09:17:07 +00:00
accf_data.c add missing #include <sys/module.h> 2004-05-30 20:27:19 +00:00
accf_http.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
icmp6.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
icmp_var.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
if_atm.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
if_atm.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
if_ether.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
if_ether.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
igmp_var.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
igmp.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
igmp.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
in_cksum.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
in_gif.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
in_gif.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
in_pcb.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
in_pcb.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
in_proto.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
in_rmx.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
in_systm.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
in_var.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
in.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
in.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ip6.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ip_divert.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ip_divert.h Convert IPDIVERT into a loadable module. This makes use of the dynamic loadability 2004-10-19 21:14:57 +00:00
ip_dummynet.c - Reduce number of arguments passed to dummynet_io(), we already have cookie 2005-01-16 11:13:18 +00:00
ip_dummynet.h - Reduce number of arguments passed to dummynet_io(), we already have cookie 2005-01-16 11:13:18 +00:00
ip_ecn.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ip_ecn.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ip_encap.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ip_encap.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ip_fastfwd.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ip_fw2.c Jump to common action checks after doing specific once. This fixes adding 2005-02-06 11:13:59 +00:00
ip_fw_pfil.c Add a ng_ipfw node, implementing a quick and simple interface between 2005-02-05 12:06:33 +00:00
ip_fw.h Add a ng_ipfw node, implementing a quick and simple interface between 2005-02-05 12:06:33 +00:00
ip_gre.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ip_gre.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ip_icmp.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ip_icmp.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ip_id.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ip_input.c Prefer (NULL) spelling of (0) for pointers. 2005-01-30 19:29:47 +00:00
ip_mroute.c When running with debug.mpsafenet=0, initialize IP multicast routing 2004-10-07 14:13:35 +00:00
ip_mroute.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ip_output.c Correctly move the packet header in ip_insertoptions(). 2005-01-23 19:43:46 +00:00
ip_var.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ip.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ipprotosw.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
pim_var.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
pim.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
raw_ip.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
tcp_debug.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
tcp_debug.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
tcp_fsm.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
tcp_hostcache.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
tcp_input.c Remove 2 (SACK) fields from the tcpcb. These are only used by a 2005-02-17 23:04:56 +00:00
tcp_output.c Fix a TCP SACK related crash resulting from incorrect computation 2005-01-12 21:40:51 +00:00
tcp_reass.c Remove 2 (SACK) fields from the tcpcb. These are only used by a 2005-02-17 23:04:56 +00:00
tcp_sack.c Remove 2 (SACK) fields from the tcpcb. These are only used by a 2005-02-17 23:04:56 +00:00
tcp_seq.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
tcp_subr.c o Add handling of an IPv4-mapped IPv6 address. 2005-02-14 07:37:51 +00:00
tcp_syncache.c Remove clause three from tcp_syncache.c license per permission of 2005-01-30 19:28:27 +00:00
tcp_timer.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
tcp_timer.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
tcp_timewait.c o Add handling of an IPv4-mapped IPv6 address. 2005-02-14 07:37:51 +00:00
tcp_usrreq.c In the current world order, solisten() implements the state transition of 2005-02-21 21:58:17 +00:00
tcp_var.h Remove 2 (SACK) fields from the tcpcb. These are only used by a 2005-02-17 23:04:56 +00:00
tcp.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
tcpip.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
udp_usrreq.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
udp_var.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
udp.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00