git: 963629923308 - main - 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: Tue, 05 Sep 2023 16:30:40 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=96362992330894787a4485f0adc5e867879c5893 commit 96362992330894787a4485f0adc5e867879c5893 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2023-09-05 10:54:36 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2023-09-05 16:30:08 +0000 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 --- 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,