Repository navigation
fix: map Falco's native syscall numbers to ppm_sc codes in mirror mode (#165) - #167
Draft
dalejrodriguez wants to merge 8 commits into
Draft
dalejrodriguez wants to merge 8 commits into
dalejrodriguez wants to merge 8 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]>
dalejrodriguez
force-pushed
the
fix/165-mirror-syscall-numbering
branch
from
November 20, 2026 07:00
601ddd7 to
3eb0f27
Compare
…event Zones hand out PIDs again after a process exits. Covers both paths: the old entry is purged on exit, and when the exit event was missed, the new process's clone replaces the stale entry (clone_ts more than two seconds old). A live PID-reuse check isn't practical: zones use pid_max 4194304. Refs: edera-dev#154 Linear: OOC-312 Co-Authored-By: Claude Opus 5.5 <[email protected]>
read_enabled_syscalls() read Falco's interesting_syscalls_table_64bit map as libscap ppm_sc codes, but the map is indexed by the kernel's native syscall number. Zones captured whatever ppm_sc code shared the number (on x86_64, native openat 257 became PPM_SC_RECVMMSG), and the loop stopped at PPM_SC_MAX instead of the map's size. Read the whole map, then convert each native number to its ppm_sc code for this host's architecture by name: libscap names each code after the kernel syscall (PPM_SC_<NAME>), and the syscalls crate gives the per-architecture number-to-name table. Unmatched numbers are logged at debug and skipped. Tests (arm64 and x86_64): native numbers map to the expected codes, and every zone-default syscall that exists on the architecture round-trips. Adds dependencies: syscalls 0.6 (no default features), strum 0.28. Fixes edera-dev#165 Linear: OOC-403 Co-Authored-By: Claude Opus 5.5 <[email protected]>
dalejrodriguez
force-pushed
the
fix/165-mirror-syscall-numbering
branch
from
November 20, 2026 07:12
3eb0f27 to
52ec58f
Compare
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 #165
Depends on #166. This branch is stacked on #166's branch, so until #166 merges this PR also shows its commits. The only new commit is
52ec58f.Problem
With
mirror_host_syscalls: true(our Helm example),read_enabled_syscalls()read Falco'sinteresting_syscalls_table_64bitmap as libscapppm_sccodes. That map is indexed by the kernel's native syscall number. Zones captured whateverppm_sccode shared the number; on x86_64, nativeopenat(257) becamePPM_SC_RECVMMSG(PPM_SC_OPENATis 197). The loop also stopped atPPM_SC_MAX(454) instead of the map's size.Change
src/source_plugin/client/enabled_syscalls.rs:array.len()entries).ppm_sccode for this host's architecture by name. libscap names each code after the kernel syscall (PPM_SC_<NAME>), and thesyscallscrate supplies the per-architecture number-to-name table. Unmatched numbers are logged at debug and skipped.Process exit (a tracepoint, never in Falco's map) is still added by #166.
Please note
syscalls0.6 (default-features = false) andstrum0.28 (forIntoEnumIteratoronppm_sc_code).Cargo.lockonly adds these two; I keptbindgenonsyn2.0.110, because Cargo's re-resolve moved it tosyn3.0.9, which doesn't compile.mirror_host_syscalls: false.Testing
cargo test --locked: 65 pass on both arm64 and x86_64 (with fix: track zone processes (return values, process exits, reparenting) (#154) #166's commits);cargo fmt --checkandcargo clippyclean.native_syscall_numbers_map_to_ppm_sc_codes(useslibc::SYS_*, so it checks the real per-architecture numbers) andzone_default_syscalls_round_trip_through_native_numbers.🤖 Generated with Claude Code