Skip to content

feat(runtime,sosix): Darwin local_ipc_v1 owner + SOSIX Seatbelt activation leaf (C7) - #9020

Merged
ormastes merged 1 commit into
release/1.0.0from
work/darwin-local-ipc-sandbox-abi
Nov 14, 2026
Merged

ormastes merged 1 commit into
release/1.0.0from
work/darwin-local-ipc-sandbox-abi

Conversation

@ormastes

@ormastes ormastes commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

Work item C7 (Darwin substrate) of doc/05_design/simple_container_macos_seatbelt.md:
§2.3 (local_ipc_v1 Linux-only gap), §9.1 (sandbox_init / sandbox_free_error ABI), §11.4, §15.2, §20 P2.
Source only. Nothing here is qualified on a Mac, and no capability is advertised. The Darwin code fails closed.

1. Darwin implementation beneath local_ipc_v1

src/runtime/runtime_local_unix_v1.h, runtime_local_unix_transfer_v1.h, runtime_socket_nonblock.c

The public owned-handle, generation, role and close receipts are unchanged. This is not a mechanical copy of the Linux code (§15.2):

  • Origin: PID only. Darwin has no PID namespace, so a fork copy is still caught by the PID mismatch and quarantined.
  • Path: there is no /proc/self/fd anchoring. The code connects or binds to the validated absolute path, which must be at most 103 bytes. After the operation it re-walks the parent with the same no-follow policy and compares device/inode with the retained parent. This only detects a swapped parent after the fact, so it is weaker than Linux. Ancestors still must not be writable by other UIDs.
  • Descriptor flags: Darwin has no SOCK_CLOEXEC, accept4, MSG_CMSG_CLOEXEC or MSG_NOSIGNAL. CLOEXEC, O_NONBLOCK and SO_NOSIGPIPE are set right after socket creation, accept and SCM receipt. There is a race window, documented in the header: a concurrent fork+exec can still inherit the descriptor.
  • Peer identity: getpeereid uid/gid, cross-checked against the euid/egid in the LOCAL_PEERTOKEN audit token. The PID comes from the token and must match LOCAL_PEERPID. Any disagreement, or no kernel PID, fails closed (-3). XNU reports the peer socket's last operating process, so this is weaker than Linux's connect-time SO_PEERCRED. local_unix_peer_identity_class_v1() reports it as DarwinKernelObservedPeer, and neither class is an incarnation credential (§11.4).
  • SCM_RIGHTS: the receive/send code and the one-FD policy are shared with Linux. Stdout stage/adopt goes through the runtime_process.c pipe bridge, so it stays Linux-only and answers -4 on Darwin. Because Darwin never references the bridge symbols, the Darwin Rust seed link does not change.
  • Non-Apple, non-Linux hosts still answer -4.

2. SOSIX Seatbelt activation leaf (§9.1)

  • src/lib/nogc_async_mut/sosix/darwin_sandbox_v1.spl (the Simple twin): profile admission (non-empty, at most 256 KiB, no NUL), receipt decoding, and error sanitization (printable ASCII only, at most 512 bytes).
    • A missing or malformed receipt never decodes to Applied.
    • On non-Darwin hosts sosix_darwin_sandbox_apply_v1 returns Unsupported without entering native code.
  • src/runtime/runtime_sosix_darwin_sandbox_v1.h, included by runtime_process_owned.c:
    • The C side does only two calls: sandbox_init(profile, 0, &err) then sandbox_free_error.
    • The receipt is allocated before activation, so a successful activation can never be hidden by a later allocation failure.
    • A refusal is final, with no unrestricted fallback. Non-Apple hosts get -4.
  • Reviewer decision: the leaf is deliberately not an rt_* symbol (sosix_darwin_sandbox_apply_profile_v1, following the brief's naming). It has no portable meaning and no possible Rust-lane twin, so it sits outside check-rt-dual-implementation-ratchet.shs. If you would rather name it rt_sosix_darwin_*, that needs an owner-approved designed-C-only allowlist row.

Requirements touched

SC-MAC-004 (no workload after failed activation: no fallback; Refused/unknown is never Applied), SC-MAC-016 (reuses the canonical IPC owner, no second socket registry), SC-MAC-022 (no model-level success claimed as OS success), SC-MAC-023 (peer-identity limits published through a typed query).

Verification (Windows host)

  • clang -fsyntax-only with llvm-mingw clang 23.1.2 on runtime_socket_nonblock.c, runtime_process_owned.c and local_unix_v1_selfcheck.c: rc=0, and the same warning count as base (5 pre-existing -Wextra).
  • I also built stub sysroots in my scratchpad to type-check the __APPLE__ and __linux__ branches with -target arm64-apple-macos13 and -target x86_64-unknown-linux-gnu. The Linux branch has the same 0 warnings as base. These stub headers are not the real SDK. Real Darwin/Linux compilation is still owed.
  • bin/simple.exe test test/01_unit/lib/nogc_async_mut/sosix/darwin_sandbox_v1_spec.spl: 5/5 pass.
  • test/01_unit/lib/io/local_ipc_listener_v1_spec.spl: 4/4 pass (unchanged).
  • test/01_unit/lib/io/local_ipc_v1_spec.spl: 3/4 pass. The new peer-identity-class example passes. The stale generation example already failed on base with the same error: the Windows seed has no interpreter backing for rt_local_unix_* (unknown extern function: rt_local_unix_read_v1).
  • check-rt-dual-implementation-ratchet.shs --rev HEAD --baseline-rev origin/release/1.0.0: did not finish on this host (killed by a 20-minute timeout with no verdict; Windows git-bash is too slow for it). Manual substitute: the diff adds no non-static rt_* definition under src/runtime (grep of the added lines), so no new single-lane symbol is expected. The real gate is the CI fast-gates job.

Left for Mac qualification (P2 exit gate)

  • Build on macOS and run the __APPLE__ branch of src/runtime/test/local_unix_v1_selfcheck.c. It covers bytes, peer (uid/gid/pid), CLOEXEC/NONBLOCK/NOSIGPIPE, SCM rejection with no FD leak, shutdown, close/stale, symlinked ancestor, a sun_path that is too long, a writable parent, wrong UID, and listener 0666/unlink.
  • Confirm on a real host what XNU actually reports for LOCAL_PEERTOKEN / LOCAL_PEERPID, including after a socket handoff.
  • Same-UID developer admission (§11.4) is not added. The distinct-UID accept invariant is unchanged, so a separate-UID accept is NOT_RUN.
  • Seatbelt activation needs a disposable child probe: activate, then confirm a denied operation is refused and a malformed profile is Refused with sanitized text. Nothing here wires activation into a provider (C4 owns that).

🤖 Generated with Claude Code

@ormastes
ormastes temporarily deployed to self-review-admission November 13, 2026 14:10 — with GitHub Actions Inactive
@ormastes ormastes added the ci:full Run the full (non-required) CI matrix on this PR label Nov 13, 2026
@ormastes
ormastes force-pushed the work/darwin-local-ipc-sandbox-abi branch from f15b875 to 3c6255b Compare November 13, 2026 17:26
@ormastes
ormastes temporarily deployed to self-review-admission November 13, 2026 17:26 — with GitHub Actions Inactive
@ormastes ormastes added ci:full Run the full (non-required) CI matrix on this PR and removed ci:full Run the full (non-required) CI matrix on this PR labels Nov 13, 2026
@ormastes
ormastes force-pushed the work/darwin-local-ipc-sandbox-abi branch from 3c6255b to 567896d Compare November 13, 2026 18:46
@ormastes
ormastes temporarily deployed to self-review-admission November 13, 2026 18:46 — with GitHub Actions Inactive
@ormastes ormastes added ci:full Run the full (non-required) CI matrix on this PR and removed ci:full Run the full (non-required) CI matrix on this PR labels Nov 13, 2026
…ivation leaf

Design doc/05_design/simple_container_macos_seatbelt.md §2.3, §9.1, §11.4,
§15.2, §20 P2 (work item C7). Source only; nothing is qualified on a Mac.

- runtime_local_unix_v1.h/_transfer_v1.h: Darwin implementation beneath
  local_ipc_v1 with the same token/generation/role/close receipts. Not a
  mechanical Linux port: PID-only origin (no PID namespace), validated absolute
  sun_path plus post-effect parent re-walk instead of /proc/self/fd anchoring,
  descriptor flags + SO_NOSIGPIPE applied after socket/accept/SCM receipt,
  peer = getpeereid cross-checked against LOCAL_PEERTOKEN and LOCAL_PEERPID
  (fail closed on disagreement or missing kernel PID). stdout stage/adopt stays
  Linux-only (unsupported on Darwin; no bridge symbol reference, so the Darwin
  seed link is unchanged). Non-Apple non-Linux hosts still answer -4.
- local_ipc_v1.spl: local_unix_peer_identity_class_v1() reports the weaker
  Darwin class honestly; never an incarnation credential.
- SOSIX Seatbelt leaf: sosix_darwin_sandbox_apply_v1 (Simple admission,
  receipt decode, error sanitization) over a narrow C call pair
  sandbox_init(profile,0,&err)+sandbox_free_error with a preallocated receipt;
  no unrestricted fallback; Unsupported on non-Darwin without native entry.
- Darwin branch of local_unix_v1_selfcheck.c for later Mac qualification.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ormastes
ormastes force-pushed the work/darwin-local-ipc-sandbox-abi branch from 567896d to fe5741d Compare November 14, 2026 00:29
@ormastes
ormastes temporarily deployed to self-review-admission November 14, 2026 00:29 — with GitHub Actions Inactive

@ormastes ormastes left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Reviewed (Opus): macOS Native job failures are runner memory (3579 MiB < 3584 MiB reserve) and missing system LLVM, also red on main 42899640547 and unrelated PRs; no local_ipc/sandbox code involved. Diff scoped to its 12 files, merge-tree clean vs release/1.0.0, no nil, Option-decoded extern, non-Apple hosts return Unsupported/ReceiptUnavailable (fail closed), Linux IPC refactor behaviour-preserving. Owed Mac evidence (selfcheck run, child-process activation) stays tracked, not claimed. Non-rt_ leaf name: owner decision pending.

@ormastes
ormastes merged commit 017b944 into release/1.0.0 Nov 14, 2026
13 checks passed
@ormastes
ormastes deleted the work/darwin-local-ipc-sandbox-abi branch November 14, 2026 00:32

This branch was previously deployed

1 inactive deployment
self-review-admission — fe5741de Deployed Nov 14, 2026 by ormastes via Invalidate changed PR self-review state #36036
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:full Run the full (non-required) CI matrix on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant