git: 1d4abf2cfa6e - main - reap_kill_subtree_once(): handle proctree_lock unlock in reap_kill_proc()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 13 Jun 2022 19:33:40 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=1d4abf2cfa6e71f4e29ab1f1a6d366d11f3d6027 commit 1d4abf2cfa6e71f4e29ab1f1a6d366d11f3d6027 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2022-05-09 21:41:23 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> 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 &&