From nobody Mon Jun 13 19:33:40 2022 X-Original-To: dev-commits-src-main@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 AF9CB85541F; Mon, 13 Jun 2022 19:33:42 +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 4LMMF16nTlz3pwf; Mon, 13 Jun 2022 19:33:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655148822; 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=lomgewGrvtfVNqN1wu2CMCEmLDXgjeXrhdRC6O7Tl6U=; b=pCmYb1gor1jv11oDsys4RZCI3mjoiURUq9BWDDE11TMwWAlW+wwRAPm2eM7v2A28Z6BSy1 rDUPecWJkzRA9shNGPePvnQy2Evts//1fpoc6kogEyeFMswL0feW+aPhnaTXaPrbG3F0Qa u9E1kviU+1COvIgZO0H2A4QygLCFFhykR8vSzHqT3AHbjw6xouQV1f3FMqNCtP74v6gRYa 3r/gRrF0MLqKj8YJ8/lXhR4tNOzYyMlm76b4QFZ4J/6LQwYjGpfapE7AbEengWZ5O3HcLO P6G7BrGguM8/BlQ3/Q1v0E3BQzAeSqZnrBQ/LGKfmd2nnOz4+2/NGEF4+dAErA== 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 D9A3C1BA63; Mon, 13 Jun 2022 19:33:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 25DJXeKr023786; Mon, 13 Jun 2022 19:33:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25DJXevv023785; Mon, 13 Jun 2022 19:33:40 GMT (envelope-from git) Date: Mon, 13 Jun 2022 19:33:40 GMT Message-Id: <202206131933.25DJXevv023785@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: 1d4abf2cfa6e - main - reap_kill_subtree_once(): handle proctree_lock unlock in reap_kill_proc() List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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: 1d4abf2cfa6e71f4e29ab1f1a6d366d11f3d6027 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655148822; 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=lomgewGrvtfVNqN1wu2CMCEmLDXgjeXrhdRC6O7Tl6U=; b=RsK2n5p9Mk/C4w5uSPYu0bS4Tm3R7MjQK9/OWqVkIqHAcSBh/GLZqualCiUF1uojCYcgrS S80YHTWlSRf5nyACDKEFfqc78zsm1XT5tMY7hrfTOXuhq1ZAwbdtsKbYd401wPgArr7oxw /sBVwf0DfPiUcjEy3C2yI/Ul8xOO/EhChJCCVBAs9Kret+Afo5jeyQp/zUwGBo7zFPv35H NjDKcIHVC1X2DRh8h2kfMjKdEskIQX9aX01qJzlwxmNFk654oXFAc6yfcdFongBB9ivgHv 5Jts/KTaAHgoy2yD6e4gn/sjQT6O7vWU6bUQEV4srCMuQqb5AUMCvj3ba3WgaA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655148822; a=rsa-sha256; cv=none; b=hjvvzXOmEd0OcpP3OpjIAxvEPZQBDKEzhnBcKOK9rqjH26sx+8ZMpfbCezVZVotrMZMrSp TquYbZLmiYP63VfMo5kjLjYiND04JauLWggD9ktaV8Lg2NTAOp+8fb9hPmf4Hj2AchLNEn WneJSDyhalF6ZWa4VQyM7qLHfgZBNwQzBYwpoDop6jYeMw5HX3gBWoZ+1v2Bvl4twcwURn PR6J5TW4eGQodquoibYtKBFSQjIzdqj4clRRIkoNWJrroQcphN6i4sLFlM+YCtJwrLeoHa Ht417hxfOTtjodut54Ix+pu3TcK95p1ls9bXsMxa8tPFBl132/FV/LKrHvwEBQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=1d4abf2cfa6e71f4e29ab1f1a6d366d11f3d6027 commit 1d4abf2cfa6e71f4e29ab1f1a6d366d11f3d6027 Author: Konstantin Belousov AuthorDate: 2022-05-09 21:41:23 +0000 Commit: Konstantin Belousov CommitDate: 2022-06-13 19:30:03 +0000 reap_kill_subtree_once(): handle proctree_lock unlock in reap_kill_proc() Recorded reaper might loose its reaper status, so we should not assert it, but check and avoid signalling if this happens. Reported and tested by: pho Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 2 week Differential revision: https://reviews.freebsd.org/D35310 --- sys/kern/kern_procctl.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/sys/kern/kern_procctl.c b/sys/kern/kern_procctl.c index d6c29ed5894a..02469f25bc3d 100644 --- a/sys/kern/kern_procctl.c +++ b/sys/kern/kern_procctl.c @@ -370,8 +370,20 @@ reap_kill_subtree_once(struct thread *td, struct proc *p, struct proc *reaper, TAILQ_INIT(&tracker); reap_kill_sched(&tracker, reaper); while ((t = TAILQ_FIRST(&tracker)) != NULL) { - MPASS((t->parent->p_treeflag & P_TREE_REAPER) != 0); TAILQ_REMOVE(&tracker, t, link); + + /* + * Since reap_kill_proc() drops proctree_lock sx, it + * is possible that the tracked reaper is no longer. + * In this case the subtree is reparented to the new + * reaper, which should handle it. + */ + if ((t->parent->p_treeflag & P_TREE_REAPER) == 0) { + free(t, M_TEMP); + res = true; + continue; + } + LIST_FOREACH(p2, &t->parent->p_reaplist, p_reapsibling) { if (t->parent == reaper && (rk->rk_flags & REAPER_KILL_SUBTREE) != 0 &&