Repository navigation
Description
User Story
I run OpenShell sandboxes with the Podman and Kubernetes drivers, and I read through the isolation core (openshell-sandbox, openshell-binary-identity, openshell-isolation-interface) at 00528d24a. This item comes from reading the code. I have not hit it in production. It is one line of the umbrella issue #5179.
Problem Statement
The workload pre_exec hooks run in the forked child of a multithreaded process. They call enforce_capability_free, which calls seccomp::apply (crates/openshell-sandbox/src/sandbox/linux/seccomp.rs:75). That builds both the main and the compatibility filter inside the child: BTreeMap allocations, seccompiler compilation, and a debug! callsite at seccomp.rs:198. On a best-effort Landlock failure, landlock::enforce (sandbox/linux/landlock.rs:419) also emits an OCSF event from the child.
The // SAFETY: comments say otherwise: pty.rs:70 and pty.rs:104 claim "all allocations and policy compilation happened before spawn", and process.rs:629 says the hook only calls setpgid and setns.
ChildHardeningProgram already prebuilds the child self-protection filter in the parent. The main and compatibility filters are not prebuilt.
Impact / Why This Matters
If another thread holds the allocator, a tracing or subscriber mutex, or the OCSF writer lock at the moment of fork, the child can block before exec. Debug logging also writes "Restricting socket domains via seccomp" to the child's stdout, which is already the workload's pipe or PTY. The comments mislead reviewers of the fork path.
Acceptance Criteria
- Both seccomp filters are compiled into
BpfPrograms in the parent (for example insidePreparedSandbox) and the child only installs them. - No allocation,
tracingcall, or OCSF emission runs betweenforkandexecinprocess.rs,pty.rs, andlandlock::enforce(report the best-effort Landlock failure from the parent or after exec). - The three
// SAFETY:comments describe what the hooks actually do. - A test or check covers the post-fork path, for example a unit test asserting the hook performs only prebuilt operations.
Reproduction Steps
Found by reading the code; not reproduced live. Run a sandbox with debug logging enabled and watch the workload's stdout for Restricting socket domains via seccomp, which comes from the forked child. The hang itself needs a lock held across fork and is not expected to be reproducible on demand.
Environment
- OpenShell:
mainat00528d24a - OS: Fedora 44, Linux 7.2.14
- Deployment: Podman driver (local gateway); code read for the Kubernetes driver too
Activity
mrunalp commentedon Nov 3, 2026
Accepted for implementation in #5216.
Source inspection at
32dcc4a67: Seccomp apply builds both filters at installation time and includes tracing, while the child-side Landlock enforcement path can emit OCSF. Preparing filters before fork and reporting degradation from the parent addresses the reported post-fork allocation/logging hazards.This assessment is based on the source and the linked report/PR; I have not independently run deployment reproductions or the PR test suite. CI and code review still need to validate the fix.
docs(sandbox): correct pre_exec SAFETY comments
fix(sandbox): document unsafe blocks and enforce SAFETY comments with…
refactor(sandbox): prebuild seccomp filters before fork
fix(sandbox): report Landlock best-effort failure from the parent
docs(sandbox): correct pre_exec SAFETY comments
refactor(sandbox): prebuild seccomp filters before fork
fix(sandbox): report Landlock best-effort failure from the parent
docs(sandbox): correct pre_exec SAFETY comments
fix(sandbox): carry real errnos across the pre_exec error pipe
refactor(sandbox): prebuild seccomp filters before fork
fix(sandbox): report Landlock best-effort failure from the parent
docs(sandbox): correct pre_exec SAFETY comments
fix(sandbox): carry real errnos across the pre_exec error pipe