cvs commit: src/sys/kern kern_descrip.c uipc_socket.c uipc_usrreq.c src/sys/net raw_cb.c raw_usrreq.c src/sys/netatalk ddp_pcb.c src/sys/netatm atm_socket.cng_btsocket_l2cap.c ...

Robert Watson rwatson at FreeBSD.org
Mon Oct 18 15:19:44 PDT 2004


rwatson     2004-10-18 22:19:43 UTC

  FreeBSD src repository

  Modified files:
    sys/kern             kern_descrip.c uipc_socket.c 
                         uipc_usrreq.c 
    sys/net              raw_cb.c raw_usrreq.c 
    sys/netatalk         ddp_pcb.c 
    sys/netatm           atm_socket.c 
    sys/netgraph/bluetooth/socket ng_btsocket_hci_raw.c 
                                  ng_btsocket_l2cap.c 
                                  ng_btsocket_l2cap_raw.c 
                                  ng_btsocket_rfcomm.c 
    sys/netinet          in_pcb.c tcp_subr.c 
    sys/netinet6         in6_pcb.c 
    sys/netipx           ipx_pcb.c ipx_usrreq.c 
    sys/netnatm          natm.c 
    sys/sys              socketvar.h 
  Log:
  Push acquisition of the accept mutex out of sofree() into the caller
  (sorele()/sotryfree()):
  
  - This permits the caller to acquire the accept mutex before the socket
    mutex, avoiding sofree() having to drop the socket mutex and re-order,
    which could lead to races permitting more than one thread to enter
    sofree() after a socket is ready to be free'd.
  
  - This also covers clearing of the so_pcb weak socket reference from
    the protocol to the socket, preventing races in clearing and
    evaluation of the reference such that sofree() might be called more
    than once on the same socket.
  
  This appears to close a race I was able to easily trigger by repeatedly
  opening and resetting TCP connections to a host, in which the
  tcp_close() code called as a result of the RST raced with the close()
  of the accepted socket in the user process resulting in simultaneous
  attempts to de-allocate the same socket.  The new locking increases
  the overhead for operations that may potentially free the socket, so we
  will want to revise the synchronization strategy here as we normalize
  the reference counting model for sockets.  The use of the accept mutex
  in freeing of sockets that are not listen sockets is primarily
  motivated by the potential need to remove the socket from the
  incomplete connection queue on its parent (listen) socket, so cleaning
  up the reference model here may allow us to substantially weaken the
  synchronization requirements.
  
  RELENG_5_3 candidate.
  
  MFC after:      3 days
  Reviewed by:    dwhite
  Discussed with: gnn, dwhite, green
  Reported by:    Marc UBM Bocklet <ubm at u-boot-man dot de>
  Reported by:    Vlad <marchenko at gmail dot com>
  
  Revision  Changes    Path
  1.246     +1 -0      src/sys/kern/kern_descrip.c
  1.214     +4 -3      src/sys/kern/uipc_socket.c
  1.141     +1 -0      src/sys/kern/uipc_usrreq.c
  1.30      +1 -0      src/sys/net/raw_cb.c
  1.35      +1 -0      src/sys/net/raw_usrreq.c
  1.45      +1 -0      src/sys/netatalk/ddp_pcb.c
  1.21      +1 -0      src/sys/netatm/atm_socket.c
  1.16      +1 -0      src/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c
  1.14      +2 -0      src/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c
  1.13      +1 -0      src/sys/netgraph/bluetooth/socket/ng_btsocket_l2cap_raw.c
  1.13      +1 -0      src/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c
  1.156     +1 -0      src/sys/netinet/in_pcb.c
  1.205     +1 -0      src/sys/netinet/tcp_subr.c
  1.61      +1 -0      src/sys/netinet6/in6_pcb.c
  1.29      +1 -0      src/sys/netipx/ipx_pcb.c
  1.41      +1 -0      src/sys/netipx/ipx_usrreq.c
  1.35      +2 -0      src/sys/netnatm/natm.c
  1.135     +10 -2     src/sys/sys/socketvar.h


More information about the cvs-src mailing list