AF_UNIX in connectat unp and unp2 can be the same

This commit is contained in:
Matt Macy 2018-05-24 18:22:05 +00:00
parent 6ad033c2f1
commit a3a734908b

View File

@ -1610,14 +1610,18 @@ unp_connectat(int fd, struct socket *so, struct sockaddr *nam,
mac_socketpeer_set_from_socket(so, so2);
mac_socketpeer_set_from_socket(so2, so);
#endif
} else
unp_pcb_lock2(unp, unp2);
} else {
if (unp == unp2)
UNP_PCB_LOCK(unp);
else
unp_pcb_lock2(unp, unp2);
}
KASSERT(unp2 != NULL && so2 != NULL && unp2->unp_socket == so2 &&
sotounpcb(so2) == unp2,
("%s: unp2 %p so2 %p", __func__, unp2, so2));
error = unp_connect2(so, so2, PRU_CONNECT);
UNP_PCB_UNLOCK(unp2);
if (unp != unp2)
UNP_PCB_UNLOCK(unp2);
UNP_PCB_UNLOCK(unp);
bad2:
mtx_unlock(vplock);