Repository navigation
Description
What happened
On an arm64 host running a vendor 5.10 kernel (NVIDIA JetPack 5 / L4T 5.10.120-tegra), coroot-node-agent v1.35.8 starts, logs the kernel version and container runtime, and then exits with only:
failed to load collection: program sched_process_exit: load program: invalid argument
Every pre-flight check in ebpftracer/tracer.go passes on this kernel:
- tracefs is mounted (tracer.go#L253-L260)
- the kernel-version gate picks the
5.6build for a 5.10 kernel (tracer.go#L267-L281) ebpf.LoadCollectionSpecFromReadersucceeds (tracer.go#L292)
The failure comes from ebpf.NewCollectionWithOptions (tracer.go#L297-L305) as a bare EINVAL from bpf(BPF_PROG_LOAD). It is not a verifier error, so the *ebpf.VerifierError branch prints nothing extra, and the program named in the message is just whichever tracing program cilium/ebpf happened to load first (map iteration order), so it varies between runs.
Root cause on this class of kernels: CONFIG_KPROBES=n and CONFIG_UPROBE_EVENTS=n, which makes CONFIG_BPF_EVENTS unselectable (kernel/trace/Kconfig: depends on (KPROBE_EVENTS || UPROBE_EVENTS) && PERF_EVENTS). With CONFIG_BPF_EVENTS off, BPF_PROG_TYPE_KPROBE, BPF_PROG_TYPE_TRACEPOINT, BPF_PROG_TYPE_PERF_EVENT, BPF_PROG_TYPE_RAW_TRACEPOINT and BPF_PROG_TYPE_TRACING are compiled out entirely (include/linux/bpf_types.h), and find_prog_type() in kernel/bpf/syscall.c returns -EINVAL for them. CONFIG_BPF/BPF_SYSCALL/BPF_JIT are on, so the kernel otherwise looks eBPF-capable.
The agent's collection is entirely tracepoint/, kprobe/ and uprobe/ programs (ebpftracer/ebpf/proc.c, file.c, tcp/*.c, l7/*.c), so nothing in it can load on such a kernel. This is a different, deeper failure than the missing-BTF case already handled by #154 / #163: no amount of BTF or CO-RE work helps, and the agent cannot run without a kernel rebuild. The only thing wrong is that the agent does not say so.
#205 is a prior report where the same bare load program: invalid argument (different root cause: kernel lockdown) sent the reporter bisecting boot options by trial and error.
What I expected
A clear, actionable error such as:
kernel does not support BPF tracing programs (BPF_PROG_TYPE_TRACEPOINT / BPF_PROG_TYPE_KPROBE unavailable, CONFIG_BPF_EVENTS is probably not set); coroot-node-agent requires a kernel built with CONFIG_BPF_EVENTS=y
instead of a generic invalid argument that sends users down the BTF / kernel-version / verifier rabbit hole.
Proposed fix (small, self-contained)
In ebpftracer/tracer.go, before ebpf.NewCollectionWithOptions (currently line 297), probe the program types the collection needs with github.com/cilium/ebpf/features (a sub-package of the already-required github.com/cilium/ebpf v0.20.0; it maps EINVAL from the probe load to ebpf.ErrNotSupported):
for _, pt := range []ebpf.ProgramType{ebpf.TracePoint, ebpf.Kprobe} {
if err := features.HaveProgramType(pt); err != nil {
if errors.Is(err, ebpf.ErrNotSupported) {
return fmt.Errorf("kernel does not support BPF %s programs (CONFIG_BPF_EVENTS is not set?): %w", pt, err)
}
return fmt.Errorf("failed to probe BPF %s program support: %w", pt, err)
}
}Uprobes use BPF_PROG_TYPE_KPROBE, so probing TracePoint and Kprobe covers every section type in the collection. Alternatively (zero extra syscalls on the happy path), run the probe only in the error branch after NewCollectionWithOptions fails with errors.Is(err, unix.EINVAL) and wrap the error with the explanation.
The message-mapping can be unit-tested without root by putting the probe behind a package-level function variable and injecting one that returns ebpf.ErrNotSupported (the existing tracer_test.go tests need VM=1 + root, so a non-VM test is worthwhile here).
Also worth one line in the README / docs requirements (currently only "minimum supported Linux kernel version is 5.1"): the kernel must be built with CONFIG_BPF_EVENTS=y (kprobes and/or uprobes + perf events); some embedded/vendor kernels disable this.
Environment
- coroot-node-agent v1.35.8 (arm64), also reproduced against
mainat ee62018; run via Docker with--privileged --pid=host,/sys/kernel/tracingand/sys/fs/cgroupmounted - Kernel 5.10.120 (vendor BSP, NVIDIA L4T / JetPack 5):
CONFIG_BPF=y,CONFIG_BPF_SYSCALL=y,CONFIG_BPF_JIT=y,CONFIG_KPROBESnot set (HAVE_KPROBES=yonly),CONFIG_UPROBE_EVENTSnot set,CONFIG_BPF_EVENTSabsent,CONFIG_DEBUG_INFO_BTFnot set - The same image and flags work on a stock Ubuntu 5.15 kernel on the same architecture
Found while operating this in production; happy to send a PR if maintainers agree with the analysis.
Activity