HomeFreeBSD

jail: Change the locking around pr_ref and pr_uref

Description

jail: Change the locking around pr_ref and pr_uref

Require both the prison mutex and allprison_lock when pr_ref or
pr_uref go to/from zero. Adding a non-first or removing a non-last
reference remain lock-free. This means that a shared hold on
allprison_lock is sufficient for prison_isalive() to be useful, which
removes a number of cases of lock/check/unlock on the prison mutex.

Expand the locking in kern_jail_set() to keep allprison_lock held
exclusive until the new prison is valid, thus making invalid prisons
invisible to any thread holding allprison_lock (except of course the
one creating or destroying the prison). This renders prison_isvalid()
nearly redundant, now used only in asserts.

Differential Revision: https://reviews.freebsd.org/D28419
Differential Revision: https://reviews.freebsd.org/D28458

Details

Provenance
jamieAuthored on Feb 21 2021, 6:55 PM
Differential Revision
D28419: Require allprison_lock and prison mutex when to free last prison reference
Parents
R10:b963ce4588b3: sctp: improve computation of an alternate net
Branches
Unknown
Tags
Unknown