Skip to content

fix(sandbox): harden managed-children registry and workload launcher - #5209

Open
EmilienM wants to merge 1 commit into
ai-openshell:mainfrom
EmilienM:fix/5186-managed-children-launcher/EmilienM
Open

EmilienM wants to merge 1 commit into
ai-openshell:mainfrom
EmilienM:fix/5186-managed-children-launcher/EmilienM

Conversation

@EmilienM

@EmilienM EmilienM commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Three silent-failure paths in the sandbox, all found by reading the code: a managed-children registration leaks after a poisoned registry lock, the orphan reaper goes inert on kernels without CONFIG_PROC_CHILDREN because every missing children file reads as a vanished task, and a panicking job kills the workload launcher thread while is_alive() keeps reporting healthy.

Related Issue

Closes #5186

Changes

  • managed_children::unregister recovers from a poisoned registry lock like its sibling accessors, so a registration can no longer leak after a waiter panics while holding the lock
  • direct_child_pids classifies a missing children file per task (vanished task vs missing support), only concludes missing support when no task in the scan listed one, and reports it once per process with a warning and an OCSF detection finding. A scan skips a task directory it cannot read instead of aborting the pass, and three consecutive failing or skipping scans warn once
  • The workload launcher runs each job under catch_unwind, like the network broker's handler panics: the panicking job's caller gets a precise error, the panic is logged, the thread leaves its job loop, and is_alive() turns false so later spawns fail fast. The dead launcher also emits an OCSF detection finding, since no new workload process can start afterwards
  • Overlaps perf(sandbox): cut broker round trips on the mediated socket path #5233 in managed_children.rs and workload_launcher.rs; this PR should merge first and perf(sandbox): cut broker round trips on the mediated socket path #5233 rebases (the reaper restructure there composes with the scan-skip handling here)

Release Notes

When no task under /proc/self/task exposes a children file (kernel built without CONFIG_PROC_CHILDREN, or restricted procfs), the sandbox now reports the inert orphan reaper once instead of failing silently, and a reaper whose scans keep failing or skipping now warns instead of only logging at debug level. A panicking workload-launcher job now stops the launcher with a clear error and a detection finding instead of leaving it reporting healthy.

Testing

  • Checks appropriate to the affected code and behavior pass

  • Unit tests added/updated (if applicable)

  • E2E tests added/updated (if applicable)

  • cargo test -p openshell-sandbox --lib: 316 passed, including regression tests for each path (poisoned-lock unregister, children-file classification and reporting, scan-skip escalation, warn-once failure runs, panicking launcher job with its OCSF finding; the suite also passes with RUST_BACKTRACE=1)

  • cargo clippy -p openshell-sandbox --all-targets, and cargo fmt --all -- --check pass

  • No local e2e run: this host has no docker daemon and the k8s lane needs a full image build. The changed paths are failure paths not reachable on healthy kernels, and the launcher's normal spawn path is covered by tests that spawn real children through the filtered thread. CI lanes cover the rest.

  • uv-based checks (python format, license headers) skipped locally due to a host uv config break (2026-11-03 RPM update); this diff touches no manifests or Python files

Checklist

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

@copy-pr-bot

copy-pr-bot Bot commented Nov 3, 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.

@FrostGod

FrostGod commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

/ok to test 40e6725

@EmilienM
EmilienM force-pushed the fix/5186-managed-children-launcher/EmilienM branch from 40e6725 to e74a054 Compare November 4, 2026 03:26
@mrunalp mrunalp added retired:area:sandbox Retired; do not apply. See #5151 for item-specific migration to the current taxonomy. test:e2e Requires end-to-end coverage labels Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

Label test:e2e applied, but pull-request/5209 is at 40e6725 while the PR head is e74a054. A maintainer needs to comment /ok to test e74a054bd314efece879addcef9e75cec6bff522 to refresh the mirror. Once the mirror catches up, re-run Branch E2E Checks from the Actions tab.

@mrunalp

mrunalp commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

/ok to test e74a054

@EmilienM
EmilienM force-pushed the fix/5186-managed-children-launcher/EmilienM branch from e74a054 to 6c769e8 Compare November 9, 2026 21:16
@purp purp added area:runtime Sandbox execution, isolation, supervision, policy enforcement, networking, and provider lifecycle. topic:observability Logs, metrics, traces, telemetry, dashboards, event correlation, and operational data export. topic:reliability High availability, recovery, retries, graceful degradation, and correctness across restarts. and removed retired:area:sandbox Retired; do not apply. See #5151 for item-specific migration to the current taxonomy. labels Nov 15, 2026

@FrostGod FrostGod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, small and well tested. A few comments inline, plus:

  • workload_launcher.rs L53–57 (nit): "dropped the spawn result" hides that the job panicked. Can the error say so?
  • Jobs are just cmd.spawn() (process.rs:445–456), so is the panic containment purely defensive?
  • This overlaps #5233 in managed_children.rs. Let's agree which merges first.

@EmilienM
EmilienM force-pushed the fix/5186-managed-children-launcher/EmilienM branch from 6c769e8 to 8dd36f9 Compare November 23, 2026 14:28
@EmilienM

Copy link
Copy Markdown
Contributor Author

All addressed in 8dd36f9.

  • The panicked job's caller now gets a precise "job panicked before returning a result" error, sent by a Drop guard while unwinding, instead of the ambiguous "dropped the spawn result".
  • Yes, the containment is purely defensive today: the only jobs are cmd.spawn() closures, which don't panic in practice. It guards the public execute() API (arbitrary FnOnce) and mirrors the network broker's handler containment, so a future job type that can panic fails closed instead of hanging callers.
  • perf(sandbox): cut broker round trips on the mediated socket path #5233 overlap: I'd merge this one first, it's the smaller change and already reviewed. Your reaper restructure there (candidate snapshot + per-candidate guard) rebases cleanly on top and composes with the skip handling here.

@FrostGod

Copy link
Copy Markdown
Contributor

/ok to test 8dd36f9

@FrostGod
FrostGod enabled auto-merge November 24, 2026 09:11
@FrostGod

Copy link
Copy Markdown
Contributor

@EmilienM thanks, the review fixes look good. Could you rebase onto main? The E2E suite bundles job fails with unexpected argument 'build': the E2E workflow on main calls openshell-test-runner build, but the runner built from this branch's base (9e004a7) predates that subcommand (#5755, #5789, #5865 changed it since). The PR code isn't the cause.

Recover the managed-children registry from a poisoned lock in unregister,
like its sibling accessors already do, so a PID whose waiter panicked
while holding the lock cannot stay registered forever and be skipped by
the orphan reaper after the PID is reused.

Classify a missing /proc/self/task/<tid>/children file instead of
treating every NotFound as a vanished task. When no task in a scan
exposes the file (kernel built without CONFIG_PROC_CHILDREN, or
restricted procfs), log a warning and emit an OCSF detection finding
once per process instead of silently leaving the orphan reaper inert
while zombies accumulate. A scan now skips a task directory it cannot
read instead of aborting the whole pass, and a run of scans that keeps
failing or skipping warns once instead of only logging at debug level.

Contain a panicking job on the workload launcher thread, the way the
network broker contains handler panics: the panicking job's caller gets
a precise error saying the job panicked, the panic is reported, the
thread leaves its job loop, and the health flag turns false so every
later spawn fails fast instead of hanging on a launcher that still
reports healthy. A dead launcher also emits an OCSF detection finding,
since no new workload process can start in the sandbox afterwards.

Closes ai-openshell#5186

Signed-off-by: Emilien Macchi <emacchi@redhat.com>
auto-merge was automatically disabled November 24, 2026 13:47

Head branch was pushed to by a user without write access

@EmilienM
EmilienM force-pushed the fix/5186-managed-children-launcher/EmilienM branch from 8dd36f9 to 4c9143d Compare November 24, 2026 13:47

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:runtime Sandbox execution, isolation, supervision, policy enforcement, networking, and provider lifecycle. test:e2e Requires end-to-end coverage topic:observability Logs, metrics, traces, telemetry, dashboards, event correlation, and operational data export. topic:reliability High availability, recovery, retries, graceful degradation, and correctness across restarts.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: managed_children and the workload launcher mishandle a poisoned lock, a missing CONFIG_PROC_CHILDREN and a panicking job

4 participants