summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2017-07-12 09:25:48 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2017-07-12 09:25:48 +0000
commit4c10bb1e952802978efff50d3814cde68a5e5780 (patch)
tree6f3bb45ae20b1a24f7bea2eac56553e8ad4eb1e6 /sys
parenta0abd8f9b95def0ebf3cdf38b71291594a970daf (diff)
Do not call fo_ioctl() in syscall that do, or will, take the socket
lock. Prevents a future lock recursion since soo_ioctl() will need to grab the lock. ok bluhm@, visa@
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/uipc_syscalls.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index e346c161d90..e041ac1bb1e 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_syscalls.c,v 1.152 2017/07/03 23:05:21 bluhm Exp $ */
+/* $OpenBSD: uipc_syscalls.c,v 1.153 2017/07/12 09:25:47 mpi Exp $ */
/* $NetBSD: uipc_syscalls.c,v 1.19 1996/02/09 19:00:48 christos Exp $ */
/*
@@ -110,10 +110,10 @@ sys_socket(struct proc *p, void *v, register_t *retval)
closef(fp, p);
fdpunlock(fdp);
} else {
- fp->f_data = so;
if (type & SOCK_NONBLOCK)
- (*fp->f_ops->fo_ioctl)(fp, FIONBIO, (caddr_t)&type, p);
+ so->so_state |= SS_NBIO;
so->so_state |= ss;
+ fp->f_data = so;
FILE_SET_MATURE(fp, p);
*retval = fd;
}
@@ -332,12 +332,15 @@ doaccept(struct proc *p, int sock, struct sockaddr *name, socklen_t *anamelen,
fp->f_type = DTYPE_SOCKET;
fp->f_flag = FREAD | FWRITE | nflag;
fp->f_ops = &socketops;
- fp->f_data = so;
error = soaccept(so, nam);
if (!error && name != NULL)
error = copyaddrout(p, nam, name, namelen, anamelen);
if (!error) {
- (*fp->f_ops->fo_ioctl)(fp, FIONBIO, (caddr_t)&nflag, p);
+ if (nflag & FNONBLOCK)
+ so->so_state |= SS_NBIO;
+ else
+ so->so_state &= ~SS_NBIO;
+ fp->f_data = so;
FILE_SET_MATURE(fp, p);
*retval = tmpfd;
}