Repository navigation
sys: reach child memory through /proc/pid/mem when process_vm is missing - #368
Merged
Merged
Conversation
Kernels built without CONFIG_CROSS_MEMORY_ATTACH (the Docker Sandbox microVM kernel is one) return ENOSYS from process_vm_readv and process_vm_writev. The supervisor reported that to the child as EFAULT on every trapped syscall that passes a pointer, so even the dynamic loader's fstat failed and nothing could start (#367). All supervisor and checkpoint transfers now go through one module that probes the syscall once and uses /proc/<pid>/mem where it is absent. Writes through the mem file also land on read-only pages, so on such a kernel a read-only output buffer no longer yields EFAULT. Write failures were also labelled as read failures; they now carry ChildMemoryWrite. Signed-off-by: Cong Wang <cwang@multikernel.io>
No CI kernel lacks CONFIG_CROSS_MEMORY_ATTACH, so the /proc/<pid>/mem path was only covered by unit tests of its primitives. A new test binary installs a seccomp filter before the harness starts that makes process_vm_readv and process_vm_writev return ENOSYS, as such a kernel does, then reruns the chroot, checkpoint and restore suites and the case reported in #367. It is a separate binary because the probe result is cached per process and the filter cannot be removed. Signed-off-by: Cong Wang <cwang@multikernel.io>
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.
Fixes #367.
Problem
Kernels built without
CONFIG_CROSS_MEMORY_ATTACH(the Docker Sandbox microVM kernel is one) returnENOSYSfromprocess_vm_readvandprocess_vm_writev. The supervisor passed that to the child asEFAULTon every trapped syscall that takes a pointer, so even the dynamic loader'sfstatfailed and nothing could start unless--no-supervisorwas given.Change
sys/remote_mem.rswith onereadand onewrite. It probesprocess_vm_readvonce; onENOSYSevery transfer goes through/proc/<pid>/mem.seccomp/notif.rsand the checkpoint capture and resume code call that module. No directprocess_vm_*calls remain elsewhere.EIO; it is mapped toEFAULTso callers see the same error on both paths.ChildMemoryRead; they now carryChildMemoryWrite.Behavior difference on affected kernels
Writes through
/proc/<pid>/memuseFOLL_FORCE, so they also land on read-only pages. On a kernel withoutprocess_vm_writev, a child that passes a read-only output buffer (tostat,getdents, ...) gets a successful write where the real syscall would returnEFAULT. Kernels with the syscall are unaffected.Tests
/proc/<pid>/memread and write primitives, theEFAULTmapping, and the probe.process_vm_*, so nothing has run end to end on a kernel withoutCONFIG_CROSS_MEMORY_ATTACH. Confirmation from the reporter's sbx microVM would close that gap.🤖 Generated with Claude Code