svn commit: r334175 - head/sys/kern
Matt Macy
mmacy at FreeBSD.org
Thu May 24 18:22:14 UTC 2018
Author: mmacy
Date: Thu May 24 18:22:13 2018
New Revision: 334175
URL: https://svnweb.freebsd.org/changeset/base/334175
Log:
AF_UNIX: evidently Samba likes to connect a unix socket to itself, fix locking
Modified:
head/sys/kern/uipc_usrreq.c
Modified: head/sys/kern/uipc_usrreq.c
==============================================================================
--- head/sys/kern/uipc_usrreq.c Thu May 24 18:22:05 2018 (r334174)
+++ head/sys/kern/uipc_usrreq.c Thu May 24 18:22:13 2018 (r334175)
@@ -1069,6 +1069,13 @@ uipc_send(struct socket *so, int flags, struct mbuf *m
break;
}
}
+ if (__predict_false(unp == unp2)) {
+ if (unp->unp_socket == NULL) {
+ error = ENOTCONN;
+ break;
+ }
+ goto connect_self;
+ }
unp_pcb_owned_lock2(unp, unp2, freed);
if (__predict_false(freed)) {
UNP_PCB_UNLOCK(unp);
@@ -1088,6 +1095,7 @@ uipc_send(struct socket *so, int flags, struct mbuf *m
error = ENOTCONN;
break;
}
+ connect_self:
if (unp2->unp_flags & UNP_WANTCRED)
control = unp_addsockcred(td, control);
if (unp->unp_addr != NULL)
@@ -1107,7 +1115,8 @@ uipc_send(struct socket *so, int flags, struct mbuf *m
}
if (nam != NULL)
unp_disconnect(unp, unp2);
- UNP_PCB_UNLOCK(unp2);
+ if (__predict_true(unp != unp2))
+ UNP_PCB_UNLOCK(unp2);
UNP_PCB_UNLOCK(unp);
break;
}
More information about the svn-src-head
mailing list