git: 52ea025eba6c - stable/13 - kthread_add(): do not allow to attach the thread to a dead or dying process
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 09 Sep 2023 08:27:59 UTC
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=52ea025eba6c4b9cf560f0dc90ed6c49846637ef commit 52ea025eba6c4b9cf560f0dc90ed6c49846637ef Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2023-09-05 10:54:36 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2023-09-09 08:27:32 +0000 kthread_add(): do not allow to attach the thread to a dead or dying process (cherry picked from commit 96362992330894787a4485f0adc5e867879c5893) --- sys/kern/kern_kthread.c | 4 ++++ 1 file changed, 4 insertions(+) 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,