freebsd-dev/sys/netgraph
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
..
atm Apply error and success logic consistently to the function netisr_queue() and 2004-08-27 18:33:08 +00:00
bluetooth Push acquisition of the accept mutex out of sofree() into the caller 2004-10-18 22:19:43 +00:00
netflow - Remove advertising clause from copyright [1] 2004-09-17 19:58:03 +00:00
netgraph.h Align netgraph message fields ready for 64-bit (and 128 bit :-) machines. 2004-08-20 01:24:23 +00:00
ng_async.c
ng_async.h
ng_atmllc.c
ng_atmllc.h
ng_base.c
ng_bpf.c
ng_bpf.h
ng_bridge.c Convert ipfw to use PFIL_HOOKS. This is change is transparent to userland 2004-08-17 22:05:54 +00:00
ng_bridge.h
ng_cisco.c
ng_cisco.h
ng_device.c Major overhaul. 2004-10-18 20:13:57 +00:00
ng_device.h Major overhaul. 2004-10-18 20:13:57 +00:00
ng_echo.c
ng_echo.h
ng_eiface.c Remove orphaned comment about Meta data. 2004-09-11 08:59:06 +00:00
ng_eiface.h
ng_etf.c
ng_etf.h
ng_ether.c Fix packet flow when both ng_ether(4) and bridge(4) are in use: 2004-10-12 10:33:42 +00:00
ng_ether.h
ng_fec.c Avoid casts as lvalues. 2004-07-28 06:59:55 +00:00
ng_fec.h
ng_frame_relay.c
ng_frame_relay.h
ng_gif_demux.c
ng_gif_demux.h
ng_gif.c Avoid casts as lvalues. 2004-07-28 06:59:55 +00:00
ng_gif.h
ng_hole.c
ng_hole.h
ng_hub.c
ng_hub.h
ng_iface.c
ng_iface.h
ng_ip_input.c
ng_ip_input.h
ng_ksocket.c In FreeBSD 5.x, curthread is always defined, so we don't need to to test 2004-09-02 19:53:13 +00:00
ng_ksocket.h
ng_l2tp.c Implement minimalistic L2TP sessions statistics and correct man page 2004-08-03 06:52:55 +00:00
ng_l2tp.h Implement minimalistic L2TP sessions statistics and correct man page 2004-08-03 06:52:55 +00:00
ng_lmi.c
ng_lmi.h
ng_message.h Align netgraph message fields ready for 64-bit (and 128 bit :-) machines. 2004-08-20 01:24:23 +00:00
ng_mppc.c
ng_mppc.h
ng_one2many.c
ng_one2many.h
ng_parse.c Avoid casts as lvalues. 2004-07-28 06:59:55 +00:00
ng_parse.h
ng_ppp.c Do not change link[n].conf.latency for internal usage but have 2004-08-03 06:34:55 +00:00
ng_ppp.h
ng_pppoe.c Another stupid error from my side. PPPOE_NONSTANDARD was first defined 2004-08-01 20:39:33 +00:00
ng_pppoe.h
ng_pptpgre.c Increase PPTP_MAX_TIMEOUT up to 3 seconds. 10 prooved too much for high packet 2004-09-06 19:53:58 +00:00
ng_pptpgre.h
ng_rfc1490.c
ng_rfc1490.h
ng_sample.c Address node in a less complex way. 2004-07-29 08:05:02 +00:00
ng_sample.h
ng_socket.c Acquire Giant arounds calls into the linker from Netgraph sockets. 2004-08-30 14:41:25 +00:00
ng_socket.h
ng_socketvar.h
ng_source.c
ng_source.h
ng_split.c
ng_split.h
ng_sppp.c
ng_sppp.h
ng_tee.c
ng_tee.h
ng_tty.c Fix an issue with ng_tty which (ab)used the tty->t_sc field which is 2004-09-17 22:26:27 +00:00
ng_tty.h
ng_UI.c
ng_UI.h
ng_vjc.c
ng_vjc.h
ng_vlan.c
ng_vlan.h
NOTES