freebsd-dev/sys/netatalk
Robert Watson 81158452be 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>
2004-10-18 22:19:43 +00:00
..
aarp.c Inline umich license from COPYRIGHT to make it clear what license the 2004-08-10 03:23:05 +00:00
aarp.h
at_control.c Further function forward declaration white space tweaks. 2004-07-19 17:18:58 +00:00
at_extern.h This commit does two things: 2004-04-25 09:24:52 +00:00
at_proto.c
at_rmx.c Imperfect synchronization solution to imperfect code: use a static 256 2004-07-12 18:37:31 +00:00
at_var.h Rename 'at_ifaddr' list to 'at_ifaddr_list' so that the variable is 2004-03-22 04:50:36 +00:00
at.h Add more ethernet types and move AppleTalk types into proper location. 2002-09-06 17:02:29 +00:00
COPYRIGHT
ddp_input.c Inline umich license from COPYRIGHT to make it clear what license the 2004-08-10 03:23:05 +00:00
ddp_output.c Socket MAC labels so_label and so_peerlabel are now protected by 2004-06-13 02:50:07 +00:00
ddp_pcb.c Push acquisition of the accept mutex out of sofree() into the caller 2004-10-18 22:19:43 +00:00
ddp_pcb.h Procotol control block locking for netatalk DDP. 2004-07-12 18:39:59 +00:00
ddp_usrreq.c Procotol control block locking for netatalk DDP. 2004-07-12 18:39:59 +00:00
ddp_var.h Procotol control block locking for netatalk DDP. 2004-07-12 18:39:59 +00:00
ddp.h
endian.h
phase2.h