From nobody Fri Jun 24 19:37:07 2022 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 CD08A864DC8; Fri, 24 Jun 2022 19:37:08 +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 4LV6nv6t31z4XWd; Fri, 24 Jun 2022 19:37:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656099428; 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=z5cjPxdG0PzAxfIZsC4+VHnlPgQgcrIZhR9PUxgU/1s=; b=pWuwq0FcUPTWGvXxXpG3b11cT7ZoM1+nrGg9XYWTMza2f2L7HGIlJ9Zj7hEHHVUICX7qW2 FNxz0fytNDUs+NO0u874rSMb8jGHVUvsycOQjV+HtVfgT/OltGkbPqXtTdCYA4vuCPqCta Yk7voBphbTFc99JuBEn5/aslxV41nTrgxYPfavChG0pQJ+nS7Q5TIQ/ZsreHUjHizDV9mk CUhTTvIaYydIxJTsL3p6w4SU2C/FxsAlpQa3umiVT9OO+YUHGh1JSzjBAG+G0VptGJu0fl RSfDMHIn8I3k5ULXASN0bCA518RBli6TXHNHQCVG2Dm6U2bToFFx26tO/Mn2cg== 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 9EC7216317; Fri, 24 Jun 2022 19:37:07 +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 25OJb7CC084439; Fri, 24 Jun 2022 19:37:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25OJb7A8084438; Fri, 24 Jun 2022 19:37:07 GMT (envelope-from git) Date: Fri, 24 Jun 2022 19:37:07 GMT Message-Id: <202206241937.25OJb7A8084438@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: 935509ba185d - stable/13 - reap_kill_subtree_once(): handle proctree_lock unlock in reap_kill_proc() 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/13 X-Git-Reftype: branch X-Git-Commit: 935509ba185d9c2781fad2bc6bb8ec77a2534a78 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656099428; 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=z5cjPxdG0PzAxfIZsC4+VHnlPgQgcrIZhR9PUxgU/1s=; b=ryf2VCVIOP3wNiukZIiJ7oEkew469OxKGLy/CquUzEptMK9ZUP5Ml5p4AVQkkHTPKVm8L5 T/pLVPB4OHuVkuhr/xGn1MYpvOnWD0K5CSm3l7OFMLa47zF9cZ/LyE/DB+BbYH0XTTawtp gFFfz4R0RZX+1BQ+d9lUZy0lU7bZvjUAxdPNNSZK3I4lVDDzhLw0k6Hs6jh41debjqC0cX TO64hKlTvjZQ9/ATvdXBmCTZESKFi862QI323oum6vXcOD4r+LOF0IDvjFN2p+5WnEg35S aRExXNskBBZfxWG3/AwWQlVhXw7Sy3KJpbocUlE0h5QWhFKrddEd+05kgJm7+A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1656099428; a=rsa-sha256; cv=none; b=YwnfzFoRHuX0TpmSp4+KYHsuNLZIlfMderYhdhx/wCVFVPKfhDjCw75CqU33+TAtaFMS9r cGhKGjodNWEdEGSjjAnkW7Z9tR/kvQAnbFoepXVvm8VYXq8sZOLnYOyFpND8gaHp1yIa81 zINkjrUZKZWwV8Dweyf19wKKZRZA2Tc760tXGNFLcp/GOmdf+PnUpvLdUMwXgqRT1VXfzq pp2neVUSYZQkrXbWHGXq+EVEJm9XoJ0XbCSxeBJul40qHHFawyjRyFLfA8ZTug+5kTQ73V mWmSBOdcTvyGBdOHNnOF5vLt/W7T1FjDxsF3lUQzXaQe47je1mqDZkW/KrALcw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=935509ba185d9c2781fad2bc6bb8ec77a2534a78 commit 935509ba185d9c2781fad2bc6bb8ec77a2534a78 Author: Konstantin Belousov AuthorDate: 2022-05-09 21:41:23 +0000 Commit: Konstantin Belousov CommitDate: 2022-06-24 14:45:46 +0000 reap_kill_subtree_once(): handle proctree_lock unlock in reap_kill_proc() (cherry picked from commit 1d4abf2cfa6e71f4e29ab1f1a6d366d11f3d6027) --- 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 &&