From 2260c03d77cc9130374e042bebfe8c56594fba1d Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Sun, 18 Jul 2004 01:29:43 +0000 Subject: [PATCH] Drop Giant and acquire the UNIX domain socket subsystem lock a bit earlier in unp_connect() so that vp->v_socket can't change between our copying its value to a local variable and later use of that variable. This may have been responsible for a panic during shutdown that I experienced where simultaneous closing of a listen socket by rpcbind and a new connection being made to rpcbind by mountd. --- sys/kern/uipc_usrreq.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index 74740124f56..1a87d14a16a 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -794,17 +794,17 @@ unp_connect(so, nam, td) error = VOP_ACCESS(vp, VWRITE, td->td_ucred, td); if (error) goto bad; + mtx_unlock(&Giant); + UNP_LOCK(); so2 = vp->v_socket; if (so2 == NULL) { error = ECONNREFUSED; - goto bad; + goto bad2; } if (so->so_type != so2->so_type) { error = EPROTOTYPE; - goto bad; + goto bad2; } - mtx_unlock(&Giant); - UNP_LOCK(); if (so->so_proto->pr_flags & PR_CONNREQUIRED) { if (so2->so_options & SO_ACCEPTCONN) { /*