criu: restore nested PID namespace hierarchies correctly - #21
criu: restore nested PID namespace hierarchies correctly#21yiying-zhang wants to merge 11 commits into
Conversation
Drop --keep-pid-hierarchy from the Phase B restore argv
|
Reviewed all three commits — the direction is right: replacing the piecemeal One validation gap to close before merge Dropping the thread Minor / non-blocking
Otherwise LGTM. |
Summary
Fix CRIU restoration for workloads containing nested PID namespaces, including cases where the nested namespace’s init process—PID 1—is already a zombie.
The current
gensee-tcloneimplementation preserves the dumped PID hierarchy with--keep-pid-hierarchy, then tries to remove outer levels piecemeal during Phase B. This produces inconsistent PID chains: some process and thread restore paths retain dumped outer/host namespace IDs, while others use only the local ID.In the reproduced workload, CRIU consequently calls
clone3()withset_tid=[1, 6]after PID 6 is already occupied, causing restoration to fail withEEXIST.Changes
--keep-pid-hierarchyduring tfork restore.new_pid_ns_truncate_pid_hierarchy()remove only the PID namespace levels outside the restore target.clone3(set_tid).CLONE_PARENT.CLONE_NEWPIDfor a zombie namespace init when its missing task IDs image preventsget_clone_mask()from inferring it.The two CRIU fix commits retain the original student author attribution.
Zombie observer PID
CRIU stores PID namespace values with:
pid.ns[0]: PID in the innermost namespaceThe PID visible to an ancestor observer is selected with:
For an outer parent at namespace level 1 observing an init process at level 2, this selects index 1: the PID visible in the outer namespace.
Using
localpid(pi)instead selects index 0, which is PID 1 inside the nested namespace. The outer parent cannot use that PID to track or reap the zombie.Why
CLONE_NEWPIDmust be repairedCRIU normally derives namespace creation flags from the task’s IDs image.
A zombie namespace init does not have that image, so
get_clone_mask()cannot infer that the process must be created withCLONE_NEWPID. The restore path now detects a non-root process whose innermost PID is 1 and restores the missing flag.Validation
Test host:
Build:
make -j8 zdtmResult: passed.
Negative control
Current
gensee-tcloneplus only the new regression test:Fails during restore as expected:
Fixed branch
The same focused test passes:
Existing compatibility tests also pass: