Skip to content

fix(sandboxing): Bound advisory system bwrap startup probe#20111

Merged
viyatb-oai merged 3 commits intomainfrom
codex/viyatb/fix-bwrap-startup-probe-timeout
May 5, 2026
Merged

fix(sandboxing): Bound advisory system bwrap startup probe#20111
viyatb-oai merged 3 commits intomainfrom
codex/viyatb/fix-bwrap-startup-probe-timeout

Conversation

@viyatb-oai
Copy link
Copy Markdown
Collaborator

@viyatb-oai viyatb-oai commented Apr 29, 2026

Why

Linux startup runs an advisory system bwrap warning probe on each launch. On hosts with NFS or autofs mounts, its --ro-bind / / probe can take tens of seconds before Codex prints anything, matching #19828. Because this probe only decides whether to surface a warning, it should not be allowed to stall startup.

Relevant pre-change path: codex-rs/sandboxing/src/bwrap.rs

What changed

  • Bound the advisory system bwrap probe to 500 ms.
  • Preserve the existing warning behavior when bwrap promptly reports a known user-namespace failure.
  • Kill and reap the probe child on timeout, then suppress the advisory warning instead of blocking startup.
  • Read probe stderr with a bounded nonblocking drain so descendants that inherit the pipe cannot extend startup after the probe child exits.
  • Add regression coverage for both a deliberately slow fake bwrap process and a fake probe whose descendant keeps stderr open.

Security

This only bounds the advisory startup probe. It does not change the command execution path or add a fail-open sandbox fallback. The related command-side hang in #20017 remains separate from this PR.

Verification

  • Added system_bwrap_probe_times_out_without_reporting_a_warning.
  • Added system_bwrap_probe_does_not_wait_for_descendants_holding_stderr_open.
  • cargo test -p codex-sandboxing
  • cargo clippy -p codex-sandboxing --all-targets -- -D warnings

Fixes #19828
Related: #20017

Co-authored-by: Codex noreply@openai.com
@viyatb-oai viyatb-oai changed the title [codex] Bound system bwrap startup probe [codex] Bound advisory system bwrap startup probe Apr 29, 2026
Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7db3018aa7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/sandboxing/src/bwrap.rs Outdated
viyatb-oai added 2 commits May 4, 2026 13:43
Co-authored-by: Codex noreply@openai.com
Co-authored-by: Codex noreply@openai.com
@viyatb-oai viyatb-oai changed the title [codex] Bound advisory system bwrap startup probe fix(sandboxing): Bound advisory system bwrap startup probe May 5, 2026
Copy link
Copy Markdown
Contributor

@rreichel3-oai rreichel3-oai left a comment

Choose a reason for hiding this comment

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

Looks good, discussed offline to ensure that this wouldn't cause timeouts for /dev and /proc and other special FS mount points.

@viyatb-oai viyatb-oai merged commit ed6082c into main May 5, 2026
26 checks passed
@viyatb-oai viyatb-oai deleted the codex/viyatb/fix-bwrap-startup-probe-timeout branch May 5, 2026 17:45
@github-actions github-actions Bot locked and limited conversation to collaborators May 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

codex cli startup hangs 20-30s on Linux systems where bwrap bind-mounting / is slow (NFS, autofs)

2 participants