diff options
author | Philip Guenthe <guenther@cvs.openbsd.org> | 2009-12-28 02:54:25 +0000 |
---|---|---|
committer | Philip Guenthe <guenther@cvs.openbsd.org> | 2009-12-28 02:54:25 +0000 |
commit | fa5989e93dadf4c4259fb99782a792cfcfc04779 (patch) | |
tree | 5dc84ca656c7546c2a448365ab1ca29eb401eb97 /sys/kern/kern_fork.c | |
parent | f270b9bbc87c6e6b700174af3bc6aed85a8f38bc (diff) |
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.c | 21 |
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 |