Skip to content

Fix/native i386 sandbox - #6

Merged
1ay1 merged 2 commits into
agentty-org:masterfrom
lukerb52:fix/native-i386-sandbox
Nov 16, 2026
Merged

1ay1 merged 2 commits into
agentty-org:masterfrom
lukerb52:fix/native-i386-sandbox

Conversation

@lukerb52

@lukerb52 lukerb52 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Add architecture-specific i386 seccomp support on x86-64 Linux

Summary

Add explicit support for filtering both native x86-64 and compatibility i386 syscalls within one Claybin sandbox, without disabling seccomp or applying native syscall numbers to the compatibility ABI.

This enables a companion Agentty change to run ordinary dynamically linked gcc -m32 executables while retaining filesystem isolation and syscall restrictions.

Problem

Claybin's existing seccomp architecture guard accepts only the configured native architecture. On x86-64 Linux, an i386 process encounters SECCOMP_RET_KILL_PROCESS before reaching the syscall rules, producing SIGSYS.

Simply accepting AUDIT_ARCH_I386 in that guard would be unsafe: x86-64 and i386 assign different operations to the same syscall numbers.

Changes

  • Add an optional, independent i386 SyscallPolicy and policy-builder API.
  • Dispatch seccomp filtering by audit architecture:
    • AUDIT_ARCH_X86_64 uses the native policy.
    • AUDIT_ARCH_I386 uses the explicitly supplied compatibility policy.
    • Other architectures remain rejected.
  • Keep i386 disabled when no compatibility policy is supplied.
  • Preserve fail-closed policy composition: both operands must opt into compatibility execution.
  • Add kernel-numbered i386 profiles covering runtime, filesystem, process, and direct socket operations.
  • Apply W^X argument checks to i386 mmap2, mprotect, and pkey_mprotect.
  • Report enabled filter ABIs and avoid claiming strong filtering when an enabled ABI has an unrestricted policy.
  • Preserve upstream's tracer-cancelled syscall exception (nr == -1) after architecture validation.

Security considerations

  • Reject tagged x32 syscalls and historical untagged x32 numbers 512–547.
  • Deny pointer-based legacy mmap, whose protection flags cannot be inspected safely by seccomp.
  • Deny legacy socketcall rather than allowing its pointer arguments to bypass socket-family checks.
  • Reject i386 notification policies until broker decoding is architecture-aware.
  • Preserve native filtering and existing sandbox enforcement. No unrestricted compatibility policy is enabled by default.

Testing

The following focused suites pass after rebasing onto 19a6c27:

  • bpf_emit_test
  • plan_test
  • syscall_table_test
  • lattice_laws_test
  • policy_typestate_test
  • compile_fuzz_test

Coverage includes architecture dispatch, syscall-number collisions, unknown architectures, x32 rejection, protection arguments, compatibility-policy composition, broker rejection, and tracer cancellation for both supported ABIs. The i386 table is checked against host kernel syscall definitions.

Before this rebase, the companion Agentty integration also passed real-host sandbox tests for:

  • Native and default-interpreter i386 execution, returning 42.
  • i386 shared-library loading.
  • Blocked external filesystem writes.
  • Blocked RWX mappings and protection changes.
  • Hard-denied syscalls for both ABIs.

Related work

The companion Agentty PR supplies the filesystem-mapping changes needed to preserve merged-/usr loader resolution and selects this compatibility policy. Those Agentty-specific changes are outside this PR.

@lukerb52
lukerb52 marked this pull request as ready for review November 16, 2026 02:54
@1ay1
1ay1 merged commit 7388f1d into agentty-org:master Nov 16, 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.

2 participants