Repository navigation
Conversation
…ing faults Add the enforcement-library groundwork for the NRI start gate: a binding can point at PendingSlot, a slot that is never published. The file, network and privilege programs already treat an unpublished slot as a structural fault, so a pending pod mark denies a Strict task (EPERM) and lets an Audit one run, counted in the node-wide section error counter. No BPF map or layout changes, and nothing writes a pending binding yet. - Binding.Strict and PendingSlot. classOf takes the class of a pending binding from the binding and of a real slot from the slot only, so an in-place Strict to Audit flip never keeps BINDING_STRICT. validate refuses Strict on a real slot. - Rebind swaps the identity of a cgroup's binding in one map write. - HealNode, Kept, rewriteClass, the adoption reconcile and slotGate handle pending entries. Per-slot counters of a pending slot return an error, never zero. - Strict tracking faults in the file and privilege programs return EPERM instead of ENOMEM. A refused credential preparation still surfaces as ENOMEM: the kernel's prepare_creds() and cred_alloc_blank() turn the hook's refusal into NULL. Tested with unit tests (including the class-flip test) and kernel tests for pending marks in all three sections, the move to a real slot, a replacement on a full bindings map, a subtree mark, and the fork, exec and credential errnos. The privilege, file and network kernel suites pass on AL2023 6.18.56 and Debian 13 6.12.117 in local VMs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Performance Benchmark ResultsNode-Agent Resource Usage
Dedup EffectivenessNo data available. |
|
I read the change against the sections I own (file, privilege, network, root barrier) and the restart code. The kernel side looks right to me. A pending slot has no The EPERM change does not change what is denied, only the errno. The cred-record burst case still reaches user space as ENOMEM through
I found nothing blocking for this slice, because nothing writes a pending binding yet. My main points are for the NRI writer slice. The restart layer in FindingsBlockingNone. Should fix
Minor
Interaction with my open work
|
|
One more finding that I think belongs with this work. I hit it on plain main (node-agent What happens. A container whose first process forks before the binding is live (inside the first second) is never bound:
A first process that does not fork until the binding is live binds normally. Repro. Pods with Two parts, I think: the early fork itself (which the pending-slot binding and the NRI gate should cover), and the slots that refused routes keep. Do you want to handle both here, or should I open a separate issue for the slot leak? |
|
Thanks, Alon. These are useful.
|
Brings the pending-slot slice up to main 39414b7 (IG pin c5f01340ba4c), which includes the exec restart fence work. No conflicts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
This slice returns EPERM instead of ENOMEM for a Strict tracking fault in the privilege and file gadgets, so their manifests changed. Rebuilt with IG v0.57.0, SOURCE_DATE_EPOCH=0 and the section Makefiles' build line; a build of main 39414b7 with the same setup reproduces main's six pins. Network is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
Performance Benchmark ResultsNode-Agent Resource Usage
Dedup EffectivenessNo data available. |
There was a problem hiding this comment.
🟡 Changes recommended
Two critical enforcement gaps remain: same-value rebinds can leave tasks exempt from Strict enforcement, and Strict initial bindings can report successful activation despite failed root-barrier attestation.
2 open issues
What changed in this PR
Adds pending sandbox bindings as groundwork for the future NRI start gate, without introducing a pending-binding writer.
Changes:
- Adds pending-binding classes, identity handover, and lifecycle handling.
- Changes Strict tracking-fault returns to EPERM while documenting kernel-generated ENOMEM exceptions.
- Adds unit and kernel coverage and updates gadget image pins.
| File | Description |
|---|---|
| pkg/sandboxpolicy/igbackend/slotgate_test.go | Tests binding-aware slot gating. |
| pkg/sandboxpolicy/igbackend/section_images.go | Updates file and privilege image pins. |
| pkg/sandboxpolicy/igbackend/privilege_native.go | Passes binding class to the gate. |
| pkg/sandboxpolicy/igbackend/file_native.go | Gates file bindings by class. |
| pkg/ebpf/gadgets/enforce_privilege/runtime/runtime_kernel_test.go | Updates errno assertions. |
| pkg/ebpf/gadgets/enforce_privilege/runtime/pending_kernel_test.go | Tests pending privilege bindings. |
| pkg/ebpf/gadgets/enforce_privilege/runtime/exec_coexist_kernel_test.go | Checks refusal counters and attach orders. |
| pkg/ebpf/gadgets/enforce_privilege/README.md | Documents tracking-fault errnos. |
| pkg/ebpf/gadgets/enforce_privilege/program.bpf.c | Returns EPERM for tracking faults. |
| pkg/ebpf/gadgets/enforce_network/runtime/pending_kernel_test.go | Tests pending bindings and full-map replacement. |
| pkg/ebpf/gadgets/enforce_file/runtime/runtime.go | Makes slot bounds checking unsigned-safe. |
| pkg/ebpf/gadgets/enforce_file/runtime/runtime_kernel_test.go | Asserts EPERM on exec-mark failure. |
| pkg/ebpf/gadgets/enforce_file/runtime/pending_kernel_test.go | Tests pending bindings, subtrees, and errnos. |
| pkg/ebpf/gadgets/enforce_file/README.md | Documents EPERM for mark failures. |
| pkg/ebpf/gadgets/enforce_file/program.bpf.c | Returns EPERM for tracking faults. |
| pkg/ebpf/gadgets/common/README.md | Documents pending bindings and handover. |
| pkg/ebpf/gadgets/common/enforcement/slots.go | Handles pending entries during healing and adoption. |
| pkg/ebpf/gadgets/common/enforcement/pending_test.go | Tests pending classes, transitions, and handover. |
| pkg/ebpf/gadgets/common/enforcement/creds_linux.go | Clarifies credential-failure errno comments. |
| pkg/ebpf/gadgets/common/enforcement/counters.go | Rejects pending-slot counter reads. |
| pkg/ebpf/gadgets/common/enforcement/bindings.go | Adds PendingSlot, binding classes, and Rebind. |
| pkg/ebpf/gadgets/common/arming.h | Updates the exec-refusal errno comment. |
| docs/features/sandbox-policy.md | Explains tracking-fault errno behavior. |
Review effort: Balanced
…ing start on a failed barrier - Bindings.bind: a same-value bind that goes from SkipArming to an arming binding no longer takes the fast path, so its tasks are armed and checked for io_uring rings; a ring found on that hand-over marks the new binding unconfirmed (the SkipArming previous one is not checkable). - enforce_file instance.Ready: a failed root-barrier attestation refuses activation for a Strict PendingSlot initial binding too. Addresses Copilot review on #1160 (r4790452518, r4790452606). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
…ec does IG's root barrier (inspektor-gadget 42f1d9b6, in the pinned c5f01340) covers tasks in a cgroup with an active Strict exec route and refuses unshare(CLONE_NEWNS) and CLONE_NEWNS clones there, counted in root_barrier_counters. The unarmed-exec fixture cloned straight into the bound cgroup and unshared there, so it never reached execve and no gadget counted the refusal. - cloneHelper "enter" unshares the mount namespace in the host cgroup, moves itself into the bound cgroup and execs; the unarmed-exec round uses it. Both attach orders still require the refusing gadget to count the refusal; a moved OpUnshareNS counter or a setup failure is a fixture error. - A new round pins the barrier: the old start fails with EPERM, counted in OpUnshareNS, with no privilege or enforce_exec exec counter moving. - TestTaskAllocWithSharedExec: under an exec Enforce route the barrier refuses the CLONE_NEWNS clone (EPERM, OpCloneNS, no TASK); a barrier denial must park one birth fewer than the plain round. VM: privilege-exec-refusal 16/16 on al2023-k618, al2023-k612, debian13. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
…ng class An Audit policy with an enforce rule or default override is Strict for the start gate (S4), but the backend derived a pod mark's pending class only from the policy mode. GateStrict names the sections whose pending class is Strict; it is excluded from JSON, the revision and the combination keys, and policy slots keep the policy mode. Callers follow in S2 (backend), S4 (PodPlansAt) and S3 (gate plans). For Copilot review on #1165 (r4792384813). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
Performance Benchmark ResultsNode-Agent Resource Usage
Dedup EffectivenessNo data available. |
A direct Bind that turned a same-value Strict binding from SkipArming to armed and then found a held io_uring ring returned success but kept the old SkipArming binding in active, so every later heal returned ErrNotHealable even after the ring closed. Record the new binding before returning; it stays unconfirmed until a later walk finds no ring. Addresses Copilot review on #1160 (comment 4792446677). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
…nd) into omx/nri-s2-pending-owner Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd) into omx/nri-s4-classify Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nconfirmed adopt() left ringUnconfirmed empty for an adopted Strict entry without bindingRingChecked (for example after an interrupted Audit->Strict rewrite), so CgroupRingUnconfirmed and SlotHealth reported it attested. In sections that walk credentials, every adopted Strict entry without the checked flag and every adopted Strict pending entry is now unconfirmed until a walk passes. When a held ring refuses a Strict binding c over a different unconfirmed Strict real-slot entry (active or adopted), keeping that entry could enforce a weaker policy than c; bind now installs c unchecked, active and unconfirmed instead (its slot reports it and a heal confirms it). An adopted entry equal to c, a Strict pending entry, and an Audit entry are restored as before (Audit->Strict needs a passed check; the bind error keeps status honest). Start keeps such a take-over instead of failing, so a replacement is never blocked. Addresses Copilot review on #1160 (comment 4799126761). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
…i-s2-pending-owner Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Performance Benchmark ResultsNode-Agent Resource Usage
Dedup EffectivenessNo data available. |
…d for a ring-only SkipArming problem - rewriteClass changed an adopted entry's flags but not its ringUnconfirmed marker: Audit->Strict read as attested without a check, and unchecked Strict->Audit kept the slot unhealthy. An adopted entry made Strict in a credential-walking section is now unconfirmed, and one made Audit is cleared. - A Strict SkipArming binding is now ring-checked too: a fresh bind runs the check-only walk (records credentials, scans rings, arms nothing), so it is confirmed at once or bound but unconfirmed, never refused. - Heal and HealNode return ErrNotHealable for a non-arming binding only when there are slot tracking faults, an unknown fault count or new node faults (lost marks only a new instance can re-arm); a binding whose only problem is the ring check is check-only walked and stays unconfirmed, so the owner reports ProtectionUnconfirmed without reloading. Addresses Copilot review on #1160 (comments 4799346149, 4799126761). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
…i-s2-pending-owner Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Performance Benchmark ResultsNode-Agent Resource Usage
Dedup EffectivenessNo data available. |
|
Re the round-14 review summary (a binding-publication race letting concurrent hooks bypass pending restrictions when the bind later fails), checked at dc21ea9:
|
Performance Benchmark ResultsNode-Agent Resource Usage
Dedup EffectivenessNo data available. |
There was a problem hiding this comment.
🟡 Changes recommended
The binding transition can expose real-policy permissions before the held-ring check succeeds, and failed rollback handling can leave the slot permanently ring-unconfirmed.
2 open issues
1 resolved since last review
Review effort: Balanced
… publishes When an unchecked Strict pending entry moved to a real Strict slot, bind wrote the real-slot entry before arming and the io_uring check, so tasks could use the real policy's permissions during a walk that then failed. For that transition (an active or adopted Strict pending entry to a Strict real slot) bind now arms and checks first, while the pending entry still denies; on failure nothing is published and the pending entry stays unconfirmed (and becomes the heal-retried move if one was deferred), on success the checked entry is written once. Other transitions keep their order. keepFailed also clears any deferred move for the cgroup it keeps. Addresses Copilot review on #1160 (comments 4800029861, 4800029921). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
…i-s2-pending-owner Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| // entry. A refused walk writes nothing: the pending entry stays. | ||
| prevPending := (bound && previous.Slot == PendingSlot && b.classOf(previous)) || | ||
| (wasAdopted && adopted.Slot == PendingSlot && adopted.Flags&bindingStrict != 0) | ||
| prechecked := prevPending && c.Slot != PendingSlot && strict && b.armed != nil && !c.SkipArming |
There was a problem hiding this comment.
Fixed in 3a8d720: the check-before-write now also covers a SkipArming binding (the pod hand-over) moving from an unchecked Strict pending entry to a Strict real slot. bind runs a side-effect-free scan first (record credentials, scan rings, arm nothing, runtime helpers included) while the pending entry stays installed; on a held ring or record failure nothing is written, the pending entry stays unconfirmed and Bind returns ErrIoUringHeld, so the owner keeps the pending mark, reports it Faulted and retries; on success the checked entry is written once. Test: TestPendingToRealSlotSkipArmingChecksBeforeWriting (map captured during the scan, nothing armed).
…hecks before it publishes The round-15 check-before-write covered only arming bindings. A SkipArming binding (the pod hand-over) moving from an unchecked Strict pending entry to a Strict real slot still wrote the real-slot entry before checkOnly, and a held io_uring ring left the real policy in place. bind now runs a side-effect-free scan (record credentials, scan rings, no arming) first while the pending entry stays installed; on failure nothing is written, the pending entry stays unconfirmed and Bind returns ErrIoUringHeld (the owner keeps the pending mark, reports it Faulted and retries); on success the checked entry is written once. Addresses Copilot review on #1160 (comment 4800173157). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
…i-s2-pending-owner Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Performance Benchmark ResultsNode-Agent Resource Usage
Dedup EffectivenessNo data available. |


Summary
This is groundwork for the NRI start gate, and it changes no behavior on its own. A sandbox binding can now point at
PendingSlot, a slot index that is never published. The file, network and privilege programs already treat an unpublished slot as a structural fault, so a pending pod mark already does what the gate needs:There is no BPF map or layout change. Nothing writes a pending binding yet; the NRI writer comes in a later PR.
Enforcement library
Binding.StrictandPendingSlot.classOf: a pending binding takes its class from the binding, a real slot only from the slot. An in-place Strict→Audit flip therefore never leavesBINDING_STRICTbehind.validaterefusesStricton a real slot.Rebindswaps a cgroup binding's identity in one map write.HealNode,Kept,rewriteClass, the adoption reconcile andslotGatehandle pending entries. Per-slot counters of a pending slot return an error, never zero.Errno
prepare_creds()andcred_alloc_blank()turn the hook's refusal into NULL, and their callers return ENOMEM. This is documented in the docs and the tests.Tests
Validation
TestIoUringAttrIsJudgedfails there (setxattr EACCES); it also failed on that kernel before this change and is not touched herego build,go vet(including the kernel tags),go test -race, gofmt,go mod tidyAI Review
The changes were written and validated with Claude Code (Claude Opus 5.5), and each round was checked by a separate reviewer agent:
The owner approved the design decisions and accepted the ENOMEM kernel limit.
🤖 Generated with Claude Code
AI-skills: none | cmds: /goal