Date: Tue, 15 Sep 2020 19:23:42 +0000 (UTC) From: Mark Johnston <markj@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r365765 - head/sys/kern Message-ID: <202009151923.08FJNgdr059550@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: markj Date: Tue Sep 15 19:23:42 2020 New Revision: 365765 URL: https://svnweb.freebsd.org/changeset/base/365765 Log: Fix locking in uipc_accept(). This function wasn't converted to use the new locking protocol in r333744. Make it use the PCB lock for synchronizing connection state. Tested by: pho Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D26300 Modified: head/sys/kern/uipc_usrreq.c Modified: head/sys/kern/uipc_usrreq.c ============================================================================== --- head/sys/kern/uipc_usrreq.c Tue Sep 15 19:23:22 2020 (r365764) +++ head/sys/kern/uipc_usrreq.c Tue Sep 15 19:23:42 2020 (r365765) @@ -499,18 +499,14 @@ uipc_accept(struct socket *so, struct sockaddr **nam) KASSERT(unp != NULL, ("uipc_accept: unp == NULL")); *nam = malloc(sizeof(struct sockaddr_un), M_SONAME, M_WAITOK); - UNP_LINK_RLOCK(); - unp2 = unp->unp_conn; - if (unp2 != NULL && unp2->unp_addr != NULL) { - UNP_PCB_LOCK(unp2); - sa = (struct sockaddr *) unp2->unp_addr; - bcopy(sa, *nam, sa->sa_len); - UNP_PCB_UNLOCK(unp2); - } else { + UNP_PCB_LOCK(unp); + unp2 = unp_pcb_lock_peer(unp); + if (unp2 != NULL && unp2->unp_addr != NULL) + sa = (struct sockaddr *)unp2->unp_addr; + else sa = &sun_noname; - bcopy(sa, *nam, sa->sa_len); - } - UNP_LINK_RUNLOCK(); + bcopy(sa, *nam, sa->sa_len); + unp_pcb_unlock_pair(unp, unp2); return (0); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202009151923.08FJNgdr059550>