The parasite code is a specialized binary blob that CRIU injects into the address space of a target process during a checkpoint. Its primary purpose is to extract internal task state—such as private memory contents, credentials, and signal handlers—that is not available via standard kernel interfaces like /proc.
Infection is a multi-stage operation managed by the Compel sub-project, leveraging the ptrace system call to take control of the target process.
CRIU stops the target task using PTRACE_SEIZE followed by PTRACE_INTERRUPT. This ensures a non-disruptive stop without delivering signals to the application, maintaining transparency.
CRIU identifies the task’s current instruction pointer (RIP/PC) and uses PTRACE_POKEDATA to temporarily inject a small bootstrap payload. This payload is typically designed to execute a system call (such as mmap or memfd_create) to allocate a dedicated memory region for the full parasite blob.
To maximize efficiency and avoid thousands of slow ptrace calls, CRIU uses a memory exchange technique:
memfd).Since the parasite is a Position-Independent Executable (PIE), CRIU must patch its GOT table with the actual addresses where the blob was mapped in the target process’s address space.
CRIU sets the task’s instruction pointer to the entry point of the parasite and resumes execution using PTRACE_CONT. The parasite initializes its own stack, sets up signal handling for its own internal use, and enters daemon mode.
The parasite runs as a daemon within the target task’s context, communicating with the main CRIU process via a Unix domain socket.
The parasite enters a loop where it waits for commands from the CRIU coordinator. Each command follows a Request-Response pattern:
PARASITE_CMD_DUMP_PAGES) and any necessary arguments through the socket.vmsplice on its own memory).vmsplice() system call./proc.Once the state capture is complete, CRIU performs a “cure” operation to return the process to its original state:
PARASITE_CMD_FINI command to the daemon.