criu

Restartable Sequences (rseq)

Restartable Sequences (rseq) is a Linux kernel feature (introduced in v4.18) that enables high-performance userspace operations on per-CPU data without requiring atomic instructions or traditional locking. Each thread registers a struct rseq, and the kernel ensures that if a thread is preempted or interrupted while inside a critical section, it is “restarted” by jumping to a predefined abort handler.

The Challenge of C/R with rseq

Checkpointing and restoring rseq is exceptionally delicate because the kernel’s rseq state is tightly coupled with process execution.

  1. Dumping Sensitivity: If an infected thread is allowed to run even briefly (e.g., to execute parasite code), the kernel’s rseq_handle_notify_resume hook may be triggered. This would cause the kernel to “fix up” the rseq state, clearing critical section pointers in userspace memory and losing the very state CRIU needs to capture.
  2. Restoration Morphing: During restoration, CRIU “morphs” into the target process. If the CRIU binary itself was compiled with rseq support (common in modern distributions), it may have an active rseq registration that must be carefully managed before the memory layout is swapped.

How CRIU Handles rseq

CRIU provides robust support for rseq, ensuring that threads interrupted within a critical section correctly restart after restoration.

1. Checkpointing (Dumping)

CRIU captures the rseq configuration without disturbing the thread’s execution state:

2. Restoration

The restoration process involves two critical rseq-related steps:

Kernel Requirements

See also