Date: Thu, 24 May 2018 18:22:13 +0000 (UTC) From: Matt Macy <mmacy@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334175 - head/sys/kern Message-ID: <201805241822.w4OIMDpU026488@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201805241822.w4OIMDpU026488>