Skip to content

feat(ebpf): Add file, network, memory, and process-control syscall telemetry - #730

Merged
rabbitstack merged 5 commits into
rabbitstack:linux-portfrom
mostafa:feat/linux-syscall-telemetry
Sep 15, 2026
Merged

rabbitstack merged 5 commits into
rabbitstack:linux-portfrom
mostafa:feat/linux-syscall-telemetry

Conversation

@mostafa

@mostafa mostafa commented Sep 15, 2026

Copy link
Copy Markdown

What is the purpose of this PR / why it is needed?

Expands the Linux eBPF source beyond the process vertical slice to the MVP syscall matrix: openat (with open/openat2), unlink/unlinkat, rename/renameat/renameat2, connect, accept/accept4, mmap, process_vm_readv/process_vm_writev, kill/tkill/tgkill, ptrace, and prctl. Each family lives in its own BPF program object sharing the ring buffer, scratch, and enabled-type maps through MapReplacements.

The shared syscall_event record grows generic argument slots, a second path buffer, and truncation bits. Enter-state is staged in a per-CPU heap array (two 256-byte paths exceed the BPF stack) and correlated to the exit through a global LRU hash keyed by pid_tgid: the task can migrate CPUs mid-syscall, so the correlation map cannot be per-CPU, and LRU eviction reclaims entries whose exit never fires. Sockaddr copies clamp to the caller's addrlen because a fixed-size read past the buffer can cross into an unmapped page and fail wholesale; accept reads the value-result addrlen and peer address at exit. Emission is gated in the kernel by an enabled-type array populated from the event source config, so disabled families cost neither ring buffer traffic nor userspace decode.

Successful mmap calls update the process state with the new mapping (base, size, protection, anonymous or file-backed kind).

What type of change does this PR introduce?


/kind feature

Any specific area of the project related to this PR?


/area instrumentation

/area telemetry

/area tests

Special notes for the reviewer


  • Integration base is linux-port, not master.
  • Stable semantic type IDs 4-14 extend the Linux catalog; the raw syscall number stays an event parameter, so openat/openat2/open all map to one openat event.
  • Process-control events (kill, ptrace, prctl) are always captured with the process family. File, network, and memory families follow enable-fileio, enable-net, and enable-mem, enforced twice: tracepoints are not attached, and the kernel-side enabled map stays zero.
  • Only legacy syscall tracepoints (open, unlink, rename, tkill, and the existing fork/vfork) are optional attachments, following the earlier finding that some kernels refuse perf links on them. Modern variants (openat2, renameat2, accept4, tgkill) must attach.
  • Scratch entries are deleted on every exit path, including ring-buffer-full reserve failures.
  • Objects regenerated with Ubuntu 24.04 clang 18 to match the drift check.
  • Verified:
    • Docker Linux: ./internal/ebpf/generate.sh followed by a clean git diff -- internal/ebpf
    • Docker Linux: go test ./internal/ebpf/... ./pkg/event/...
    • Matrix test asserts every catalog type decodes its documented parameters; live integration test covers openat, rename, unlink, and kill end to end.

Does this PR introduce a user-facing change?


Yes. On a 5.9+ kernel with runtime BTF, fibratus run now emits file, network, memory, and process-control syscall events alongside process telemetry, honoring the enable-fileio, enable-net, and enable-mem event source settings.

Extend the Linux event catalog with openat, unlink, rename, connect, accept, mmap, process_vm_readv/writev, kill, ptrace, and prctl. Identifiers stay stable and Linux-native, and tests assert that Windows event names stay out of the catalog.
Grow the ring buffer record with extra arguments, a second path buffer, and truncation bits so later syscall families can share one header. Build scratch values in a per-CPU heap to stay under the BPF stack limit, and gate emission with an enabled-type array keyed by stable event IDs rather than architecture syscall numbers.
Add one CO-RE program per family for openat/unlink/rename, connect/accept, mmap/process_vm_readv/writev, and kill/ptrace/prctl. Optional families follow the existing enable-fileio, enable-net, and enable-mem switches, process-control events stay on, and accept reads the peer address on syscall exit because the kernel fills it then.
Add a checked matrix that every Linux event type decodes with its documented parameters, plus mmap process-state and live open/rename/unlink/kill coverage on a real kernel.
Comment thread internal/ebpf/c/common/events.h Outdated
Comment thread internal/ebpf/c/common/events.h
Comment thread internal/ebpf/c/common/events.h Outdated
Comment thread internal/ebpf/c/ctl.bpf.c Outdated
Comment thread internal/ebpf/c/common/events.h
Comment thread internal/ebpf/consumer.go Outdated
Comment thread internal/ebpf/loader.go
tp_btf/sys_exit supplies pt_regs, so kill/ptrace/prctl no longer need an enter probe or scratch slot. Rename filename2 to aux, document the truncation bits and padding, and keep only file-backed mmaps in process state until munmap is hooked.
@rabbitstack
rabbitstack merged commit c37e2c2 into rabbitstack:linux-port Sep 15, 2026
1 check passed
@mostafa
mostafa deleted the feat/linux-syscall-telemetry branch September 15, 2026 17:25
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.

2 participants