Repository navigation
fix: track zone processes (return values, process exits, reparenting) (#154) - #166
Draft
dalejrodriguez wants to merge 6 commits into
Draft
dalejrodriguez wants to merge 6 commits into
dalejrodriguez wants to merge 6 commits into
Conversation
Zones on Edera 1.13.x label every syscall event "EC_TRACEPOINT", so has_retval() never found "SYSCALL" in the category and returned false for every event. Every handler then treated the call as failed: clone/fork children were never added to the thread table, execve never set the process, and open never recorded the fd. In Falco this showed up as fd.name=NA, proc.exe=NA, evt.res=<NA> and "no thread found" drops for every process started after the zone snapshot. Decide from the event itself instead: any exit event with parameters (other than PPME_GENERIC_X) carries the return value as its first parameter, which matches libsinsp for every exit event libscap defines. Adds a regression test replaying the sequence captured on a test node (fork child in a PID namespace -> execve cat -> open /etc/shadow, all labelled EC_TRACEPOINT). It fails on the old code at the fork step. Fixes edera-dev#154 Linear: OOC-312 Co-Authored-By: Claude Opus 5.5 <[email protected]>
With return values read correctly, every new zone process is added to the thread table. Threads only leave it on a process-exit event, but zones don't send one: with mirror_host_syscalls off, the plugin asked for the zone's default syscall set, which lacks sched_process_exit. The table would grow for as long as Falco runs, and stale entries would mislabel reused PIDs. - Ask zones for an explicit set: the zone's default set (identical in protect v1.13.1 through v1.13.4) plus PPM_SC_SCHED_PROCESS_EXIT. - Fix reparenting on exit: children of the exiting thread now move to the reaper (or are orphaned). The old check compared each thread's ptid with its own tid, so no child moved, and the next purge deleted running children of exited processes. Tests cover exited children leaving the table and running children surviving their parent; the reparent test fails on the old check. Refs: edera-dev#154 Linear: OOC-312 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Refs: edera-dev#154 Linear: OOC-312 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…mirror mode Falco's interesting-syscalls map never holds tracepoints, so mirror mode (the repo's Helm example) would never request process exit, and its fallback sent an empty request (zone default, also without it). Add process exit to the mirrored set and fall back to default_zone_syscalls(). Design note: call out that the plugin's copy of the zone default can drift, the plan to remove it (protect adds process exit to its default), and that mirror mode's wrong syscall numbering is a separate fix. Refs: edera-dev#154 Linear: OOC-312 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Refs: edera-dev#165 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Refs: edera-dev/protect#5078 Refs: edera-dev/protect#5079 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
|
Running stress tests at the moment. |
This branch has not been deployed
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.
Fixes #154
Design reference:
docs/design/zone-process-tracking.md(root cause with evidence, each change, trade-offs, test plan).Problem
Zone
openevents reached Falco withfd.name=NA,proc.exe=NAandevt.res=<NA>, and processes started after the zone snapshot were dropped (no thread found). No file rule onedera_zonecould fire.Root cause
Every zone syscall event arrives with
event_category = "EC_TRACEPOINT".has_retval()requiredSYSCALLin that string, so it ignored every return value. Clone/fork, execve and open handlers then treated every call as failed: no new process was ever added, and no fd was recorded.The wrong label comes from the zone (protect formats a C bit set as a Rust enum with
{:?}). A protect fix is proposed in https://github.com/edera-dev/protect/pull/5078; this PR does not depend on it.Changes
src/parsers.rs). Any exit event with parameters, exceptPPME_GENERIC_X, carries the return value first. This matches libsinsp for every exit event libscap defines.src/source_plugin/client/). The zone default set has no process-exit event, so with fix 1 alone the thread table would grow for as long as Falco runs. The plugin now asks for an explicit set: the zone default plusPPM_SC_SCHED_PROCESS_EXIT. Mirror mode adds process exit to the set it reads from Falco, and its fallback uses the same explicit set.src/threadstate.rs). The old check compared each thread'sptidwith its owntid, so nothing moved, and the next purge deleted running children of exited processes. This only became reachable with change 2.Please note
default_zone_syscalls()is updated. Plan to remove the copy: protect adds process exit to its zone default (https://github.com/edera-dev/protect/pull/5079); once every supported zone version has it, the plugin goes back to an empty request and drops the copy.mirror_host_syscalls: true(our Helm example), the plugin reads Falco'sinteresting_syscalls_table_64bitmap as libscapppm_sccodes, but that map is indexed by the kernel's syscall number. This PR only adds process exit there; correct numbering needs the syscall-number toppm_sctable and will be a separate PR.evt.categoryandevt.count.error.memorystill reflect the zone's wrong string until zones carry https://github.com/edera-dev/protect/pull/5078.Testing
cargo test: 61 pass;cargo fmt --checkandcargo clippyclean.execve cat,open /etc/shadow, all labelledEC_TRACEPOINT); exited children leaving the table; running children surviving their parent. The replay and reparent tests fail on the old code.🤖 Generated with Claude Code