Page MenuHomeFreeBSD

Better locking in prison_deref, and hide invalid prisons.

Authored by jamie on Feb 2 2021, 5:41 AM.
Referenced Files
F81699961: D28458.diff
Sat, Apr 20, 3:47 AM
Unknown Object (File)
Thu, Apr 18, 7:00 PM
Unknown Object (File)
Wed, Apr 17, 8:17 AM
Unknown Object (File)
Tue, Apr 16, 2:47 AM
Unknown Object (File)
Wed, Apr 3, 4:57 PM
Unknown Object (File)
Thu, Mar 28, 6:33 PM
Unknown Object (File)
Jan 30 2024, 8:25 PM
Unknown Object (File)
Dec 23 2023, 10:02 AM



Change the flow of prison_deref() so it doesn't let go of allprison_lock until it's completely done using it (except for a possible drop as part of an upgrade on its first try). Before this patch, it's possible to unlock and relock allprison_lock multiple times, typically when removing a prison removes its parent.

I'm not sure this is a necessary condition for the next change but it certainly doesn't hurt: add just a little more locking in kern_jail_set(), and now invalid prisons are never seen by any thread holding allprison_lock (except of course the ones creating and destroying prisons). This makes prison_isvalid() redundant, and able to be removed almost everywhere. But instead of removing it, I mostly turned the tests into asserts.

This builds on D27876.

Diff Detail

rG FreeBSD src repository
Lint Skipped
Tests Skipped