Skip to content

fix(jaild): fail closed when the read-only remount fails (AB-003) - #304

Merged
hartsock merged 1 commit into
mainfrom
fix/ab-003-jaild-remount-fail-closed
Jul 28, 2026
Merged

fix(jaild): fail closed when the read-only remount fails (AB-003)#304
hartsock merged 1 commit into
mainfrom
fix/ab-003-jaild-remount-fail-closed

Conversation

@hartsock

Copy link
Copy Markdown
Member

Summary

Fixes #266 / AB-003. In run_jailed's async-signal-safe pre_exec closure, the read-only remount (MS_BIND|MS_REMOUNT|MS_RDONLY) discarded its return value — unlike every other syscall in the closure, which fails closed via the errno pipe. If that remount failed (EACCES/EPERM/EINVAL), the path was left read-write and the closure proceeded to pivot_root and exec: the jail's effective authority exceeded the caveat. Now the return code is captured and the closure return Errs on failure.

Test plan

  • New privileged regression ro_remount_failure_fails_closed (linux tier, #[ignore]d like the other jaild E2E proofs): a test-only fault seam (FAULT_RO_REMOUNT) forces the RO remount to fail, and asserts run_jailed then fails closed rather than exec'ing (baseline with no fault still runs). Reverting the return Err re-fails it.
  • clippy -D warnings clean, cargo fmt clean, the 14 non-ignored jaild tests pass; full pre-push gate [pre-push] OK.

Scope

Contained to linux.rs. Minimal fail-closed change matching the closure's established errno-pipe pattern. (The related "failed initial bind is skipped" nuance from the issue is benign for RO mounts — a bind that fails leaves the path absent, which is fail-safe; the writable-path breach is the remount, which this closes.)

Fixes #266

🤖 Generated with Claude Code

WHAT: In run_jailed's async-signal-safe pre_exec closure, the RO remount
(MS_BIND|MS_REMOUNT|MS_RDONLY) discarded its return value — unlike every other
syscall in the closure, which fails closed via the errno pipe. If the remount
failed (EACCES/EPERM/EINVAL), the path was left READ-WRITE and the closure
proceeded to pivot_root and exec: the jail's effective authority exceeded the
caveat. Capture the return code and `return Err` on failure.

WHY: #266 / AB-003 — a fail-open confinement breach (a would-be read-only path
stays writable). Regression: a test-only fault seam (FAULT_RO_REMOUNT) forces the
remount to fail; the privileged `ro_remount_failure_fails_closed` test (linux
tier, like the other jaild E2E proofs) asserts run_jailed then fails closed
rather than exec'ing. Reverting the `return Err` re-fails the test.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@hartsock hartsock added the risk:high High-risk change label Jul 28, 2026
@cursor

cursor Bot commented Jul 28, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@hartsock
hartsock merged commit ee9dca0 into main Jul 28, 2026
9 of 10 checks passed
@hartsock
hartsock deleted the fix/ab-003-jaild-remount-fail-closed branch July 28, 2026 04:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:high High-risk change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AB-003: jaild read-only remount failure is ignored — path stays writable

1 participant