From nobody Tue Sep 05 16:30:40 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Rg9wd2YC6z4rmmx; Tue, 5 Sep 2023 16:30:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Rg9wc6Y2wz4nQv; Tue, 5 Sep 2023 16:30:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1693931440; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=g8jIUYeaPX7PyVfgS1kpARedemRm7ZCgKFUSyf11X1I=; b=QWBpArbh5W4GmoU0yJ0OgZvoJRveohMaqgzgnhSWuB69SgTi/WMMD6QC/72Jvz2PQI1Az8 jiZh0fiRVtpvbk99QEPw77QCUOjrbEb+Hhj8w6LrRhJ8RtohZpQsS8VKZjoxON4skkshDY PYA/E4ft8Q7JfIjPqwRMxhZpBH66bw5o3ZJtZTMQvZwIwfJ0kTXRfpBFpbReMoJ7D43YZ2 WwGHAk/1iJMSdVJuqc7GkcLTp0WzFgzCzTOrWSx9qcCcxjUulUTCmvk9/1X3AXLzYFIad1 2tbKhPuyV3LzbH583iboEXbOgH01wwBcJEkvgrJQaoPDtTeIjVcwaznMDOLuWA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1693931440; a=rsa-sha256; cv=none; b=J5gTUvr1QHLuDnbCh7FJqAhylzGDtCGgqAbYHcVzQpEkM2Wmb7aeh5VbaSL0GD51TjnKfM 0GTqjdDiXS77Zxthamo/OCqYc9vfk9N5/yeA/FZzROB0JOGngjCavopVkNg8AmIzAtUNWk d+Zi1WmeIl1tZOv7p3oINtYFTLgZV2O0iR+inb4PKk6LHyGI/C5qqCAqVS96BBkEuDPZTH LL0yn7Lvvr6dOpLTf36ZFcTy0ic4X5S3gjfQUNra/A6WaLGCm7p+mQMX0S3IONarF+A/aC FIuCY84VoUDWdA7j52HytPbaD03vxfVYGJZu7iYBHmatBUESH0064xQPB8R6Ow== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1693931440; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=g8jIUYeaPX7PyVfgS1kpARedemRm7ZCgKFUSyf11X1I=; b=cQ558o3U5DUj9D976KNfj3wxb0txxaYCNAYHtjkXz9IHP9/bC3hnMmX5B5wb5QczBwhSgX SqWHxEES7AVmKsLTOLGeaschyT6XBvxK84dWQRG5CzcMGbjD3D5npXqK2hYn+op0wHFdLl hydyvdoCOO+m/Wt1TgzWvzc+a6fK/XRRrDNjc9FTSQFxBjNiI2X/Uu7VMbIpOoQdI9IHI+ myPJ2K2c27WTgb0vElBVqxAl+fwdT7moKCP6s2XkwGmof9irmXSXf2oLrNb75v6X3HVJWg ED3M4ch0avCD+9iBCqFSwdiHYLomuBsVYPUwjmpPYsxFNMsYp99ERY8bUG2tNw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Rg9wc5WWqzgRh; Tue, 5 Sep 2023 16:30:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 385GUe7U085816; Tue, 5 Sep 2023 16:30:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 385GUeis085813; Tue, 5 Sep 2023 16:30:40 GMT (envelope-from git) Date: Tue, 5 Sep 2023 16:30:40 GMT Message-Id: <202309051630.385GUeis085813@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 963629923308 - main - kthread_add(): do not allow to attach the thread to a dead or dying process List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 96362992330894787a4485f0adc5e867879c5893 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=96362992330894787a4485f0adc5e867879c5893 commit 96362992330894787a4485f0adc5e867879c5893 Author: Konstantin Belousov AuthorDate: 2023-09-05 10:54:36 +0000 Commit: Konstantin Belousov 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,