fix(sight): change cgroup gate to OR semantics and add trace_cgroup F…#859
Open
shawtao wants to merge 1 commit into
Open
fix(sight): change cgroup gate to OR semantics and add trace_cgroup F…#859shawtao wants to merge 1 commit into
shawtao wants to merge 1 commit into
Conversation
…FI interface 1. Add traced_pid_cgroup_gate_allow() with OR semantics to cgroup_helper.h: admit if PID is traced OR cgroup is in filter map. 2. Replace AND gate logic in filewatch, filewrite, proctrace (execve_enter) with traced_pid_cgroup_gate_allow() OR call. 3. Add dynamic cgroup filter FFI interface: - ProbeCommand channel in ffi.rs for thread-safe probe control - agentsight_add_traced_cgroup() / agentsight_remove_traced_cgroup() C exports - src/agentsight/include/agentsight.h C header Stdout/exit paths retain child_pids gate to avoid high-frequency flood.
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat(sight): upgrade cgroup gate to OR semantics and add trace_cgroup FFI interface
Add traced_pid_cgroup_gate_allow() with OR semantics to cgroup_helper.h: admit if PID is traced OR cgroup is in filter map.
Replace AND gate logic in filewatch, filewrite, proctrace (execve_enter) with traced_pid_cgroup_gate_allow() OR call.
Add dynamic cgroup filter FFI interface:
Stdout/exit paths retain child_pids gate to avoid high-frequency flood.
Description
The existing cgroup filter implementation (merged in
367c6fa) uses AND logic: events pass only when both PID is intraced_processesAND cgroup is incgroup_filter. This causes a critical issue — when onlycgroup_ids are registered (no PIDs intraced_processes), all events are silently dropped because the PID check fails first.This PR fixes the gate semantics and exposes the dynamic cgroup control via C FFI:
Add
traced_pid_cgroup_gate_allow()with OR semantics tocgroup_helper.h: admit if PID is traced OR cgroup is in filter map.Replace AND gate logic in
filewatch.bpf.c,filewrite.bpf.c,proctrace.bpf.c(execve_enter) with the unified OR gate call.Add dynamic cgroup filter FFI interface:
ProbeCommandchannel inffi.rsfor thread-safe probe control from caller thread to background pipelineagentsight_add_traced_cgroup()/agentsight_remove_traced_cgroup()C exportssrc/agentsight/include/agentsight.hC headerStdout/exit paths retain
child_pidsgate to avoid high-frequency flood on write(2)/sched_process_exit.Related Issue
no-issue: semantic fix for cgroup filter gate logic introduced in 367c6fa
Type of Change
Scope
sight(agentsight)Checklist
sight:cargo clippy -- -D warningsandcargo fmt --checkpasspackage-lock.json/Cargo.lock)Testing
filter_cgroup_enabled = trueand only cgroup IDs are registered (no PIDs), events from processes in those cgroups now pass the gate.filter_cgroup_enabled = false, behavior is identical to pre-patch (pure PID gate).agentsight_add_traced_cgroup()/agentsight_remove_traced_cgroup()— commands are enqueued and drained by the background thread's event loop.Additional Notes
NO_CGROUP_FILTERmacro path (used byprocmon.bpf.c) degrades to purepid_allow, preserving full-system audit semantics.filewatch/filewriteeventpidfield switched fromis_pid_traced()return value tocurrent_ns_pid()since the OR gate no longer guarantees PID registration on cgroup-only admission.