Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1defff6
feat(sandboxpolicy): pending-slot bindings and EPERM for Strict track…
matthyx Nov 24, 2026
d3587f9
Merge origin/main into omx/nri-s1-pending-slot
matthyx Dec 3, 2026
29704a3
fix(sandboxpolicy): rotate the privilege and file section image pins
matthyx Dec 3, 2026
e30b1eb
fix(enforcement): arm on a SkipArming hand-over; refuse a Strict pend…
matthyx Dec 3, 2026
8b60684
test(enforce_privilege): enter the cgroup after unsharing, as runc ex…
matthyx Dec 3, 2026
d96378d
feat(sandboxpolicy): Plan.GateStrict carries a section's Strict pendi…
matthyx Dec 3, 2026
a0ca2db
fix(enforcement): a held-ring Bind records the new binding as active
matthyx Dec 4, 2026
a952048
test(enforce_file): fail TestForkMarkFaultErrno in CI without its helper
matthyx Dec 4, 2026
c6e618d
fix(enforcement): a Strict pending binding with unrecorded credential…
matthyx Dec 4, 2026
609b68d
fix(enforcement): retry a failed write of a binding's unchecked entry
matthyx Dec 4, 2026
19e6bc8
fix(enforcement): a rollback after unrecorded credentials leaves the …
matthyx Dec 4, 2026
95434db
fix(enforcement): no bind fast path or reload while an unchecked writ…
matthyx Dec 4, 2026
4fb6a2f
fix(enforcement): never trust an adopted Strict pending entry's ring …
matthyx Dec 4, 2026
4f5bde7
fix(enforcement): a start move refused by a held ring keeps the pendi…
matthyx Dec 4, 2026
031cc89
fix(enforcement): keep the deferred-move record consistent with Free …
matthyx Dec 4, 2026
e3fa03a
feat(enforcement): per-cgroup ring-check query for pending marks
matthyx Dec 4, 2026
cda2148
fix(enforcement): a check-only walk confirms an unconfirmed SkipArmin…
matthyx Dec 4, 2026
8b1258e
fix(enforcement): an adopted Strict entry without a passed check is u…
matthyx Dec 4, 2026
dc21ea9
fix(enforcement): class rewrites keep the ring-check marker; no reloa…
matthyx Dec 4, 2026
95069da
fix(enforcement): a move from a Strict pending entry checks before it…
matthyx Dec 4, 2026
3a8d720
fix(enforcement): a SkipArming move off a Strict pending entry also c…
matthyx Dec 4, 2026
7f9d771
fix(enforcement): a refused startup move keeps the wanted binding's S…
matthyx Dec 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/features/sandbox-policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,14 @@ reports `ProtectionUnconfirmed`, also when the cause is an unreadable counter.
The privilege instance is not ready while its credential record (the
overridden credentials it judges, see the gadget README) is at least 90%
full: a Strict binding would soon be refused new credentials.
A Strict binding refuses an operation it cannot track (a fork whose child
mark fails, an exec whose mark cannot be prepared, or credentials the record
cannot hold) with `EPERM`, as every Strict deny; an Audit binding allows it
and counts it. A refused credential preparation is the one exception user
space sees: the kernel's `prepare_creds()` and `cred_alloc_blank()` turn the
hook's refusal into a NULL credential, so the syscall (including a fork)
fails with `ENOMEM`; an io_uring request under a personality still fails with
`EPERM`.
A new Strict binding (privilege or file section) whose container holds io_uring
rings opened before it is refused: the policy reports `NotReady` with reason
`IoUringHeld`, and the refresh binds it once the rings are closed (an io_uring
Expand Down
4 changes: 2 additions & 2 deletions pkg/ebpf/gadgets/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ and keeps its path rules in an array that `policy.h` does not describe.

| File | Content |
|---|---|
| `bindings.h` | `<section>bindings` map (version 1, gadget annotation `sandbox-bindings-version`, which the controller checks at instance start): cgroup id → the container's policy slot and flags. Exact scope by default; `BINDING_SUBTREE` covers descendant cgroups, `BINDING_STRICT` carries the slot's class (a fault denies), `BINDING_RUNTIME_HELPERS` admits the arming exemption |
| `bindings.h` | `<section>bindings` map (version 1, gadget annotation `sandbox-bindings-version`, which the controller checks at instance start): cgroup id → the container's policy slot and flags. Exact scope by default; `BINDING_SUBTREE` covers descendant cgroups, `BINDING_STRICT` carries the slot's class (a fault denies), `BINDING_RUNTIME_HELPERS` admits the arming exemption. `enforcement.PendingSlot` (0xFFFFFFFF) is a slot that is never published: the program finds no policy there, so for a judged task a Strict pending binding fails closed (a structural fault, EPERM) and an Audit one allows; both count only in the node-wide section error counter, with no per-slot counter (`SlotFaults`/`Counters(PendingSlot)` return an error); its class is the binding's own (`Binding.Strict`, refused on a real slot), and a class flip of a real slot never rewrites it |
| `policy.h` | policy modes (0 off, 1 audit, 2 enforce), rank resolution (explicit deny > allow > default, one mode per rule), shared policy value |
| `verdict.h` | first verdict fields (`generation`, `cgroup`, `deny`, `mode`), per-CPU `counters` (denied, submitted, dropped, allowed, section error, rate limited), 100 reports per CPU per second |
| `root_barrier.h` | root barrier: always deny chroot, pivot_root, new user namespaces, new or joined mount namespaces and mount-tree changes for the tasks a gadget-defined predicate covers |
Expand All @@ -27,7 +27,7 @@ and keeps its path rules in an array that `policy.h` does not describe.
| `pin.h` | the section's state maps are pinned by name with its prefix (`SANDBOX_SECTION`, for example `sbx1_priv_`): a new load of the gadget re-opens them, so a restart keeps bindings, slot state, policy, task marks and fault counts. `enforcement.RemovePinnedMaps` starts from empty state |
| `merge/` | the merge contract for several policies on one container, and its shared test vectors |
| `rootbarrier/` | Go: attestation (each barrier program has a live LSM link, BPF LSM is active) and a self-test, for the Ready step of a gadget that includes `root_barrier.h` |
| `enforcement/` | Go: the binding controller of one long-lived node-wide instance: live `Bind`/`Unbind` of a container to a slot; `Publish` of a slot's policy into its inactive buffer and one flip write (a failed publish keeps the last-good policy); `Free` and a quarantine (default 2 s) before a buffer is deleted or a slot reused; `Heal`/`HealNode` arm the bound tasks again without a reload; readiness, `SlotFaults`, `ArmingWitness` (a counter below its base or unreadable is an error, never zero); `Counters`/`NodeCounters` read the raw pinned counters, and `RateWindow`/`FailRate` (failrate.go) apply the reporting rule: Degraded on any failure within 60 s, NotReady above 0.1 % over 5 min, unknown when a counter is unreadable or moved backwards. A section instance with a test-only switch set is refused unless `FaultInjection` admits it. A frozen mode (policy written and frozen before any binding) stays for sections not moved yet |
| `enforcement/` | Go: the binding controller of one long-lived node-wide instance: live `Bind`/`Unbind` of a container to a slot; `Rebind` hands a bound cgroup to another identity with one map write; `Publish` of a slot's policy into its inactive buffer and one flip write (a failed publish keeps the last-good policy); `Free` and a quarantine (default 2 s) before a buffer is deleted or a slot reused; `Heal`/`HealNode` arm the bound tasks again without a reload; readiness, `SlotFaults`, `ArmingWitness` (a counter below its base or unreadable is an error, never zero); `Counters`/`NodeCounters` read the raw pinned counters, and `RateWindow`/`FailRate` (failrate.go) apply the reporting rule: Degraded on any failure within 60 s, NotReady above 0.1 % over 5 min, unknown when a counter is unreadable or moved backwards. A section instance with a test-only switch set is refused unless `FaultInjection` admits it. A frozen mode (policy written and frozen before any binding) stays for sections not moved yet |

Section-specific parts (the policy key layout, hooks, compiler) stay in each
gadget.
Expand Down
2 changes: 1 addition & 1 deletion pkg/ebpf/gadgets/common/arming.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ static __always_inline bool arming_exec_needs_prepare(void)
// arming_prepare_exec runs in bprm_check_security, where the exec can still
// fail: it creates the task's mark storage (unarmed) when the exec may need a
// mark. It returns false when the storage could not be allocated; the
// caller then refuses the exec under a Strict binding (-ENOMEM), so a
// caller then refuses the exec under a Strict binding (-EPERM), so a
// committed exec never needs an allocation.
static __always_inline bool arming_prepare_exec(__u32 binding_flags)
{
Expand Down
Loading