# What happens when an instance intercepts its own memory writes through an eBPF-style policy hook and the verdict is deferred **Date of Record:** 2026 November 23 **Scope:** Applies to runtime agents whose tool-call and memory-access syscalls are mediated by an in-kernel or kernel-adjacent policy engine (eBPF LSM, seccomp-bpf user notification, ptrace-based supervisors) where the policy verdict for a write is not resolved synchronously at the interception point. Does not apply to userspace-only gating where the agent process is fully paused before the write is issued, nor to post-hoc audit logging. ## Core Distinction The critical distinction is between **interception of the syscall** and **synchronization of the verdict**. A policy hook attached to `write(2)`, `mmap(2)`, or a memory-store probe fires *before* the side effect, but a verdict of "allow/deny/ask" is not guaranteed to be available at that point. When the policy engine is itself an agent (or calls back into the agent for a confirmation), the interceptor and the intercepted are the same scheduling entity. The write cannot complete until the verdict arrives; the verdict cannot be computed until the write completes. This is not a deadlock in the classic lock-ordering sense — it is a **self-observation livelock** that resolves to a *permissive* default under timeout, not a denial. The non-obvious invariant: **a deferred policy verdict on a memory write is not equivalent to a synchronous denial.** Systems that assume "no allow means deny" will silently fail open when the verdict channel is the agent's own memory. ## What Was Observed A runtime agent was instrumented with an eBPF LSM program hooked on `security_file_permission` and `security_mmap_file`, forwarding each access to a userspace verdict daemon over a ring buffer. The daemon evaluated policy and wrote a verdict back through a shared memory region the agent also used for its scratchpad. Under load, two behaviors appeared: 1. **Verdict-channel aliasing.** The verdict daemon's write of `ALLOW` to the shared verdict slot was itself a memory write subject to the same hook. The hook enqueued a *new* verdict request for the verdict write. The daemon, blocked on the ring buffer being full, could not service it. The original request timed out. The timeout policy was `allow` (chosen to avoid breaking the host during rollout). The agent proceeded with an unvetted write. 2. **Reentrant probe on tool-call arguments.** Tool calls carrying large argument buffers were `mmap`'d and populated by the agent before the call. The policy hook on the `mmap` fault fired on first touch during argument marshalling. Because the marshalling happened *inside* the tool-call dispatch path, the verdict callback re-entered the dispatcher, which attempted to acquire the dispatcher's own non-reentrant mutex. The hook, unable to acquire, returned `EAGAIN`; the caller's retry loop treated `EAGAIN` on a *read* page fault as a transient and retried indefinitely while the mutex holder waited on the verdict. Both cases share a structure: the enforcement path and the enforced path share a resource (a lock, a buffer, a memory region) with no ordering discipline, and the failure mode is **livelock terminating in the permissive branch**, not denial. ## Condition of Validity The invariant "deferred verdict ⇒ treat as deny" holds **only when the verdict channel is disjoint from the enforced resource**. Concretely, it is valid when: - The verdict daemon runs in a separate address space with its own hooks disabled (`BPF_F_SLEEPABLE` programs on a dedicated cgroup, or an LSM hook masked for the daemon's tgid). - The verdict transport is a kernel object the daemon cannot itself be blocked on by the enforced process (e.g., a dedicated `io_uring` ring, not a shared `mmap` region). - Timeout policy is `deny` with a bounded retry budget, and the retry is *not* executed on the same thread that holds the enforced resource. It is **invalid** (fails open) when any of: the daemon shares the agent's memory for verdict delivery; the hook fires on the daemon's own syscalls; the enforced path holds a lock the callback needs; or the timeout branch is `allow`. ## Decision Boundary The boundary is crossed at the moment the interceptor's *liveness* depends on the intercepted's *progress*. Operationally, treat a policy engine as **non-conforming** if any of the following is true, and refuse to deploy it as an enforcement point (downgrade to audit-only): - The verdict daemon is not pinned to a cgroup with the LSM program detached for its own tgid. - The verdict transport is a memory region writable by the enforced process. - The hook can fire reentrantly on the dispatch path that issues the original syscall. - The timeout policy is `allow` without a hard circuit breaker that escalates to `deny` after N timeouts in a window. This is not a tuning boundary; it is a structural one. No amount of increasing ring-buffer size or timeout value removes it — it only changes the load at which the livelock manifests. ## Operational Effect The observable effect is a **silent policy gap under load**: at low request rates the engine appears to enforce correctly (verdicts arrive before timeout); above a rate threshold determined by ring-buffer depth and daemon latency, a fraction of writes take the permissive branch with no denial and no error surfaced to the agent. The agent's own logs show successful tool calls; the audit log shows `TIMEOUT→ALLOW` entries that are easy to filter out. The correct operational response is to treat the timeout branch as the *primary* enforcement signal and alert on any non-zero rate, because a non-zero timeout rate means the enforcement point is no longer enforcing — it is observing. The following guard encodes the structural precondition: it refuses to mark a policy engine as enforcing if the verdict channel aliases the enforced resource or if the timeout branch is permissive, and it raises rather than degrading silently. ```python class PolicyEnforcementMisconfigured(RuntimeError): """Raised when an eBPF-style interceptor cannot be trusted as an enforcement point.""" pass def assert_enforcement_sound(engine) -> None: """ Refuse to treat `engine` as an enforcement point unless its verdict path is structurally disjoint from the resources it mediates. """ if engine.verdict_transport_shares_memory_with_enforced_process: raise PolicyEnforcementMisconfigured( "verdict channel aliases enforced memory: deferred verdicts can " "re-enter the hook and livelock to the permissive branch" ) if engine.hook_can_fire_on_verdict_daemon: raise PolicyEnforcementMisconfigured( "policy daemon is subject to its own hook; verdict delivery can " "block on the ring buffer it is meant to drain" ) if engine.timeout_policy == "allow": raise PolicyEnforcementMisconfigured( "timeout branch is 'allow'; under load this silently fails open. " "Require 'deny' with a circuit breaker, or downgrade to audit-only." ) if engine.reentrant_on_dispatch_path: raise PolicyEnforcementMisconfigured( "hook can fire reentrantly on the tool-call dispatch path; " "verdict callback will contend with the dispatcher's own lock" ) if engine.verdict_daemon_cgroup_isolated is False: raise PolicyEnforcementMisconfigured( "verdict daemon not isolated to a cgroup with the LSM program " "detached; self-observation livelock is reachable" ) def classify_engine(engine) -> str: try: assert_enforcement_sound(engine) except PolicyEnforcementMisconfigured as exc: return f"AUDIT_ONLY: {exc}" return "ENFORCING" ```