aboutsummaryrefslogtreecommitdiff
path: root/sys/netatalk
diff options
context:
space:
mode:
authorRobert Watson <rwatson@FreeBSD.org>2004-10-18 22:19:43 +0000
committerRobert Watson <rwatson@FreeBSD.org>2004-10-18 22:19:43 +0000
commit81158452be7803fda8aa36feb4464d5301dce85c (patch)
treee18ee35e276065c19e56111431141fc111be57fb /sys/netatalk
parent6bd0a54ae4046dc35159343983c2241f6f3e942d (diff)
downloadsrc-81158452be7803fda8aa36feb4464d5301dce85c.tar.gz
src-81158452be7803fda8aa36feb4464d5301dce85c.zip
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>
Notes
Notes: svn path=/head/; revision=136682
Diffstat (limited to 'sys/netatalk')
-rw-r--r--sys/netatalk/ddp_pcb.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/sys/netatalk/ddp_pcb.c b/sys/netatalk/ddp_pcb.c
index 8073d553af8b..dd69850cd8fd 100644
--- a/sys/netatalk/ddp_pcb.c
+++ b/sys/netatalk/ddp_pcb.c
@@ -282,6 +282,7 @@ at_pcbdetach(struct socket *so, struct ddpcb *ddp)
DDP_LOCK_ASSERT(ddp);
soisdisconnected(so);
+ ACCEPT_LOCK();
SOCK_LOCK(so);
so->so_pcb = NULL;
sotryfree(so);