]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
MFC jail: Handle a possible race between jail_remove(2) and fork(2)
authorJamie Gritton <jamie@FreeBSD.org>
Tue, 16 Feb 2021 19:19:13 +0000 (11:19 -0800)
committerJamie Gritton <jamie@FreeBSD.org>
Fri, 19 Feb 2021 21:44:19 +0000 (13:44 -0800)
commitf7007a7d05255a6859dea0982b1f0a6d695e8881
tree1069f96f73ffd841e349f9717c18401c5d1ee8a9
parent57d2eb8896c2dd9ece7d99415893e2e8a8bfce82
MFC 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.

Reported by:    trasz
Approved by:    kib

(cherry picked from commit cc7b73065302005ebc4a19503188c8d6d5eb923d)
sys/kern/kern_fork.c
sys/kern/kern_jail.c
sys/sys/jail.h