]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
jail: Change the locking around pr_ref and pr_uref
authorJamie Gritton <jamie@FreeBSD.org>
Sun, 21 Feb 2021 18:55:44 +0000 (10:55 -0800)
committerJamie Gritton <jamie@FreeBSD.org>
Sun, 21 Feb 2021 18:55:44 +0000 (10:55 -0800)
commitf7496dcab0360a74bfb00cd6118f66323fffda61
tree3d2905671ada32ea912fac4d913fbcc430628b6f
parentb963ce4588b33f733aef3f7a7f3fbe5018a89728
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
sys/kern/kern_jail.c
sys/kern/sysv_msg.c
sys/kern/sysv_sem.c
sys/kern/sysv_shm.c
sys/kern/uipc_mqueue.c
sys/sys/jail.h