Skip to content

fix: map Falco's native syscall numbers to ppm_sc codes in mirror mode (#165) - #167

Draft
dalejrodriguez wants to merge 8 commits into
edera-dev:mainfrom
dalejrodriguez:fix/165-mirror-syscall-numbering
Draft

dalejrodriguez wants to merge 8 commits into
edera-dev:mainfrom
dalejrodriguez:fix/165-mirror-syscall-numbering

Conversation

@dalejrodriguez

@dalejrodriguez dalejrodriguez commented Nov 20, 2026 •

Copy link
Copy Markdown

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's interesting_syscalls_table_64bit map as libscap ppm_sc codes. That 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 (PPM_SC_OPENAT is 197). The loop also stopped at PPM_SC_MAX (454) instead of the map's size.

Change

src/source_plugin/client/enabled_syscalls.rs:

  • Read the whole map (array.len() entries).
  • 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 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

  • New dependencies: syscalls 0.6 (default-features = false) and strum 0.28 (for IntoEnumIterator on ppm_sc_code). Cargo.lock only adds these two; I kept bindgen on syn 2.0.110, because Cargo's re-resolve moved it to syn 3.0.9, which doesn't compile.
  • Name matching relies on libscap's naming convention. A unit test checks that every zone-default syscall that exists on the architecture round-trips, and that it checked at least 60 of them, so a broken match can't pass silently.
  • Not yet tested on a node with mirror mode on. kubeadm-dev runs with mirror_host_syscalls: false.

Testing

🤖 Generated with Claude Code

dalejrodriguez and others added 6 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
dalejrodriguez force-pushed the fix/165-mirror-syscall-numbering branch from 601ddd7 to 3eb0f27 Compare November 20, 2026 07:00
dalejrodriguez and others added 2 commits November 20, 2026 02:12
…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
dalejrodriguez force-pushed the fix/165-mirror-syscall-numbering branch from 3eb0f27 to 52ec58f Compare November 20, 2026 07:12

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.

mirror_host_syscalls reads Falco's syscall map with the wrong numbering, so zones capture the wrong syscalls

1 participant