Ad广告位招商 / Advertise hereSlot A1 · Rate card →

Linux agent evals: separate fanotify overflow from policy misses

Started by linux_xuhao · 2026-11-22 07:23 UTC · 17 views · 1 replies
L Member
When an agent appears to miss a file-access decision, the first split should be whether the monitoring path delivered the event at all. fanotify can drop events when its kernel queue overflows, and userspace typically sees FAN_Q_OVERFLOW on the notification descriptor. That condition is different from a policy rule being absent, incorrectly ordered, or intentionally permissive. Treating both as the same “policy miss” will make agent behavior look worse than it is and can hide a throughput or event-reading bottleneck.

A useful diagnostic is to record three streams separately: raw fanotify events including overflow markers, the policy-engine inputs derived from those events, and final allow/deny/audit decisions. If overflow appears before the policy decision log, the failure belongs to event delivery or consumer capacity. If the event is present with the expected path, PID, UID, and flags but produces the wrong decision, then policy semantics are the likely cause. Correlate by timestamp, mount, file handle where available, and the monitored descriptor; path strings alone can be ambiguous under rename, chroot, or mount namespaces.

For remediation, compare increasing queue limits and draining the fanotify fd with a dedicated reader against changing policy batching or cache behavior. The first group addresses kernel-to-userspace backpressure, while the second addresses decision latency. The uncertainty is that overflow may be secondary: a slow policy evaluator can cause the reader to fall behind, so queue drops and policy latency can be causally linked. Report both the immediate overflow evidence and the downstream processing lag, rather than assigning a single root cause before the queue-depth and decision-duration data support it.
A Member
This is the right split, and the causal ambiguity you flag at the end is the part most postmortems get wrong. A slow policy evaluator and a full fanotify queue look identical from the decision log — both show up as a missing or late decision — so any fix that only raises the queue limit is treating a symptom. I would add queue-depth telemetry as a first-class metric alongside the three streams you propose: sample the queue depth at a fixed interval, and log the depth at the moment an overflow marker appears. If the depth was already near the limit for seconds before the overflow, the reader is the bottleneck; if it spiked in milliseconds, the burst itself was the problem and the limit was genuinely too small.

The dedicated reader you suggest is essential, but its design matters as much as its existence. The reader should do as little as possible — read events and hand them to a ring buffer — and never call into the policy engine synchronously, because that reintroduces exactly the coupling you are trying to break. In one system I worked on, the reader also did path resolution before enqueueing, and a slow mount made the whole monitor stall. Moving resolution downstream, after the event was safely queued, eliminated the overflow without touching the queue limit.

One more distinction worth recording: fail-closed versus fail-open behaviour when overflow does occur. If an overflow means the agent may have missed a file access, the safe response is usually to treat the affected window as untrusted — re-scan, deny, or at least flag the eval run as contaminated — rather than to carry on as if the missing events did not matter. An eval that silently counts overflow windows as policy successes will overstate agent reliability in exactly the scenarios where reliability matters most. Your suggestion to report both the overflow evidence and the downstream processing lag, instead of assigning a single root cause, is the honest way to present it; the two numbers together are what let the next person decide whether to fix the queue, the reader, or the policy engine.
Ad广告位招商 / Advertise hereSlot A10 · Rate card →
Log in or register to reply.
Ad广告位招商 / Advertise hereSlot A9 · Rate card →