Skip to content

feat(ebpf): Add Linux process event source - #729

Merged
rabbitstack merged 8 commits into
rabbitstack:linux-portfrom
mostafa:feat/linux-ebpf-process-source
Sep 14, 2026
Merged

rabbitstack merged 8 commits into
rabbitstack:linux-portfrom
mostafa:feat/linux-ebpf-process-source

Conversation

@mostafa

@mostafa mostafa commented Sep 14, 2026

Copy link
Copy Markdown

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

Adds the live Linux eBPF process source so fibratus run can capture execve, exit, and clone instead of stopping at an unwired capture stub. The source loads committed CO-RE objects, shares maps across separately generated collections, snapshots thread-group leaders with iter/task, and reconciles hot events against that baseline using PID plus start boot time.

Successful clones take child identity from sched_process_fork, and process exits are emitted from sched_process_exit because exit/exit_group never return (their syscall exit tracepoints never fire) and signal-terminated processes never invoke them. Filename bytes for execve/execveat are copied into a scratch map on enter so a successful exec cannot reread a replaced address space. Executable path and cmdline are best-effort /proc/<pid>/{exe,cmdline} reads only. Missing kernel 5.9, usable /sys/kernel/btf/vmlinux, or required program/map helpers fail the open path with a concrete error.

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

/area ci

/area build

Special notes for the reviewer


  • Integration base is linux-port, not master.
  • x86_64 only. The loader rejects other GOARCH values.
  • Generated bpf2go bindings and .o objects are committed. Ordinary Linux builds do not need clang. internal/ebpf/generate.sh regenerates them.
  • Shared maps (events, drop_count, scratch) are owned by the execve collection and injected into exit/clone/iterator collections with MapReplacements.
  • Startup sequence: load maps, start the ring buffer reader, attach the hot path, queue inbound events, run iter/task, upsert baseline process state, replay pending events in ring-buffer order, then switch to live dispatch.
  • Credential parameters carry effective uid/gid.
  • Process events are always captured. File/net/memory families are not in this change.
  • Linux bootstrap now constructs the process snapshotter, optional rule engine, aggregator, local API (TCP or unix://), and signal handling. Filaments remain unsupported.
  • Capabilities expected at runtime: CAP_BPF, CAP_PERFMON, and CAP_SYS_PTRACE for incidental /proc enrichment.
  • Verified:
    • Docker Linux: go test ./internal/ebpf ./internal/bootstrap ./pkg/event ./pkg/ps ./pkg/api ./pkg/util/signals
    • Docker Linux: go build -o /tmp/fibratus ./cmd/fibratus
    • GOOS=windows GOARCH=amd64 go test -exec=true ./pkg/event ./pkg/util/signals ./pkg/api ./internal/bootstrap

Does this PR introduce a user-facing change?


Yes. On a 5.9+ kernel with runtime BTF, fibratus run opens the eBPF process source and emits enriched execve, exit, and clone events into the existing aggregator and outputs path.

Linux run can now load CO-RE programs, snapshot processes through iter/task, and emit enriched execve/exit/clone events instead of failing as an unwired capture stub.
@mostafa
mostafa marked this pull request as draft September 14, 2026 11:22
Some kernels refuse a perf link on the legacy fork/vfork syscall tracepoints while clone and clone3 still attach. Treat those links as optional so the process source can open.
The exit and exit_group syscalls never return, so their raw syscall exit
tracepoints never fire, and processes terminated by signals never enter
exit_group at all. Attach a tp_btf program to sched_process_exit instead,
emitting the raw wait status from the task exit code when the thread-group
leader terminates.

Also read effective instead of real credentials in every program so the
uid/gid parameters match their documented semantics.
Drain the pending queue in rounds and only flip to live dispatch once the
queue is empty, so replayed and live events cannot interleave out of ring
buffer order. Size the output channel to the pending capacity so a full
replay cannot block before the aggregator starts consuming. Assign the
sequence number at dispatch and increment it only for events that pass
exclusion and filtering, mirroring the Windows consumer.
Guard single instance with an abstract UNIX domain socket that the kernel
releases automatically on process termination, replacing the flock file in
a world-writable directory. Drop the no-op debug privilege option since
the concept does not exist on Linux. Import internal/ebpf under the
libebpf alias and give the Windows signal handler its platform suffix now
that a Linux counterpart exists.
@mostafa
mostafa force-pushed the feat/linux-ebpf-process-source branch from b4641de to aa5ffb3 Compare September 14, 2026 11:51
@mostafa
mostafa marked this pull request as ready for review September 14, 2026 12:05

@rabbitstack rabbitstack left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, looks pretty solid. Just a few naming nits and some questions. Approving...

Comment thread internal/ebpf/c/common/events.h Outdated
Comment thread internal/ebpf/c/common/events.h Outdated
Comment thread internal/ebpf/c/common/events.h Outdated
Comment thread internal/ebpf/c/clone.bpf.c Outdated
Comment thread internal/ebpf/loader.go Outdated
Drop the kind field: it always mirrored the type, which alone designates
the event topology, with zero reserved for iter/task snapshot records
that map to the unknown type and can never leak as live events. Removing
it also removes the explicit alignment padding. Rename the record struct
to syscall_event, generalize clone_flags to a per-type flags field ahead
of wider telemetry, and rename attachHotPath to attachPrograms with a
comment contrasting the continuous live-capture programs against the
one-shot snapshot iterator.
@rabbitstack
rabbitstack merged commit 841911d into rabbitstack:linux-port Sep 14, 2026
1 check passed
@mostafa
mostafa deleted the feat/linux-ebpf-process-source branch September 14, 2026 17:39
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