HomeFreeBSD

MFS jail: Handle a possible race between jail_remove(2) and fork(2)

Description

MFS jail: Handle a possible race between jail_remove(2) and fork(2)

jail_remove(2) includes a loop that sends SIGKILL to all processes
in a jail, but skips processes in PRS_NEW state. Thus it is possible
the a process in mid-fork(2) during jail removal can survive the jail
being removed.

Add a prison flag PR_REMOVE, which is checked before the new process
returns. If the jail is being removed, the process will then exit.
Also check this flag in jail_attach(2) which has a similar issue.

Approved by: re (gjb)
Reported by: trasz
Approved by: kib

(cherry picked from commit cc7b73065302005ebc4a19503188c8d6d5eb923d)
(cherry picked from commit 894360bacd42f021551f76518edd445f6d299f2e)

Details

Provenance
jamieAuthored on Feb 16 2021, 7:19 PM
Parents
rG889cf2bf73a0: ffs_vnops.c: Move opt_*.h includes to the top.
Branches
Unknown
Tags
Unknown