freebsd-skq/sys/netipx
rwatson 4b81ce6dd2 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
..
ipx_cksum.c Avoid casts as lvalues. Declare local variable as u_char * instead of 2004-07-28 06:58:23 +00:00
ipx_if.h Update netisr handling; Each SWI now registers its queue, and all queue 2003-03-04 23:19:55 +00:00
ipx_input.c o add a flags parameter to netisr_register that is used to specify 2003-11-08 22:28:40 +00:00
ipx_ip.c Replace the if_name and if_unit members of struct ifnet with new members 2003-10-31 18:32:15 +00:00
ipx_ip.h
ipx_outputfl.c Use __FBSDID(). 2003-06-11 05:37:42 +00:00
ipx_pcb.c Push acquisition of the accept mutex out of sofree() into the caller 2004-10-18 22:19:43 +00:00
ipx_pcb.h Correct typos, mostly s/ a / an / where appropriate. Some whitespace cleanup, 2003-01-01 18:49:04 +00:00
ipx_proto.c Use __FBSDID(). 2003-06-11 05:37:42 +00:00
ipx_usrreq.c Push acquisition of the accept mutex out of sofree() into the caller 2004-10-18 22:19:43 +00:00
ipx_var.h Update netisr handling; Each SWI now registers its queue, and all queue 2003-03-04 23:19:55 +00:00
ipx.c Mark Netgraph TTY, KAME IPSEC, and IPX/SPX as requiring Giant for correct 2004-08-28 15:24:53 +00:00
ipx.h Improve source-code compatibility with Linux applications using the 2004-06-22 21:46:49 +00:00
README
spx_debug.c Use __FBSDID(). 2003-06-11 05:37:42 +00:00
spx_debug.h Make spxnames a const char * to quieten some warnings in netstat. 2002-07-27 23:15:08 +00:00
spx_timer.h
spx_usrreq.c Constify 'spx_backoff'. 2004-07-12 19:35:29 +00:00
spx_var.h
spx.h

$FreeBSD$

This protocol implements IPX/SPX over Ethernet_II frame type 0x8137.
Please note: the SPX implementation may require further work and testing
to insure proper operation.

Mike Mitchell, Network Engineer
AMTECH Systems Corporation, Technology and Manufacturing
8600 Jefferson Street, Albuquerque, New Mexico 87113 (505) 856-8000
supervisor@alb.asctmd.com

John Hay
Some Company
Some Address
jhay@mikom.csir.co.za

--- Copyright Information ---

Copyright (c) 1984, 1985, 1986, 1987, 1993
The Regents of the University of California.  All rights reserved.

Modifications Copyright (c) 1995, Mike Mitchell
Modifications Copyright (c) 1995, John Hay