Skip to content

fix: track zone processes (return values, process exits, reparenting) (#154) - #166

Draft
dalejrodriguez wants to merge 6 commits into
edera-dev:mainfrom
dalejrodriguez:fix/154-retval-from-event-type
Draft

dalejrodriguez wants to merge 6 commits into
edera-dev:mainfrom
dalejrodriguez:fix/154-retval-from-event-type

Conversation

@dalejrodriguez

@dalejrodriguez dalejrodriguez commented Nov 20, 2026 •

Copy link
Copy Markdown

Fixes #154

Design reference: docs/design/zone-process-tracking.md (root cause with evidence, each change, trade-offs, test plan).

Problem

Zone open events reached Falco with fd.name=NA, proc.exe=NA and evt.res=<NA>, and processes started after the zone snapshot were dropped (no thread found). No file rule on edera_zone could fire.

Root cause

Every zone syscall event arrives with event_category = "EC_TRACEPOINT". has_retval() required SYSCALL in 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

  1. Return values come from the event, not the category string (src/parsers.rs). Any exit event with parameters, except PPME_GENERIC_X, carries the return value first. This matches libsinsp for every exit event libscap defines.
  2. Zones send process exits (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 plus PPM_SC_SCHED_PROCESS_EXIT. Mirror mode adds process exit to the set it reads from Falco, and its fallback uses the same explicit set.
  3. Children move to the reaper on exit (src/threadstate.rs). The old check compared each thread's ptid with its own tid, so nothing moved, and the next purge deleted running children of exited processes. This only became reachable with change 2.

Please note

  • The plugin's copy of the zone default can drift. Before, the plugin asked for "the zone default", so Falco users got whatever protect's default said. Now it sends its own copy (identical to protect v1.13.1 through v1.13.4, plus process exit). If a future zone default adds or removes events, Falco users won't see that change until 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 mode still sends the wrong syscall set (follow-up PR, mirror_host_syscalls reads Falco's syscall map with the wrong numbering, so zones capture the wrong syscalls #165). With mirror_host_syscalls: true (our Helm example), the plugin reads Falco's interesting_syscalls_table_64bit map as libscap ppm_sc codes, but that map is indexed by the kernel's syscall number. This PR only adds process exit there; correct numbering needs the syscall-number to ppm_sc table and will be a separate PR.
  • evt.category and evt.count.error.memory still reflect the zone's wrong string until zones carry https://github.com/edera-dev/protect/pull/5078.

Testing

  • cargo test: 61 pass; cargo fmt --check and cargo clippy clean.
  • New tests: return values with any category string; a replay of the sequence captured on a test node (fork child in a PID namespace, execve cat, open /etc/shadow, all labelled EC_TRACEPOINT); exited children leaving the table; running children surviving their parent. The replay and reparent tests fail on the old code.
  • Reproduced and diagnosed on an Edera 1.13.1 Xen worker (Falco 0.45.2) with a diagnostic build.
  • Still to run before release (draft until done): a stress test with about 1,000 short-lived processes per minute, a PID-reuse check, and a 24-hour soak watching Falco memory. Details in the design note.

🤖 Generated with Claude Code

dalejrodriguez and others added 5 commits November 20, 2026 01:19
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]>
…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]>
@dalejrodriguez

Copy link
Copy Markdown
Author

Running stress tests at the moment.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Zone open events carry no file name or process (fd.name=NA, proc.exe=NA), and new processes are dropped ("no thread found")

1 participant