Page MenuHomeFreeBSD

Better locking in prison_deref, and hide invalid prisons.
ClosedPublic

Authored by jamie on Feb 2 2021, 5:41 AM.
Tags
None
Referenced Files
F161162744: D28458.diff
Wed, Jul 1, 3:31 AM
F161133448: D28458.id84356.diff
Tue, Jun 30, 8:28 PM
Unknown Object (File)
Mon, Jun 29, 7:07 PM
Unknown Object (File)
Mon, Jun 22, 4:40 PM
Unknown Object (File)
Sun, Jun 21, 12:30 PM
Unknown Object (File)
Fri, Jun 19, 7:43 PM
Unknown Object (File)
Mon, Jun 15, 2:14 PM
Unknown Object (File)
Mon, Jun 15, 1:56 PM
Subscribers
None

Details

Summary

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

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable