Skip to content

sys: reach child memory through /proc/pid/mem when process_vm is missing - #368

Merged
congwang-mk merged 2 commits into
mainfrom
remote-mem-proc-path
Dec 2, 2026
Merged

congwang-mk merged 2 commits into
mainfrom
remote-mem-proc-path

Conversation

@congwang-mk

Copy link
Copy Markdown
Contributor

Fixes #367.

Problem

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 passed that to the child as EFAULT on every trapped syscall that takes a pointer, so even the dynamic loader's fstat failed and nothing could start unless --no-supervisor was given.

Change

  • New module sys/remote_mem.rs with one read and one write. It probes process_vm_readv once; on ENOSYS every transfer goes through /proc/<pid>/mem.
  • The supervisor helpers in seccomp/notif.rs and the checkpoint capture and resume code call that module. No direct process_vm_* calls remain elsewhere.
  • The mem file reports an unmapped address as EIO; it is mapped to EFAULT so callers see the same error on both paths.
  • Write failures were labelled ChildMemoryRead; they now carry ChildMemoryWrite.

Behavior difference on affected kernels

Writes through /proc/<pid>/mem use FOLL_FORCE, so they also land on read-only pages. On a kernel without process_vm_writev, a child that passes a read-only output buffer (to stat, getdents, ...) gets a successful write where the real syscall would return EFAULT. Kernels with the syscall are unaffected.

Tests

  • New unit tests for the /proc/<pid>/mem read and write primitives, the EFAULT mapping, and the probe.
  • CI passes on the branch, all 25 jobs (run).
  • Not covered: CI kernels have process_vm_*, so nothing has run end to end on a kernel without CONFIG_CROSS_MEMORY_ATTACH. Confirmation from the reporter's sbx microVM would close that gap.

🤖 Generated with Claude Code

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>
@congwang-mk
congwang-mk merged commit 03481d8 into main Dec 2, 2026
25 checks passed
@congwang-mk
congwang-mk deleted the remote-mem-proc-path branch December 2, 2026 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Supervisor fails on kernels without CONFIG_CROSS_MEMORY_ATTACH (process_vm_writev → ENOSYS reported as EFAULT)

1 participant