git: 70e76f81e594 - stable/14 - 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:02 UTC
The branch stable/14 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=70e76f81e594e108054446bfc890eeaeace5a839 commit 70e76f81e594e108054446bfc890eeaeace5a839 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:26:33 +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,