Skip to content

feat(containment): run Linux containment on x86_64 - #40

Closed
mufaddalq wants to merge 8 commits into
strands-agents:mainfrom
mufaddalq:feat/x86-64-linux-containment
Closed

mufaddalq wants to merge 8 commits into
strands-agents:mainfrom
mufaddalq:feat/x86-64-linux-containment

Conversation

@mufaddalq

@mufaddalq mufaddalq commented Oct 9, 2026 •

Copy link
Copy Markdown

Status (2026-11-16): superseded on main by #398, which landed Linux x86-64 behind EXPERIMENTAL_X86_SUPPORT=TRUE (tracker: #45). This branch is not being rebased; see the latest comment for what it still has that main does not.

Description

Foundational-premise change. This changes why the box is safe on a new architecture, so it needs a maintainer's explicit call.

Linux containment refuses every architecture except aarch64 (crates/containment/src/facade.rs). Many Kubernetes and VM-sandbox fleets are x86_64, for example Kata on EC2 m7i. Lifting the gate alone is not enough. The permit filter is default-EPERM, and x86_64 programs (glibc, the dynamic loader, CPython) still call legacy syscall spellings that ARM64's generic table dropped. With only the gate removed, CPython fails at load (libpython3.12.so.1.0: cannot open).

This change lets x86_64 select the namespace launcher, and it adds an x86_64-only permit table, ARCH_PERMITTED, behind #[cfg(target_arch = "x86_64")].

Load-bearing decisions:

  1. The twin rule. An x86_64-only spelling is permitted only when its modern twin is already in the shared WORKLOAD_PERMITTED table and is not mediated, so no spelling reaches more than its twin does. Each entry carries ArchBasis::Twin("<twin>"), and a unit test enforces the rule. The set is complete under the rule, not bisected to an observed minimum, because an unlisted call answers EPERM and callers read that as a real failure. The table has 28 twinned spellings: the issue's 27, plus utime.
  2. arch_prctl is the one exception, permitted without argument scoping. glibc needs it for thread-local storage (ARCH_SET_FS) and, on newer releases, for shadow stacks. PyTorch and oneDNN need ARCH_REQ_XCOMP_PERM for AMX on Sapphire Rapids. Every subcommand affects only the calling process. None reaches a path, a socket, another process, a filter, or a namespace. Docker's default profile also permits it unrestricted. Scoping it to a subcommand list would break AMX and CET startup, and it would have to track new kernel subcommands.
  3. What stays closed. The restrictions filter is unchanged: x86_64 has no legacy spelling of a mediated call. modify_ldt, iopl, ioperm, and uselib are absent from the permit table. An x32 call (nr | 0x4000_0000, which shares AUDIT_ARCH_X86_64) matches no permit key and gets EPERM, and a test pins that no permit key carries the x32 bit. An i386 int 0x80 call fails seccompiler's arch check, which kills the process.
  4. aarch64 is unchanged. The new table is empty there, and the compiled filters are the same. The existing count of 114 permit keys still holds.

Observable changes. x86_64 Linux is now accepted. The refusal for any other Linux architecture now reads Linux containment supports ARM64 (aarch64) and x86_64, not {architecture}. There is no change to the strands-box public API, box.toml, the CLI, or any record or protocol version.

CI. containment-deterministic.yml gets an advisory ubuntu-latest leg, matching the advisory arm64 leg. That leg also runs a new kernel test, and the step fails if that test skips. Making Linux blocking stays the maintainers' call.

Out of scope: an x86_64 Linux release tarball (deploy-box-artifact.yml), and every Linux architecture other than aarch64 and x86_64.

Related Issues

Related: #45 (tracker; #21 was consolidated into it)
Related: #10, #18

Type of Change

New feature

Testing

The first commit message names the test for each claim.

  • Fork CI on real x86_64 and arm64 (run): every job green.
    • Rust / Unit Tests (ubuntu-latest, x86_64, blocking): 0 failures. The 7 new syscall.rs tests (twin rule, single exception, closed calls, mediated collisions, the x32 bit, the per-arch counts, and the merged duplicate check) and the 2 new facade.rs tests ran and passed.
    • x86_64_syscall_surface_linux (new), in the Deterministic ubuntu-latest leg: passed, with no skip. At the kernel, the box refuses modify_ldt, iopl, ioperm, uselib, and x32 open with EPERM, where an uncontained control run of the same probe does not. A legacy open(2) of a granted file succeeds.
    • The kernel test was also seen failing: a throwaway branch that permits iopl (run) fails it with 'iopl' was not refused inside the box, and fails the_x86_64_kernel_programming_calls_stay_closed. The leg is advisory, so this test does not gate a merge by itself; the unit tests in the blocking leg do.
    • Deterministic suite, x86_64 against arm64: the same 129 cases, 106 PASS and 23 SKIP on each, with no difference. Before this change, every x86_64 case errored at the harness's positive control.
  • macOS arm64: cargo test -p strands-box-containment -p strands-box --all-features, 0 failures.
  • Linux aarch64 (a privileged container, rust 1.98.1): strands-box-containment all pass. The aarch64 count is still 114.
  • cargo fmt --all -- --check is clean. cargo clippy --workspace --all-targets --all-features gives no warnings in the files this PR touches. The warnings it does give are on main already (chunks_exact_to_as_chunks in contain_trampoline/args.rs and namespace/view.rs, and several in crates/shell). I did not run it with -D warnings.
  • Not run: Kata on EC2 m7i, the issue's environment.

Checklist

  • I have read the CONTRIBUTING document
  • I have reviewed and understand every line of code in this PR, including any generated by AI tools, and I can explain why it works
  • My change is focused and reasonably small; I have split unrelated work into separate PRs
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • My changes generate no new warnings

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

🤖 Generated with Claude Code

muffadalq and others added 8 commits October 9, 2026 09:40
## Problem

Linux containment refused every architecture except aarch64 (strands-agents#21), so Box
could not run on x86_64 hosts such as Kata pods on EC2 m7i. Removing the gate
alone is not sufficient: x86_64 programs, the dynamic loader, and CPython still
call the legacy syscall spellings that the ARM64 table removed, and the permit
filter answers each of them with EPERM.

## Solution

- The facade selects the namespace launcher on aarch64 and x86_64. It refuses
  every other Linux architecture by name, and the refusal now names both.
- On x86_64 the permit filter also allows 28 legacy spellings. Each one is
  permitted only because its modern twin is already a shared permit, and no
  spelling reaches more than its twin does. arch_prctl is the one exception:
  glibc needs it at startup, and every subcommand changes only the calling
  process.
- The restrictions filter does not change: x86_64 has no legacy spelling of a
  mediated call. modify_ldt, iopl, ioperm, and uselib stay refused. An x32
  call gets EPERM from the default-deny permit filter, and an i386 call kills
  the process at the seccompiler arch check.
- On aarch64 the compiled filters do not change.
- CI gets an advisory ubuntu-latest containment leg, the same as the arm64 leg.

## Tests

- syscall.rs: the twin rule, the single exception, the closed x86_64 calls,
  number collisions, the x32 bit, and the counts per architecture.
- x86_64_syscall_surface_linux: at the kernel, the box refuses modify_ldt,
  iopl, ioperm, uselib, and x32 open with EPERM, where an uncontained control
  does not, and a legacy open(2) of a granted file succeeds.
- facade.rs: x86_64 selects the launcher, and riscv64 is refused by name.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@mufaddalq

Copy link
Copy Markdown
Author

Hi maintainers, could someone approve the pending workflow runs on this PR? As an outside contributor, CI and the PR-title check are at action_required, and Auto Strands Review is waiting on the manual-approval environment (run). Fork CI is green on my side (run), but I'd like the upstream checks and the review to run too. Thanks!

@mufaddalq

Copy link
Copy Markdown
Author

Status update, now that #21 has been folded into #45.

#398 (merged Nov 11) landed Linux x86-64 on main behind EXPERIMENTAL_X86_SUPPORT=TRUE, and #446 / #466 added the native test job and packaging. That covers the core of this PR, and this branch now conflicts with main in 11 files, so I am not going to rebase it as it stands. I have pointed the description at #45 instead of the closed #21.

What this branch still has that main does not, in case any of it is useful to #45:

  • A kernel-level refusal test (crates/containment/tests/x86_64_syscall_surface_linux.rs). Inside the box it calls modify_ldt, iopl, ioperm, uselib, and an x32-numbered open, and requires EPERM for each, against an uncontained control run of the same probe. I could not find an equivalent on main.
  • Legacy spellings main does not permit: creat, epoll_create, eventfd, fork, futimesat, getdents, inotify_init, pause, time, utime, utimes. These came from this PR's twin rule (permit a legacy spelling only when its modern twin is already permitted and unmediated), not from an observed workload. feat(box): add experimental Linux x86-64 support #398's observed set is the tighter choice; I list them only in case a workload trips on one.
  • arch_prctl: this PR permitted it unscoped, main permits only ARCH_SET_FS. main is tighter. The case I had in mind for the wider permit was ARCH_REQ_XCOMP_PERM (AMX on Sapphire Rapids, used by oneDNN / PyTorch); I have not tested that against main.

I am happy to close this, or to send the kernel-surface test as a small standalone PR against main if it is wanted.

@mufaddalq

Copy link
Copy Markdown
Author

Closing as superseded by #398 on main (tracker: #45). The notes above list what this branch had beyond it, in case any of it is useful.

@mufaddalq mufaddalq closed this Nov 19, 2026
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.

1 participant