aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/uipc_syscalls.c
diff options
context:
space:
mode:
authorDon Lewis <truckman@FreeBSD.org>1998-11-23 00:45:39 +0000
committerDon Lewis <truckman@FreeBSD.org>1998-11-23 00:45:39 +0000
commit9d2b090975f4a3ed7caf455c05d93dc36ce88311 (patch)
treeb76568ccbce705ecb298eca5ea5930459382d248 /sys/kern/uipc_syscalls.c
parent22b9c86cfd2412ec6675d75ec167a32ddfbdba81 (diff)
downloadsrc-9d2b090975f4a3ed7caf455c05d93dc36ce88311.tar.gz
src-9d2b090975f4a3ed7caf455c05d93dc36ce88311.zip
We can't call fsetown() from sonewconn() because sonewconn() is be called
from an interrupt context and fsetown() wants to peek at curproc, call malloc(..., M_WAITOK), and fiddle with various unprotected data structures. The fix is to move the code that duplicates the F_SETOWN/FIOSETOWN state of the original socket to the new socket from sonewconn() to accept1(), since accept1() runs in the correct context. Deferring this until the process calls accept() is harmless since the process can't do anything useful with SIGIO on the new socket until it has the descriptor for that socket. One could make the case for not bothering to duplicate the F_SETOWN/FIOSETOWN state and requiring the process to explicitly make the fcntl() or ioctl() call on the new socket, but this would be incompatible with the previous implementation and might break programs which rely on the old semantics. This bug was discovered by Andrew Gallatin <gallatin@cs.duke.edu>.
Notes
Notes: svn path=/head/; revision=41298
Diffstat (limited to 'sys/kern/uipc_syscalls.c')
-rw-r--r--sys/kern/uipc_syscalls.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index a857710b20ee..5abf279a893f 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)uipc_syscalls.c 8.4 (Berkeley) 2/21/94
- * $Id: uipc_syscalls.c,v 1.45 1998/11/15 16:55:09 dg Exp $
+ * $Id: uipc_syscalls.c,v 1.46 1998/11/18 09:00:47 dg Exp $
*/
#include "opt_compat.h"
@@ -260,6 +260,8 @@ accept1(p, uap, compat)
so->so_state &= ~SS_COMP;
so->so_head = NULL;
+ if (head->so_sigio != NULL)
+ fsetown(fgetown(head->so_sigio), &so->so_sigio);
fp->f_type = DTYPE_SOCKET;
fp->f_flag = fflag;