From: mvs Date: Tue, 18 May 2021 11:15:14 +0000 (+0000) Subject: Move potential sleeping m_getclr(9) out of `unp_lock' within unp_bind(). X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=93985c08b04eab6707fa61b799fad7263ceea757;p=openbsd Move potential sleeping m_getclr(9) out of `unp_lock' within unp_bind(). ok mpi@ --- diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index 5a51fd6d7f6..2dd6d89a252 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_usrreq.c,v 1.146 2021/05/17 17:06:51 claudio Exp $ */ +/* $OpenBSD: uipc_usrreq.c,v 1.147 2021/05/18 11:15:14 mvs Exp $ */ /* $NetBSD: uipc_usrreq.c,v 1.18 1996/02/09 19:00:50 christos Exp $ */ /* @@ -530,6 +530,16 @@ unp_bind(struct unpcb *unp, struct mbuf *nam, struct proc *p) if ((error = unp_nam2sun(nam, &soun, &pathlen))) return (error); + unp->unp_flags |= UNP_BINDING; + + /* + * Enforce `i_lock' -> `unplock' because fifo subsystem + * requires it. The socket can't be closed concurrently + * because the file descriptor reference is still held. + */ + + sounlock(unp->unp_socket, SL_LOCKED); + nam2 = m_getclr(M_WAITOK, MT_SONAME); nam2->m_len = sizeof(struct sockaddr_un); memcpy(mtod(nam2, struct sockaddr_un *), soun, @@ -545,16 +555,6 @@ unp_bind(struct unpcb *unp, struct mbuf *nam, struct proc *p) soun->sun_path, p); nd.ni_pledge = PLEDGE_UNIX; - unp->unp_flags |= UNP_BINDING; - - /* - * Enforce `i_lock' -> `unplock' because fifo subsystem - * requires it. The socket can't be closed concurrently - * because the file descriptor reference is still held. - */ - - sounlock(unp->unp_socket, SL_LOCKED); - KERNEL_LOCK(); /* SHOULD BE ABLE TO ADOPT EXISTING AND wakeup() ALA FIFO's */ error = namei(&nd);