Repository navigation
feat: enforce native filesystem policy on Linux - #181
kevin-orellana merged 3 commits into
Conversation
## Problem Selected Linux workloads need filesystem policy checks over their direct system calls. Static filesystem grants alone cannot enforce the authored policy or its shared history. ## Solution Add the Linux notification adapter and task-bound kernel identity guard. The worker resolves paths under the captured workload root and acts on approved objects. The loader removes its capabilities before runtime threads start. Containment::apply gains the approved fourth optional native-registration socket argument. Existing callers pass None. Selection fields, policy actions, record versions, and the public broker protocol stay unchanged. Probe actual path-only descriptor transfer. Refuse unsupported path-only opens and report the limitation. Preserve ordinary symlinks, parent components, mutation suffix requirements, callback ordering, and the initial launch acknowledgment. ## Tests linux_native_paths covers path resolution, policy denial, path-only handles, and destructive suffix regressions. All 120 native integration cases passed. linux_native_failures and linux_native_entry_races passed 42 failure and identity-race cases. All 18 native kernel library tests passed. The complete workspace run exposed failures in box_library and the containment trampoline. Both were repaired. The final Box and containment suites passed 1,525 tests with six existing ignores; the callback executable also passed. All 48 trampoline tests passed. Independent review reran nine suffix controls, callback initialization with and without loader capabilities, and six launch-gate cases. The positive-kernel VM passed both probe/handler tests with path-only transfer enabled. This does not qualify a complete Box run on a stock supported-transfer kernel. macOS all-targets checks, formatting, workspace lint with repository allowances, and strict owned-crate lint passed. Performance, capacity, metadata/readlink expansion, signed macOS runtime qualification, and target release acceptance are not claimed.
|
Assessment: Comment A large but cohesive single-platform adapter. The enforcement core is carefully written and the authorization model is sound: validate-then-act with pinned objects, host/box identity reconciliation on every path, a BPF token keyed to the worker task's kernel identity to defeat replacement races, fail-safe watchdog/deadline handling, and Review Categories
Nicely engineered and well-tested work; the findings are documentation and tidiness only. |
|
The two-PR split continues in #186 (preparation) and #188 (native adapter). This PR's existing auto-merge setting fired when its base changed. A forward revert restored the preparation branch to its exact tested tree. |
|
Assessment: Approve Re-reviewed at What changed since the last review
No new concerns. Nicely done. |
Human readable section
Problem: Linux workloads can reach files through direct system calls without consulting the authored filesystem policy. The experimental selection already exists, but Linux has no production adapter behind it.
Solution: Add the Linux adapter for selected workloads. It checks opens, creation, deletion, renames, and truncation against the same policy and history as other Box operations. The worker acts on pinned objects. Kernel identity checks prevent deletion or renaming of a replacement object after authorization.
Trade-off: This implementation requires seccomp descriptor transfer and BPF security hooks. Qualification covers ARM64 Linux. Existing file descriptors retain their access. Linux permission changes remain governed by static write grants. Independent metadata queries and link-target reads remain deferred. Performance and capacity qualification are separate work.
Description
This PR depends on #186. Its preparation-branch base exists for review only. Merge #186 into
mainfirst, update this branch frommain, then retarget this PR tomain. Do not merge this PR into the preparation branch.The trusted loader uses CAP_BPF and CAP_PERFMON, then removes its capabilities before runtime threads and workloads start. The workload hands its notification listener and captured filesystem root to Box before execution. Unsupported setup stops launch.
Containment::applygains a fourth optional native-registration socket argument. Existing callers passNone. Workload selection, policy actions, record versions, and the public broker protocol stay unchanged.A runtime probe checks actual O_PATH descriptor transfer. Supported kernels can issue policy-authorized path-only handles that cannot read contents. Unsupported kernels refuse only path-only opens and print the limitation. Unexpected probe failures stop startup.
Ordinary symlinks and parent components resolve within the captured workload root. Authorization uses the resolved object. Mutation requests preserve trailing-slash requirements and refuse final dot components. Tests cover the destructive suffix defect found during review.
The library retains its readiness callback ordering, including callbacks that create the configuration. The trampoline retains parent acknowledgment before configuration loading, followed by native registration before execution.
Related Issues
Implements the Linux adapter tracked in #127. Target release acceptance and performance qualification remain separate.
Type of Change
New feature
Testing
Current head:
5c85b1307d1319e6884307f4453e454945bcf443. Every production and test file matches tested repair candidate36c0bdc610e8d399eb1d6a260d50c430c415e524. Independent review verified all 912 tracked entries. The merge changes only the CI branch filter and preserves preparation ancestry. Broad compatibility checks ran at4e4cca8fcf215b15c8d0167c000759bdcc22a593. The affected native checks were rerun after the shutdown repair.The positive O_PATH run uses an isolated Linux 6.18.56 test kernel with upstream O_PATH transfer support backported. The same boot records
PATH_HANDLES=trueand passes the policy/descriptor handler tests. This is kernel-transfer and handler coverage, not full Box qualification on a stock distribution with that capability.The complete workspace run exposed callback ordering and initial launch acknowledgment regressions. Both were repaired, and the affected Box and containment suites were rerun. Existing ignored tests remain ignored; no security test was removed or newly ignored.
Adversarial review also found that immediate workload exit could hide a fatal outcome-storage error. The new immediate-exit regression failed before repair. After repair, shutdown returns the original storage error, and the successful control still records its outcome. Independent replay confirmed three failure cases and one successful control.
The hosted review of
4e4cca8raised two comments. The README now documents all four containment arguments. The selection test now checks agreement between raw configuration and normalized records. Each phase keeps its own traversal because its input representation differs.Local review included destructive-path controls, readiness callbacks, startup deadlines, and shutdown error propagation. Hosted review assessed the authorization and identity paths. Formal human approval remains separate.
just check, orcargo test --workspace --all-features)cargo fmt --allandcargo clippy --workspace --all-targets --all-features -- -D warningsThe workspace lint command uses the existing justfile allowances:
clippy::too_many_arguments,clippy::only_used_in_recursion,clippy::await_holding_refcell_ref,clippy::explicit_auto_deref,clippy::chunks_exact_to_as_chunks,dead_code, andnon_snake_case. The changed owned crates also pass strict Clippy with--no-depsand without those allowances. An unrestricted strict run stopped on six existing Shell warnings; those files match the base revision.Checklist
The interface migration and baseline callback regression are in #186. This dependent diff keeps the complete platform adapter, its identity protections, and its tests together. Start with the Linux broker and identity guard, then review monitor lifecycle, containment setup, and tests.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.