Date: Fri, 29 Jan 2021 05:52:17 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: c050ea803eaa - main - jail: Handle a parent jail when a child is added to it Message-ID: <202101290552.10T5qHSl023735@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by jamie: URL: https://cgit.FreeBSD.org/src/commit/?id=c050ea803eaa1087313b86628b5d486c0e59e41b commit c050ea803eaa1087313b86628b5d486c0e59e41b Author: Jamie Gritton <jamie@FreeBSD.org> AuthorDate: 2021-01-29 05:51:09 +0000 Commit: Jamie Gritton <jamie@FreeBSD.org> CommitDate: 2021-01-29 05:51:09 +0000 jail: Handle a parent jail when a child is added to it It's possible when adding a jail that its dying parent comes back to life. Only allow that to happen when JAIL_DYING is specified. And if it does happen, call PR_METHOD_CREATE on it. --- sys/kern/kern_jail.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c index 064f1afa4133..ece0aa33e642 100644 --- a/sys/kern/kern_jail.c +++ b/sys/kern/kern_jail.c @@ -1105,6 +1105,14 @@ kern_jail_set(struct thread *td, struct uio *optuio, int flags) "jail \"%s\" not found", name); goto done_deref; } + if (!(flags & JAIL_DYING) && + !prison_isalive(ppr)) { + mtx_unlock(&ppr->pr_mtx); + error = ENOENT; + vfs_opterror(opts, + "jail \"%s\" is dying", name); + goto done_deref; + } mtx_unlock(&ppr->pr_mtx); *namelc = '.'; } @@ -1200,8 +1208,18 @@ kern_jail_set(struct thread *td, struct uio *optuio, int flags) goto done_deref; } prison_hold(ppr); - refcount_acquire(&ppr->pr_uref); - mtx_unlock(&ppr->pr_mtx); + if (refcount_acquire(&ppr->pr_uref)) + mtx_unlock(&ppr->pr_mtx); + else { + /* This brings the parent back to life. */ + mtx_unlock(&ppr->pr_mtx); + error = osd_jail_call(ppr, PR_METHOD_CREATE, opts); + if (error) { + pr = ppr; + drflags |= PD_DEREF | PD_DEUREF; + goto done_deref; + } + } if (jid == 0 && (jid = get_next_prid(&inspr)) == 0) { error = EAGAIN;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202101290552.10T5qHSl023735>