fix(vm): make sandbox process startup fork-safe - #2658
Closed
kholia wants to merge 1 commit into
Closed
Conversation
Prepare executable paths, named identities, supplementary groups,
Landlock handles, and runtime seccomp programs in the supervisor before
fork. Entrypoint and SSH pre-exec hooks now consume prepared numeric
state and keep their successful path to the required namespace,
credential, hardening, Landlock, seccomp-install, and exec syscalls.
Direct Linux setgroups/setresgid/setresuid calls avoid libc setxid
coordination, while static error markers avoid tracing and formatting in
the child.
This removes NSS, initgroups, PATH search, filter compilation, and
allocator-backed seccomp cleanup from the multithreaded post-fork child.
It fixes the supervisor spawn deadlock that left VM clients waiting
indefinitely before a process PID could be published.
Also mirror the selected lower root filesystem owner and mode onto the
VM overlay upper root before mounting it. The overlay upper directory
had inherited the host umask and UID, exposing the merged guest root as
mode 0700 and causing the named sandbox identity to fail exec with
EACCES after the original deadlock was removed.
Add regressions for parent-side executable and identity resolution,
supplementary-group preservation, SSH hook preparation, and overlay root
metadata ordering. Update the sandbox architecture and security
enforcement-order documentation.
Validated with workspace pre-commit, complete process-supervisor and
VM-driver unit suites, VM smoke/host-gateway/resume E2E, and a
named-identity interactive PTY relay held open for more than 45 seconds.
This was debugged and tested on a Ubuntu 26.04 AMD64 box.
Config:
```
$ cat ~/.config/openshell/gateway.toml
[openshell.gateway]
compute_drivers = ["vm"]
log_level = "debug"
[openshell.drivers.vm]
mem_mib = 4096
vcpus = 2
```
Before:
```
$ openshell sandbox create --name demo-fixed
✓ Sandbox allocated (0s) ✓ Sandbox allocated (0s) ✓ Sandbox allocated (0s) ✓ Sandbox allocated (0s)
✓ Sandbox allocated (0s)
⠚ Starting sandbox... Waiting for VM supervisor (2m) # gets stuck
✗ sandbox provisioning timed out after 300s. Last reported status: Starting: VM is starting
```
After:
```
$ time openshell sandbox create --name demo-fixed
Created sandbox: demo-fixed ✓ Sandbox allocated (0s)
✓ Sandbox allocated (0s) ✓ Sandbox allocated (0s) ✓ Sandbox allocated (0s) sandbox@demo-fixed:~$
exit
real 0m1.832s
```
Fixes NVIDIA#2587
Signed-off-by: Dhiru Kholia <kholia@users.noreply.github.com>
kholia
requested review from
a team,
derekwaynecarr,
maxamillion and
mrunalp
as code owners
August 8, 2026 07:12
|
All contributors have signed the DCO ✍️ ✅ |
|
Thank you for your interest in contributing to OpenShell, @kholia. This project uses a vouch system for first-time contributors. Before submitting a pull request, you need to be vouched by a maintainer. To get vouched:
See CONTRIBUTING.md for details. |
Author
|
I have read the DCO document and I hereby sign the DCO. |
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.
Prepare executable paths, named identities, supplementary groups, Landlock handles, and runtime seccomp programs in the supervisor before fork. Entrypoint and SSH pre-exec hooks now consume prepared numeric state and keep their successful path to the required namespace, credential, hardening, Landlock, seccomp-install, and exec syscalls. Direct Linux setgroups/setresgid/setresuid calls avoid libc setxid coordination, while static error markers avoid tracing and formatting in the child.
This removes NSS, initgroups, PATH search, filter compilation, and allocator-backed seccomp cleanup from the multithreaded post-fork child. It fixes the supervisor spawn deadlock that left VM clients waiting indefinitely before a process PID could be published.
Also mirror the selected lower root filesystem owner and mode onto the VM overlay upper root before mounting it. The overlay upper directory had inherited the host umask and UID, exposing the merged guest root as mode 0700 and causing the named sandbox identity to fail exec with EACCES after the original deadlock was removed.
Add regressions for parent-side executable and identity resolution, supplementary-group preservation, SSH hook preparation, and overlay root metadata ordering. Update the sandbox architecture and security enforcement-order documentation.
Validated with workspace pre-commit, complete process-supervisor and VM-driver unit suites, VM smoke/host-gateway/resume E2E, and a named-identity interactive PTY relay held open for more than 45 seconds.
This was debugged and tested on a Ubuntu 26.04 AMD64 box.
Config:
Before:
After:
Fixes #2587
Summary
This change enables the
vmdriver to work and create sandboxes (on Linux at least).Related Issue
#2587
Testing
mise run pre-commitpassesChecklist