summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_syscalls.c
diff options
context:
space:
mode:
authortruckman <truckman@FreeBSD.org>1998-11-23 00:45:39 +0000
committertruckman <truckman@FreeBSD.org>1998-11-23 00:45:39 +0000
commit0b3bd2def8c0b1aad4cf5df500e9eb3c3947b7c8 (patch)
treed691f40d0b0a4524e2ac6b8b24feccd6908d80ea /sys/kern/uipc_syscalls.c
parent7db1d5d9598a5047cf40b7cd3e796316f31fb862 (diff)
downloadFreeBSD-src-0b3bd2def8c0b1aad4cf5df500e9eb3c3947b7c8.zip
FreeBSD-src-0b3bd2def8c0b1aad4cf5df500e9eb3c3947b7c8.tar.gz
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>.
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 a857710..5abf279 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;
OpenPOWER on IntegriCloud