]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
MFC 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>
Fri, 12 Mar 2021 18:30:06 +0000 (10:30 -0800)
commitad259c473dc645725225cfda307323de48c87051
treee3f67c73039111df5bbec61d1e3ab1cd0d5734e1
parentfe6b360a62931eaea450ab9ac9b41daac5996e51
MFC 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

(cherry picked from commit f7496dcab0360a74bfb00cd6118f66323fffda61)

MFC jail: fix build after the previous commit
Noted by: Michael Butler <imb protected-networks.net>

(cherry picked from commit ee9b37ae5c115c41835119bb5c9d2e14c83abd65)
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