network - Fix multiple MP races
authorMatthew Dillon <dillon@apollo.backplane.com>
Mon, 13 Sep 2010 05:33:08 +0000 (22:33 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Mon, 13 Sep 2010 05:33:08 +0000 (22:33 -0700)
commit0ce0603ec479756ab4cb88f1958bf08b2772a4cd
tree67522b65bdd1f07b178147f200e9aad7094d7180
parent21b74198714dbfa5d1a9f1094d63725949110c2c
network - Fix multiple MP races

* Fix sonewconn() races.  sonewconn() was attaching prior to changing
  the socket->so_port, relying on the caller to set the socket->so_port.
  This resulted in a race where userland wound up with visibility on the
  socket and could issue commands, like close(), which would end up going
  to the original protocol thread instead of the post-connect protocol thread
  which was handling the sonewconn().

  Thus the close() could message the backend to detach and compete
  against the sonewconn() because the detach message was going to
  a different protocol thread.

* When the socket->so_port is changed the inpcb was not being moved
  from the old pcbinfo->pcblisthead list to the new one, resulting
  in MP races later on during removal.

* Add more debugging kprintf()s.

* Clean up sosetport() use, remove the now-unused *_soport_attach().

Reported-by: Many
14 files changed:
sys/kern/uipc_socket2.c
sys/net/netisr.c
sys/netinet/in_pcb.c
sys/netinet/in_pcb.h
sys/netinet/ip_demux.c
sys/netinet/ip_divert.c
sys/netinet/tcp_subr.c
sys/netinet/tcp_syncache.c
sys/netinet/tcp_usrreq.c
sys/netinet/tcp_var.h
sys/netinet/udp_usrreq.c
sys/netinet/udp_var.h
sys/netinet6/in6_pcb.c
sys/netinet6/udp6_usrreq.c