summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_fork.c
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2009-12-28 02:54:24 +0000
committerguenther <guenther@openbsd.org>2009-12-28 02:54:24 +0000
commit819e4fd85c58460dfea3060fc729ffbdb22d512e (patch)
tree91ca3ed0b8c2a2e9a822978ca2c4afbe5d71bbcc /sys/kern/kern_fork.c
parentAdd MCP73_AHCI_5 to list of devices started in that special NVidia (diff)
downloadwireguard-openbsd-819e4fd85c58460dfea3060fc729ffbdb22d512e.tar.xz
wireguard-openbsd-819e4fd85c58460dfea3060fc729ffbdb22d512e.zip
Sanity check flags in fork1(), banning some combos we don't support
and catching FORK_THREAD when RTHREADS wasn't compiled in. Simplify sys_rfork() based on that. Flesh out the Linux clone support with more flags, but stricter checks for missing support or bad combos. Still not enough for NPTL to work, mind you. ok kettenis@
Diffstat (limited to 'sys/kern/kern_fork.c')
-rw-r--r--sys/kern/kern_fork.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index ac6721c2a4c..1d9fe52edc5 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_fork.c,v 1.106 2009/12/23 07:40:31 guenther Exp $ */
+/* $OpenBSD: kern_fork.c,v 1.107 2009/12/28 02:54:24 guenther Exp $ */
/* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */
/*
@@ -141,10 +141,9 @@ sys_rfork(struct proc *p, void *v, register_t *retval)
if (rforkflags & RFMEM)
flags |= FORK_SHAREVM;
-#ifdef RTHREADS
+
if (rforkflags & RFTHREAD)
- flags |= FORK_THREAD | FORK_SIGHAND;
-#endif
+ flags |= FORK_THREAD | FORK_SIGHAND | FORK_NOZOMBIE;
return (fork1(p, SIGCHLD, flags, NULL, 0, NULL, NULL, retval, NULL));
}
@@ -190,6 +189,20 @@ fork1(struct proc *p1, int exitsig, int flags, void *stack, size_t stacksize,
void *newstrp = NULL;
#endif
+ /* sanity check some flag combinations */
+ if (flags & FORK_THREAD)
+ {
+#ifdef RTHREADS
+ if ((flags & (FORK_SIGHAND | FORK_NOZOMBIE)) !=
+ (FORK_SIGHAND | FORK_NOZOMBIE))
+ return (EINVAL);
+#else
+ return (ENOTSUP);
+#endif
+ }
+ if (flags & FORK_SIGHAND && (flags & FORK_SHAREVM) == 0)
+ return (EINVAL);
+
/*
* Although process entries are dynamically created, we still keep
* a global limit on the maximum number we will create. We reserve