diff options
| author | Konstantin Belousov <kib@FreeBSD.org> | 2023-09-05 10:54:36 +0000 |
|---|---|---|
| committer | Konstantin Belousov <kib@FreeBSD.org> | 2023-09-05 16:30:08 +0000 |
| commit | 96362992330894787a4485f0adc5e867879c5893 (patch) | |
| tree | 56ebb8dfff2d04b44e66a725190aa7ee6a6ea519 | |
| parent | ba675bb94870fcb1a07018920433e9468003364c (diff) | |
kthread_add(): do not allow to attach the thread to a dead or dying process
Reported by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
| -rw-r--r-- | sys/kern/kern_kthread.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/sys/kern/kern_kthread.c b/sys/kern/kern_kthread.c index 5e32aea1f56d..6f7fd8b3d555 100644 --- a/sys/kern/kern_kthread.c +++ b/sys/kern/kern_kthread.c @@ -281,6 +281,10 @@ kthread_add1(void (*func)(void *), void *arg, struct proc *p, return (ENOMEM); PROC_LOCK(p); + if (p->p_state == PRS_ZOMBIE || (p->p_flag2 & P2_WEXIT) != 0) { + PROC_UNLOCK(p); + return (ESRCH); + } oldtd = FIRST_THREAD_IN_PROC(p); bzero(&newtd->td_startzero, |
