mirror of
https://github.com/freebsd/freebsd-src
synced 2024-11-02 19:51:25 +00:00
unix: Fix locking in uipc_peeraddr()
After the locking protocol changed in commit 75a67bf3d0
("AF_UNIX:
make unix socket locking finer grained"), uipc_peeraddr() was not
updated accordingly.
The link lock now only protects global socket lists. The PCB lock is
used to protect the link between connected PCBs, so use that. Remove an
old comment which appears to be noting that unp_conn is not set for
connected SOCK_DGRAM sockets (in one direction anyway).
Reviewed by: glebius
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D39855
This commit is contained in:
parent
fc2e2c950d
commit
e8f6e5b2d9
1 changed files with 4 additions and 9 deletions
|
@ -885,15 +885,10 @@ uipc_peeraddr(struct socket *so, struct sockaddr **nam)
|
|||
KASSERT(unp != NULL, ("uipc_peeraddr: unp == NULL"));
|
||||
|
||||
*nam = malloc(sizeof(struct sockaddr_un), M_SONAME, M_WAITOK);
|
||||
UNP_LINK_RLOCK();
|
||||
/*
|
||||
* XXX: It seems that this test always fails even when connection is
|
||||
* established. So, this else clause is added as workaround to
|
||||
* return PF_LOCAL sockaddr.
|
||||
*/
|
||||
unp2 = unp->unp_conn;
|
||||
|
||||
UNP_PCB_LOCK(unp);
|
||||
unp2 = unp_pcb_lock_peer(unp);
|
||||
if (unp2 != NULL) {
|
||||
UNP_PCB_LOCK(unp2);
|
||||
if (unp2->unp_addr != NULL)
|
||||
sa = (struct sockaddr *) unp2->unp_addr;
|
||||
else
|
||||
|
@ -904,7 +899,7 @@ uipc_peeraddr(struct socket *so, struct sockaddr **nam)
|
|||
sa = &sun_noname;
|
||||
bcopy(sa, *nam, sa->sa_len);
|
||||
}
|
||||
UNP_LINK_RUNLOCK();
|
||||
UNP_PCB_UNLOCK(unp);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue