Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Jun 2009 16:10:04 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r194967 - in stable/7/sys: . contrib/pf kern
Message-ID:  <200906251610.n5PGA479056333@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Thu Jun 25 16:10:04 2009
New Revision: 194967
URL: http://svn.freebsd.org/changeset/base/194967

Log:
  MFC: Fix a deadlock in the getpeername() method for UNIX domain sockets.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/kern/uipc_usrreq.c

Modified: stable/7/sys/kern/uipc_usrreq.c
==============================================================================
--- stable/7/sys/kern/uipc_usrreq.c	Thu Jun 25 15:47:32 2009	(r194966)
+++ stable/7/sys/kern/uipc_usrreq.c	Thu Jun 25 16:10:04 2009	(r194967)
@@ -672,7 +672,7 @@ uipc_peeraddr(struct socket *so, struct 
 	KASSERT(unp != NULL, ("uipc_peeraddr: unp == NULL"));
 
 	*nam = malloc(sizeof(struct sockaddr_un), M_SONAME, M_WAITOK);
-	UNP_PCB_LOCK(unp);
+	UNP_GLOBAL_RLOCK();
 	/*
 	 * XXX: It seems that this test always fails even when connection is
 	 * established.  So, this else clause is added as workaround to
@@ -682,7 +682,7 @@ uipc_peeraddr(struct socket *so, struct 
 	if (unp2 != NULL) {
 		UNP_PCB_LOCK(unp2);
 		if (unp2->unp_addr != NULL)
-			sa = (struct sockaddr *) unp->unp_conn->unp_addr;
+			sa = (struct sockaddr *) unp2->unp_addr;
 		else
 			sa = &sun_noname;
 		bcopy(sa, *nam, sa->sa_len);
@@ -691,7 +691,7 @@ uipc_peeraddr(struct socket *so, struct 
 		sa = &sun_noname;
 		bcopy(sa, *nam, sa->sa_len);
 	}
-	UNP_PCB_UNLOCK(unp);
+	UNP_GLOBAL_RUNLOCK();
 	return (0);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906251610.n5PGA479056333>