Skip to content

fix(vm): make sandbox process startup fork-safe - #2658

Closed
kholia wants to merge 1 commit into
NVIDIA:mainfrom
kholia:vm-mode-fixes
Closed

fix(vm): make sandbox process startup fork-safe#2658
kholia wants to merge 1 commit into
NVIDIA:mainfrom
kholia:vm-mode-fixes

Conversation

@kholia

@kholia kholia commented Aug 8, 2026

Copy link
Copy Markdown

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 #2587

Summary

This change enables the vm driver to work and create sandboxes (on Linux at least).

Related Issue

#2587

Testing

  • mise run pre-commit passes
  • Unit tests added/updated
  • E2E tests added/updated (if applicable)

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)
  • Architecture docs updated (if applicable)

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>
@copy-pr-bot

copy-pr-bot Bot commented Aug 8, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown

All contributors have signed the DCO ✍️ ✅
Posted by the DCO Assistant Lite bot.

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown

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:

  1. Open a Vouch Request discussion.
  2. Describe what you want to change and why.
  3. Write in your own words — do not have an AI generate the request.
  4. A maintainer will comment /vouch if approved.
  5. Once vouched, open a new PR (preferred) or reopen this one after a few minutes.

See CONTRIBUTING.md for details.

@github-actions github-actions Bot closed this Aug 8, 2026
@kholia

kholia commented Aug 8, 2026

Copy link
Copy Markdown
Author

I have read the DCO document and I hereby sign the DCO.

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.

VM sandbox SSH session disconnects with broken pipe

1 participant