From nobody Sat Sep 09 08:27:02 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 4RjR0k52NGz4sNtv; Sat, 9 Sep 2023 08:27:02 +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 4RjR0k4V7yz4M0T; Sat, 9 Sep 2023 08:27:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694248022; 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=7/a6i4Q0Xktl4WeFlc40gLPMvWmhj6MJ7QZ/jPK2HtI=; b=MQfC0Kwr/ku3q+D/ulTexmotcpvtmtAuDj5DeAzthW91Pzt1qp1LX3yf4I4zvnYIyGZ+NB z0X4K7xzHTPu0e6JlKZ09hOsEIe0vZ4C1Hpy8+qOIYU6vtMYdRRMfg6Xplg4vlANTUAs4N /Z9pAnsOZc0FADc+F+zJpxD5OZrAlrKhI4kizrwniXy9sMtbu3k8KGzfWxHL59qPypBHvh 35phS1eRrdWWS8+pf+VscxIDAOcBqT8CtAg+MfSMX2uVd7H7K7dvk3NkYKvJG6O3j59YRk FiIsR+nZldTGrYMo3oVu2pGjyj92yRnLLYuFsD8jt1YuxrzLBEJkGjqdbdv3vQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1694248022; a=rsa-sha256; cv=none; b=eBOYIjqWTXSeCa6Q7cUITiFoEn4PmWE6WPK1UA7iSSGOUP9ER/XHAzQ+tV8ag3QpSFN707 h1bbyTqBI0ImrxUqf7LW6j4nEkm6EtEbOK01U+I4wiV5oD2aCYVBcpZ+tINPlk7QdVSlAu i2AjH3pLhmUkOccB6LDg+M6NRcqPzOw0Y0qG+yF8l1Icz2EbLrOLg4M9SAHcw/I4bVSAnZ hKlU0n1AfFhAvT0WBiQI6Vkp/IqoG9QLwumIIG0Y4txVYioKAGWNVY+wzlr7BmpfMkxy8Q 7U5MvndbY3QuC9ru02KLyRQRFwpbrDCB7wfQVMi3qSWZeLkpFdN1lZ25Ikd7uQ== 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=1694248022; 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=7/a6i4Q0Xktl4WeFlc40gLPMvWmhj6MJ7QZ/jPK2HtI=; b=bqs19WhPouu6uUCx+AO25Q8XGZaj6CwkCwiqiLjFoe9IKFQWiZGOg65iAdfQkkGzqUTl1u QRCexHr7WMCWd0IcT2QEsizX488COT5BeK5tIaGgqO9XhHg45RnTkAuO1A56M+ImNBhzX9 djAQTovOVr64cjOQ2lvKI2He0dpvr62zh0xdWeaz08wkev9pE0CHu0lY65Z/2ZKFQZM98k kOIbEwJYogyV+m60y9eHmawqwdxF6MZIITXWNHCJzGY1QO7qXmy6N++RUfeDubXBGbbxaH A8R+KCKtfVSnx7fa/qV290iMw8JwQ0LJ6kC02dmoT9mwj7whKIu2oJUaMfrsWA== 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 4RjR0k3Fj0z38K; Sat, 9 Sep 2023 08:27:02 +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 3898R2cA053718; Sat, 9 Sep 2023 08:27:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3898R2rh053715; Sat, 9 Sep 2023 08:27:02 GMT (envelope-from git) Date: Sat, 9 Sep 2023 08:27:02 GMT Message-Id: <202309090827.3898R2rh053715@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 70e76f81e594 - stable/14 - 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/stable/14 X-Git-Reftype: branch X-Git-Commit: 70e76f81e594e108054446bfc890eeaeace5a839 Auto-Submitted: auto-generated The branch stable/14 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=70e76f81e594e108054446bfc890eeaeace5a839 commit 70e76f81e594e108054446bfc890eeaeace5a839 Author: Konstantin Belousov AuthorDate: 2023-09-05 10:54:36 +0000 Commit: Konstantin Belousov 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,