HomeFreeBSD

jail: prevent a race between jail_attach in different threads

Description

jail: prevent a race between jail_attach in different threads

Attaching to a jail changes its root directory and its process
credentials. These operations both require unlocking the jail, and also
need allprison_lock unlocked. That means that if two threads are trying
to attach to different jails at the same time, it's possible for the
process to end up with one jail's root directory but the other jail's
credentials.

Solve this by forcing the process into single-threaded mode during
system calls that attach to a jail (jail_attach, jail_attach_jd, and
sometimes jail_set).

Reviewed by: kib, markj
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D57858

Details

Provenance
jamieAuthored on Jul 2 2026, 10:48 PM
Reviewer
kib
Differential Revision
D57858: Prevent a jail_attach race between threads
Parents
rGcd61eb4f6681: zfs: Wire sha512 offload to the build
Branches
Unknown
Tags
Unknown