diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2018-02-19 11:35:42 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2018-02-19 11:35:42 +0000 |
commit | ebcc90bf1864b82f8e13c4ad8295219b246f3370 (patch) | |
tree | c76bd63e6f220ba6913c62983388103795522182 /sys | |
parent | 7cbd729d49b62edc3d073334c91e791f1bb37634 (diff) |
Grab solock() inside soconnect2() instead of asserting for it to be held.
ok millert@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/uipc_socket.c | 7 | ||||
-rw-r--r-- | sys/kern/uipc_syscalls.c | 8 | ||||
-rw-r--r-- | sys/miscfs/fifofs/fifo_vnops.c | 10 |
3 files changed, 8 insertions, 17 deletions
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index ace43c11592..2f696b36001 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_socket.c,v 1.216 2018/02/19 08:59:52 mpi Exp $ */ +/* $OpenBSD: uipc_socket.c,v 1.217 2018/02/19 11:35:41 mpi Exp $ */ /* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */ /* @@ -337,11 +337,12 @@ soconnect(struct socket *so, struct mbuf *nam) int soconnect2(struct socket *so1, struct socket *so2) { - int error; + int s, error; - soassertlocked(so1); + s = solock(so1); error = (*so1->so_proto->pr_usrreq)(so1, PRU_CONNECT2, NULL, (struct mbuf *)so2, NULL, curproc); + sounlock(s); return (error); } diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index 9eeb53281ed..0c058ffec15 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_syscalls.c,v 1.165 2018/02/19 08:59:52 mpi Exp $ */ +/* $OpenBSD: uipc_syscalls.c,v 1.166 2018/02/19 11:35:41 mpi Exp $ */ /* $NetBSD: uipc_syscalls.c,v 1.19 1996/02/09 19:00:48 christos Exp $ */ /* @@ -447,7 +447,7 @@ sys_socketpair(struct proc *p, void *v, register_t *retval) struct filedesc *fdp = p->p_fd; struct file *fp1, *fp2; struct socket *so1, *so2; - int s, type, cloexec, nonblock, fflag, error, sv[2]; + int type, cloexec, nonblock, fflag, error, sv[2]; type = SCARG(uap, type) & ~(SOCK_CLOEXEC | SOCK_NONBLOCK); cloexec = (SCARG(uap, type) & SOCK_CLOEXEC) ? UF_EXCLOSE : 0; @@ -461,9 +461,7 @@ sys_socketpair(struct proc *p, void *v, register_t *retval) if (error) goto free1; - s = solock(so1); error = soconnect2(so1, so2); - sounlock(s); if (error != 0) goto free2; @@ -471,9 +469,7 @@ sys_socketpair(struct proc *p, void *v, register_t *retval) /* * Datagram socket connection is asymmetric. */ - s = solock(so2); error = soconnect2(so2, so1); - sounlock(s); if (error != 0) goto free2; } diff --git a/sys/miscfs/fifofs/fifo_vnops.c b/sys/miscfs/fifofs/fifo_vnops.c index e6381943927..7fcd631803b 100644 --- a/sys/miscfs/fifofs/fifo_vnops.c +++ b/sys/miscfs/fifofs/fifo_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fifo_vnops.c,v 1.62 2018/01/02 06:38:45 guenther Exp $ */ +/* $OpenBSD: fifo_vnops.c,v 1.63 2018/02/19 11:35:41 mpi Exp $ */ /* $NetBSD: fifo_vnops.c,v 1.18 1996/03/16 23:52:42 christos Exp $ */ /* @@ -143,14 +143,7 @@ fifo_open(void *v) return (error); } fip->fi_writesock = wso; - /* - * XXXSMP - * We only lock `wso' because AF_LOCAL sockets are - * still relying on the KERNEL_LOCK(). - */ - s = solock(wso); if ((error = soconnect2(wso, rso)) != 0) { - sounlock(s); (void)soclose(wso); (void)soclose(rso); free(fip, M_VNODE, sizeof *fip); @@ -158,6 +151,7 @@ fifo_open(void *v) return (error); } fip->fi_readers = fip->fi_writers = 0; + s = solock(wso); wso->so_state |= SS_CANTSENDMORE; wso->so_snd.sb_lowat = PIPE_BUF; } else { |