Date: Mon, 20 Oct 2025 16:54:28 GMT From: Jamie Gritton <jamie@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 78f70d4ff9dd - main - jail: fix a regression that creates zombies when removing dying jails Message-ID: <202510201654.59KGsS4p017499@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch main has been updated by jamie: URL: https://cgit.FreeBSD.org/src/commit/?id=78f70d4ff9dd4af2318b25023a7f55be7402ec60 commit 78f70d4ff9dd4af2318b25023a7f55be7402ec60 Author: Jamie Gritton <jamie@FreeBSD.org> AuthorDate: 2025-10-20 16:49:14 +0000 Commit: Jamie Gritton <jamie@FreeBSD.org> CommitDate: 2025-10-20 16:49:14 +0000 jail: fix a regression that creates zombies when removing dying jails When adding jail descriptors, I split sys_jail remove in two, and didn't properly track jail held between them when a jail was dying. This fixes that as well as cleaning up the logic behind it. PR: 290217 Reported by: David 'equinox' Lamparter <equinox at diac24.net> Reviewed by: markj MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D53200 --- sys/kern/kern_jail.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c index 3697d95fe0e5..00732d55cd46 100644 --- a/sys/kern/kern_jail.c +++ b/sys/kern/kern_jail.c @@ -2909,12 +2909,6 @@ prison_remove(struct prison *pr) { sx_assert(&allprison_lock, SA_XLOCKED); mtx_assert(&pr->pr_mtx, MA_OWNED); - if (!prison_isalive(pr)) { - /* Silently ignore already-dying prisons. */ - mtx_unlock(&pr->pr_mtx); - sx_xunlock(&allprison_lock); - return; - } prison_deref(pr, PD_KILL | PD_DEREF | PD_LOCKED | PD_LIST_XLOCKED); } @@ -3461,12 +3455,17 @@ prison_deref(struct prison *pr, int flags) /* Kill the prison and its descendents. */ KASSERT(pr != &prison0, ("prison_deref trying to kill prison0")); - if (!(flags & PD_DEREF)) { - prison_hold(pr); - flags |= PD_DEREF; + if (!prison_isalive(pr)) { + /* Silently ignore already-dying prisons. */ + flags &= ~PD_KILL; + } else { + if (!(flags & PD_DEREF)) { + prison_hold(pr); + flags |= PD_DEREF; + } + flags = prison_lock_xlock(pr, flags); + prison_deref_kill(pr, &freeprison); } - flags = prison_lock_xlock(pr, flags); - prison_deref_kill(pr, &freeprison); } if (flags & PD_DEUREF) { /* Drop a user reference. */home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202510201654.59KGsS4p017499>
