eBPF lets you run your own small programs inside the Linux kernel, safely, without recompiling it or loading a module. This module is for the system administrator who wants three things: to understand what an eBPF program is and how the kernel controls it, to trace a machine live to diagnose an incident, and to harden a server so that this power does not become an entry point. Eleven lessons, all tested on a virtual machine: a kernel program cannot be tested in a container, which shares the host kernel. Three of them end with a lab to replay on a VM.
What you will learn
- Explain what an eBPF program is, where it attaches and how the kernel checks it
- Trace a system live with bpftrace and the ready-made BCC tools
- Measure the attack surface that eBPF adds to a server
- Harden a server: sysctl, capabilities, inventory of the loaded programs
- Locate the eBPF tools of Kubernetes, which live in other courses
What is eBPF, in two minutes?
eBPF (extended Berkeley Packet Filter) is a virtual machine built into the Linux kernel. It runs programs triggered by kernel events: a system call, a network packet arriving, a kernel function executing. The program reads what happens, acts, then returns a result, all without leaving the kernel.
Three properties make it a technology of its own. Verification: before loading, a kernel component, the verifier, proves that the program can neither loop forever nor read forbidden memory, otherwise it is rejected. No instrumentation: eBPF observes the system from outside the observed code, without modifying the application or installing an agent in a container. Performance: the program runs where the event happens, without costly round trips to user space.
Why does this module come after the internals?
This module is a deeper dive, placed outside the three levels of the Linux course, after the lessons on the internal mechanisms of the kernel. The three it assumes you know are cgroups, which group and limit processes, namespaces, which isolate what a process sees, and capabilities, which split up the powers of root.
The reason is practical. The eBPF programs of systemd attach to cgroups, security tools decide by namespace and by container, and the CAP_BPF capability is one of the levers of hardening. Without these three notions, the bpftool outputs and the recommendations of the last part remain formulas to copy. The hardening part also builds on the lesson Hardening a server with sysctl, which sets the kernel parameters that the module takes up again.
The thread of the eleven lessons
The module follows a progression in three stages, from the mental model to usage, then to risk. The module is fully translated, and each lesson is linked below.
Understand lays the foundation. The lesson What is eBPF gives the mental model and the program types. Writing and loading your first program checks that your kernel supports eBPF, then shows the full cycle on a machine. The maps explain how the kernel and user space exchange data, and the verifier how to read a rejection. The lesson CO-RE and BTF makes a program portable; it is optional for an administrator, because it mostly serves those who develop tools.
Trace puts eBPF to work for diagnosis. The bpftrace lesson answers "what is my machine doing right now?" in one line and presents the ready-made BCC tools (execsnoop, opensnoop, biolatency). The BCC and libbpf lesson shows how to build your own tools; it is also optional.
Harden covers the flip side. The attack surface of eBPF, eBPF rootkits and their detection with bpftool, then hardening eBPF itself: who may load a program, with which capabilities, and how to audit what is running.
Where should you start?
The path depends on your need, and the module gets harder as it goes: nobody needs to read everything at once.
If the subject is new, follow the order of the module starting with What is eBPF. If you simply want to see eBPF work without writing a line of C, the gentlest route is bpftrace, which is enough to diagnose a slow machine. If your concern is server security, read the attack surface lesson first, then the hardening one: these lessons only assume you know what an eBPF program is.
Where do the eBPF tools of Kubernetes live?
eBPF is the common building block under several tools that this module does not cover, because they belong to other courses. Finding them in the right place avoids duplicating their guides.
For networking, Cilium is the CNI (the network layer of a Kubernetes cluster) that largely replaces iptables with eBPF; its observability comes with Hubble, and the Kubernetes course carries them (not yet translated). For runtime security, Falco and Tracee detect a suspicious action, Tetragon blocks it directly in the kernel, and a Falco versus Tetragon comparison runs both on the same cluster (Tracee, Tetragon and the comparison are not yet translated).
For observability in Kubernetes, Inspektor Gadget ties the traced events to pods (not yet translated). Continuous profiling with eBPF (Parca, Pyroscope), which keeps a history of CPU usage, also belongs to observability and stays outside this module: bpftrace serves one-off investigation, these tools permanent monitoring.
Quick glossary
The same words come back from one lesson to the next. Here are their short definitions, to keep at hand; each term is developed in its dedicated lesson.
| Term | Short definition |
|---|---|
| eBPF | Kernel virtual machine that runs your small programs, triggered by events. |
| bytecode | The intermediate format, specific to eBPF, into which your C is compiled before verification. |
| hook | The trigger point where a program attaches (see kprobe, tracepoint, uprobe, XDP). |
| kprobe / tracepoint | Attachment to a kernel function (kprobe, dynamic) or to a stable observation point (tracepoint). |
| uprobe | Attachment to a function of a program in user space, not of the kernel. |
| helper | Function that the kernel makes available to eBPF programs (read a process name, write to a map...). |
| map | Kernel data structure shared with user space: the memory and the voice of the program. |
| verifier | Kernel component that proves a program is safe before loading it, otherwise it rejects it. |
| JIT | Compiler that translates the verified bytecode into native machine code, for performance. |
| BTF | Description of the kernel types (/sys/kernel/btf/vmlinux), the map that makes portability possible. |
| CO-RE | Compile Once Run Everywhere: compile a program once and load it on different kernels. |
Key takeaways
- eBPF runs your programs in the Linux kernel, triggered by events (system call, packet, function), without a module or recompilation.
- A verifier proves that a program is safe before loading it: no infinite loop, no forbidden memory access.
- The module follows three stages: understand (foundation), trace (diagnose), harden (reduce risk).
- It assumes you know cgroups, namespaces and capabilities, and takes up the parameters of the sysctl lesson.
- CO-RE and BCC/libbpf are tool-developer skills: optional for an administrator.
- Cilium, Falco, Tetragon and continuous profiling live in other courses; eBPF is the common building block there.