The branch stable/15 has been updated by jamie: URL: https://cgit.FreeBSD.org/src/commit/?id=315238df53233a35752146cf291a37049a4656a3
commit 315238df53233a35752146cf291a37049a4656a3 Author: Jamie Gritton <[email protected]> AuthorDate: 2026-06-19 19:45:27 +0000 Commit: Jamie Gritton <[email protected]> CommitDate: 2026-06-24 17:47:43 +0000 jail: call PR_METHOD_ATTACH again (with old jail) if the first call fails jail_attach lets modules do attachment-specific work by calling osd_jail_call(PR_METHOD_ATTACH). If one of the modules returns an error, the call needs to be repeated with the thread's current prison, so possible earlier modules and undo any changes they may have made. (cherry picked from commit e91e8ebefadcce9d57c8ff945ff70050cbbe1ce1) --- sys/kern/kern_jail.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c index 43acde461e40..72ccbdf77550 100644 --- a/sys/kern/kern_jail.c +++ b/sys/kern/kern_jail.c @@ -3024,10 +3024,8 @@ do_jail_attach(struct thread *td, struct prison *pr, int drflags) /* Let modules do whatever they need to prepare for attaching. */ error = osd_jail_call(pr, PR_METHOD_ATTACH, td); - if (error) { - prison_deref(pr, drflags); - return (error); - } + if (error) + goto e_revert_osd; sx_unlock(&allprison_lock); drflags &= ~(PD_LIST_SLOCKED | PD_LIST_XLOCKED); @@ -3093,8 +3091,10 @@ do_jail_attach(struct thread *td, struct prison *pr, int drflags) VOP_UNLOCK(pr->pr_root); e_revert_osd: /* Tell modules this thread is still in its old jail after all. */ - sx_slock(&allprison_lock); - drflags |= PD_LIST_SLOCKED; + if (!(drflags & (PD_LIST_SLOCKED | PD_LIST_XLOCKED))) { + sx_slock(&allprison_lock); + drflags |= PD_LIST_SLOCKED; + } (void)osd_jail_call(td->td_ucred->cr_prison, PR_METHOD_ATTACH, td); prison_deref(pr, drflags); return (error);
