checkpoint: execve-stub restore path (primitive proof)#141
Merged
Conversation
Signed-off-by: Cong Wang <cwang@multikernel.io>
Signed-off-by: Cong Wang <cwang@multikernel.io>
Signed-off-by: Cong Wang <cwang@multikernel.io>
Signed-off-by: Cong Wang <cwang@multikernel.io>
Signed-off-by: Cong Wang <cwang@multikernel.io>
…_DIR Signed-off-by: Cong Wang <cwang@multikernel.io>
Signed-off-by: Cong Wang <cwang@multikernel.io>
Signed-off-by: Cong Wang <cwang@multikernel.io>
…h) and mark staged code Signed-off-by: Cong Wang <cwang@multikernel.io>
… build warnings Signed-off-by: Cong Wang <cwang@multikernel.io>
d136f85 to
b50df02
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Introduces the execve-stub restore path: a checkpoint is restored by exec-ing a freestanding stub into a fresh process that self-reconstructs its address space, rather than driving a puppet through ptrace injection. This first cut proves the primitive end to end for a trivial single-region program, entirely unprivileged (no sysctl, no
CAP_SYS_PTRACE).How it works
restore-stub(a freestanding, no-libc, no-PIE binary) with the blob and two eventfds on fixed inherited fds.MAP_FIXEDwith its captured prot, registers them with userfaultfd (missing mode), exposes the uffd to the supervisor, signals READY, waits for GO, thenrt_sigreturns into the checkpoint register context.pidfd_getfdand serves each faulting page withUFFDIO_COPYfrom the blob.What is proven
The end-to-end test restores a hand-assembled program (write a sentinel byte to an inherited pipe, then exit) whose code lives in an anonymous region served on fault. Reading the sentinel proves the stub mapped the region, registered uffd,
rt_sigreturnd to the checkpoint rip/rsp, and the pager filled the faulting code page.Notable correctness points
O_NONBLOCK:poll()on a blocking uffd always reportsPOLLERR, so a polling pager would never see a fault.vm.unprivileged_userfaultfd=0, creation falls back toUFFD_USER_MODE_ONLY, which serves the user-mode faults this path relies on without privilege.PROT_EXECwould fault as a protection violation rather than a serviceable missing-page fault).Known limitations (follow-up)
-no-pieand links low; restoring a real program whose own text occupies that range would clobber the running stub. The next phase relocates the stub out of the way.USER_MODE_ONLYcannot serve kernel-mode faults (a syscall touching an unfilled page); the planned solution is prefaulting pointer args from the seccomp-notify supervisor.Testing
checkpointunit tests (blob round-trip, pager page service): pass.test_restore_stubend-to-end integration test: pass.🤖 Generated with Claude Code