Linux - eBPF
Contents_Index
- EBPF ESSENTIALS2
- KERNEL DOCUMENTATION4
- MANUAL PAGES3
- OTHER5
- GENERIC EBPF PRESENTATIONS AND ARTICLES17
- BPF INTERNALS2
- KERNEL TRACING3
- XDP12
- AF_XDP2
- BPFILTER2
- BTF3
- CBPF6
- HARDWARE OFFLOAD5
- TUTORIALS26
- EXAMPLES12
- BCC2
- IPROUTE22
- LLVM1
- LIBBPF2
- GO LIBRARIES3
- AYA3
- ZBPF1
- EUNOMIA-BPF1
- OXIDEBPF1
- BPFTOOL AND OTHER TOOLS FROM THE KERNEL TREE1
- USER SPACE EBPF6
- EBPF ON OTHER PLATFORMS1
- TESTING IN VIRTUAL ENVIRONMENTS2
- NETWORKING14
- OBSERVABILITY11
- SECURITY11
- LINUX SCHEDULER2
- TOOLS23
- THE CODE8
- DEVELOPMENT AND COMMUNITY7
- OTHER LISTS OF RESOURCES ON EBPF3
eBPF Essentials
2_ENTRIES- ebpf.io
A gateway to discover all the basics of eBPF, including a listing of the main related projects and of community resources.
- Cilium's BPF and XDP Reference Guide
In-depth documentation about most features and aspects of eBPF.
Kernel Documentation
4_ENTRIES- BPF Documentation
Index for BPF-related documentation coming with the Linux kernel.
- linux/Documentation/networking/filter.rst
eBPF specification (somewhat outdated; information should still be valid, but not exhaustive).
- BPF Design Q&A
Frequently Asked Questions on the decisions behind the BPF infrastructure.
- HOWTO interact with BPF subsystem
Frequently Asked Questions about contributing to eBPF development.
Manual Pages
3_ENTRIES- `bpf(2)`
Manual page about the
bpf()system call, used to manage BPF programs and maps from userspace. - `tc-bpf(8)`
Manual page about using BPF with tc, including example commands and samples of code.
- `bpf-helpers(7)` man page
Description of the in-kernel helper functions forming the BPF standard library.
Other
5_ENTRIES- IO Visor's Unofficial eBPF spec
Summary of eBPF syntax and operation codes.
- Jesper Dangaard Brouer's documentation
Work in progress, contributions welcome.
- Emails from David Miller to the [xdp-...
Emails from David Miller to the xdp-newbies mailing list:bpf.h and you...Contextually speaking...BPF Verifier Overview
Generic eBPF Presentations and Articles
17_ENTRIESIf you are new to eBPF, you may want to try the links described as "introductions" in this section.
- A brief introduction to XDP and eBPF
An accessible introduction providing context, history, and details about the functioning of eBPF.
- An eBPF Overview - Blog series by Adr...
An eBPF Overview - Blog series by Adrian Ratiu, covering many aspects of the eBPF infrastructure:Part 1: IntroductionPart 2: Machine & Bytecode
- Ferris Ellis's blog posts about eBPF
They have a few posts about eBPF:Part 1: Past, Present, and FuturePart 2: Syscall and Map Types
- A BPF reference guide
About BPF C and bcc Python helpers, from bcc repository.
- Making the Kernel's Networking Data Path Programmable with BPF and XDP
A set of slides covering all the basics about eBPF and XDP (mostly for network processing).
- The BSD Packet Filter
An introduction mostly covering the tracing aspects.
- BPF: tracing and more
An introduction mostly covering the tracing aspects.
- Linux BPF Superpowers
An introduction mostly covering the tracing aspects, first part with flame graphs.
- IO Visor
Also introduces IO Visor project.
- BPF -- in-kernel virtual machine
Presentation by the author of eBPF.
- Extending extended BPF
A blog post from 2014 on the development of BPF and demonstrating what can be done with it, using an example of stateful socket filtering by attaching an eBPF program to a socket.
- Greg Marsden made some documentation ...
Greg Marsden made some documentation about eBPF:A Tour of Program Types - A description of all existing hooks for BPF program types, and of their interest.BPF helper functions - A review of the kernel functions that can be called from within eBPF programs.Communicating with Userspace - How BPF communicates with userspace - BPF maps, perf events, bpf_β¦
- Linux Kernel Observability through eBPF
A blog post covering the basics of eBPF as well as code samples in Go on how to build and load a minimal eBPF program into the kernel.
- eBPF - From a Programmer's Perspective
A short paper describing the fundamentals of eBPF and how to get started with writing eBPF programs.
- Cloudflare's blog posts on eBPF
Different blog posts about networking use cases and low-level aspects of eBPF.
- Linux Extended BPF (eBPF) Tracing Tools
An in-depth collection of information around examples of performance analysis tools using eBPF. Contains also a section at the end of the page about other resources.
- Beginner's guide to eBPF
A set of live-coding talks and the accompanying code examples, introducing eBPF programming using a variety of libraries and program types.
BPF Internals
2_ENTRIES- Daniel Borkmann has made several presentations and papers covering the internals of eBPF, in particular about its use with tc.eBPF and XDP walkthrough and recent (2017) updatesAdvanced programmability and recent updates with tc's cls_bpf - Details on eBPF, its use for tunneling and encapsulation, direct packet access, and more.cls_bpf/eBPF updates since netdev 1.1 - Part of this tc workshop.On getting tc classifier fully programmable with cls_bpf - Introduction to eBPF, including several features (map management, tail calls, verifier). The full paper [is also available here](http://www.netdevconf.org/1.1/proceedings/papers/On-getting-tc-classifier-fullyβ¦
- Linux Networking Explained
Linux networking internals, with a part about eBPF.
Kernel Tracing
3_ENTRIES- Brendan Gregg's blog, and in particular Linux BPF Superpowers article.
- Full-system dynamic tracing on Linux using eBPF and bpftrace
A detailed introduction to tracing with eBPF, from listing the available trace points to running bpftrace programs.
- Meet-cute between eBPF and Kernel Tracing
Kprobes, uprobes, ftrace.
- Linux Kernel Tracing
Systemtap, Kernelshark, trace-cmd, LTTng, perf-tool, ftrace, hist-trigger, perf, function tracer, tracepoint, kprobe/uprobe, and more.
XDP
12_ENTRIES- The eXpress Data Path
A very accessible introduction to XDP, providing sample code to show how to process packets.
- All XDP details in a technical paper
All XDP details in a technical paper: The eXpress Data Path: Fast Programmable Packet Processing in the Operating System Kernel, by Toke HΓΈiland-JΓΈrgensen, Jesper Dangaard Brouer, Daniel Borkmann, John Fastabend, Tom Herbert, David Ahern and David Miller, all being essential eBPF and XDP contributors.
- BPF and XDP Reference Guide
Guide from the Cilium project.
- eXpress Data Path (XDP)
The first presentation about XDP.
- eXpress Data Path
Contains some benchmark results obtained with the mlx4 driver.
- Jesper Dangaard Brouer has several se...
Jesper Dangaard Brouer has several sets of slides describing the internals of XDP:XDP β eXpress Data Path, Intro and future use-cases - Linux Kernel's fight against DPDK. Future plans (as of this writing) for XDP and comparison with DPDK.Network Performance Workshop - Additional hints about XDP internals and expected evolution.[XDP ββ¦
- High Speed Packet Filtering on Linux
About packet filtering on Linux, DDoS protection, packet processing in the kernel, kernel bypass, XDP and eBPF.
- How to drop 10 million packets per second
Cloudflare's blog post talking about their move to using XDP for packet filtering.
AF_XDP
2_ENTRIES- AF_XDP
Kernel documentation on the AF_XDP address family.
bpfilter
2_ENTRIES- Why is the kernel community replacing iptables with BPF?
A blog post by Cilium on the motivations behind eBPF and bpfilter, with a couple examples and links to other projects using eBPF and bpfilter.
- bpfilter: Linux firewall with eBPF sauce
Slides from a talk by Quentin Monnet with a background on eBPF and comparing bpfilter to iptables.
BTF
3_ENTRIES- BPF Type Format (BTF)
Kernel documentation about BTF, explaining how to use it.
- Enhancing the Linux kernel with BTF type information
A description of the work done with BTF to provide debugging information for BPF programs.
- What is BTF (BPF Type Format)
A community-authored newsletter enriched with useful code illustrations and hands-on examples.
cBPF
6_ENTRIES- The BSD Packet Filter: A New Architecture for User-level Packet Capture
The original paper about (classic) BPF.
- Introducing Cloudflare's BPF Tools
Usage of BPF bytecode with the
xt_bpfmodule for iptables.
Hardware Offload
5_ENTRIES- eBPF/XDP hardware offload to SmartNICs
Hardware offload for eBPF with TC or XDP (Linux kernel 4.9+), introduced by Netronome.
- Comprehensive XDP offload---Handling the edge cases
An update on the topic above.
- hBPF - eBPF in hardware
An eBPF CPU written for FPGAs.
- OpenCSD eBPF SSD offloading
Computational Storage simulation (QEMU) platform with FUSE LFS filesystem for Zoned Namespaces NVMe SSDs using uBPF for compute kernel offloading, all in userspace.
- Delilah: eBPF-offload on Computational Storage
Delilah is a Computational Storage Processor (CSP) built for eBPF offload to storage devices.
Tutorials
26_ENTRIES- bcc Reference Guide
Many incremental steps to start using bcc and eBPF, mostly centered on tracing and monitoring.
- bcc Python Developer Tutorial
Comes with bcc, but targets the Python bits across seventeen "lessons".
- Building BPF applications with libbpf-bootstrap
Helps generate minimal or advanced templates to bootstrap your own applications (kernel side and user space management for maps and programs) with features like CO-RE, global variables, and ring buffer.
- How I ended up writing opensnoop in pure C using eBPF
A thorough walk-through of how to write eBPF programs, first using only bpf() syscall, and then libbpf library, with reproducible code examples.
- Linux Tracing Workshops Materials
Involves the use of several BPF tools for tracing.
- Tracing a packet journey using Linux tracepoints, perf and eBPF
Troubleshooting ping requests and replies with perf and bcc programs.
- Open NFP platform
Operated by Netronome: some tutorials for network-related eBPF use cases, including an eBPF Offload Starting Guide.
- XDP for the Rest of Us
First edition of a workshop to get started with XDP.
- XDP for the Rest of Us
Second edition, with new contents.
- XDP Hands-On Tutorial
A progressive (three levels of difficulty) tutorial to learn how to process packets with XDP.
- All your tracing are belong to BPF
A step-by-step walkthrough to integrate tracing capabilities in your C++ applications with the LLVM libraries.
- Firewalling with BPF/XDP: Examples and Deep Dive
A simple guide to build basic firewalls with TC and XDP.
- A Deep Dive into eBPF: Writing an Efficient DNS Monitoring.
A detailed explanation of methods used to capture DNS requests at the socket filter layer.
- eBPF Developer Tutorial - Learn eBPF by examples
Start with eBPF basics and progress to advanced topics using 20+ hands-on tutorials and examples. Covers performance, networking, and security with libbpf and CO-RE. Available in Chinese and English.
- Catch Performance Regressions in eBPF
A step-by-step guide to benchmarking both the client and kernel eBPF code written in Rust.
- Loops and Iterators in eBPF
Newsletter about all the ways to loop and iterate in eBPF.
- What Insights Can eBPF Provide into Real-Time SSL/TLS Encrypted Traffic and How?
A step-by-step guide how eBPF can observe encrypted network traffic.
- Can eBPF Detect Redis Message Patterns Before They Become Problems?
A step-by-step guide how eBPF can observe Redis communication between client and server.
- Transparent Proxy Implementation using eBPF and Go
A step-by-step guide on how to implement a transparent proxy using eBPF.
- eBPF-Powered Load Balancing
Learn how eBPF can infer custom load-balancing for services listening on the same port, through the SO_REUSEPORT TCP option.
- Unit Testing eBPF Programs
Learn how you can unit test your eBPF programs using libbpf.
- Accelerating Local Socket Communication using eBPF
Learn how eBPF can speed-up local socket communication up to 30%.
- Writing a basic continuous profiler
A step-by-step guide to write an appliation continuous profiler leveraging the eBPF instrumentation, with a complete project as a reference.
- Inspektor Gadget - Hello world gadget
An introductory guide to writing image-based eBPF gadgets and sharing them via OCI registries.
- Inspektor Gadget - Hello world gadget with Wasm
An introductory guide to writing image-based eBPF gadgets and performing post-processing with WASM.
Examples
12_ENTRIES- linux/samples/bpf/
In the kernel tree: some sample eBPF programs.
- linux/tools/testing/selftests/bpf
In the kernel tree: Linux BPF selftests, with many eBPF programs.
- prototype-kernel/kernel/samples/bpf
Jesper Dangaard Brouer's prototype-kernel repository contains some additional examples that can be compiled outside of kernel infrastructure.
- iproute2/examples/bpf/
Some networking programs to attach to the TC interface.
- Netronome sample network applications
Provides basic but complete examples of eBPF applications also compatible with hardware offload.
- bcc/examples
Examples coming along with the bcc tools, mostly about tracing.
- bcc/tools
These tools themselves can be seen as example use cases for BPF programs, mostly for tracing and monitoring. bcc tools have been packaged for some Linux distributions.
- MPLSinIP sample
A heavily commented sample demonstrating how to encapsulate & decapsulate MPLS within IP. The code is commented for those new to BPF development.
- ebpf-samples
A collection of compiled (as ELF object files) samples gathered from several projects, primarily intended to serve as test cases for user space verifiers.
- ebpf-kill-example
A fully documented and tested example of an eBPF probe that logs all force-kills and prints them out in user-space.
- redbpf examples
Example programs for using RedBPF to write eBPF programs in Rust.
- XDP/TC-eBPF example
Program that uses XDP/TC-eBPF to provide statefull firewalling and socket redirection.
bcc
2_ENTRIES- bcc
Framework and set of tools - One way to handle BPF programs, in particular for tracing and monitoring. Also includes some utilities that may help inspect maps or programs on the system.
- Lua front-end for BCC
Another alternative to C, and even to most of the Python code used in bcc.
iproute2
2_ENTRIES- iproute2
Package containing tools for network management on Linux. In particular, it contains
tc, used to manage eBPF filters and actions, andip, used to manage XDP programs. Most of the code related to BPF is in lib/bpf.c. - iproute2-next
The development tree, synchronised with net-next.
LLVM
1_ENTRIES- LLVM
Contains several tools used in eBPF workflows. Snapshots of the latest versions for Ubuntu/Debian can be retrieved from here.clang is used to compile C to eBPF object file under the ELF format (clang v3.7.1+). The BPF backend was added with this commit.llvm-objdump is used to dump the content of an object file in human-readable format, possibly with the initial C source code (llvm-objdump v4.0+).llvm-mc is used to compile from LLVM interβ¦
libbpf
2_ENTRIES- libbpf
A C library used for handling BPF objects (programs and maps), and manipulating ELF object files containing them. It is shipped with the kernel and mirrored on GitHub.
- libbpf-bootstrap
Scaffolding for BPF application development with libbpf and BPF CO-RE.
Go libraries
3_ENTRIES- cilium/ebpf
Pure-Go library to read, modify and load eBPF programs and attach them to various hooks in the Linux kernel.
- libbpfgo
eBPF library for Go, powered by libbpf.
- gobpf
Go bindings for BCC for creating eBPF programs.
Aya
3_ENTRIES- aya
A pure Rust library for writing, loading, and managing eBPF objects, with a focus on developer experience and operability. It supports writing eBPF programs in Rust and distributing library code over crates.io to share it between eBPF programs. Aya does not depend on libbpf.
- aya-template
Templates for writing BPF applications in Aya that can be used with
cargo generate. - Ebpfguard
Rust library for writing Linux security policies using eBPF.
zbpf
1_ENTRIES- zbpf
A pure Zig framework for writing cross platform eBPF programs, powered by libbpf and Zig toolchain.
eunomia-bpf
1_ENTRIES- eunomia-bpf
A compilation framework and runtime library to build, distribute, dynamically load, and run CO-RE eBPF applications in multiple languages and WebAssembly. It supports writing eBPF kernel code only (to build simple CO-RE libbpf eBPF applications), writing the kernel part in both BCC and libbpf styles, and writing userspace in multiple languages in a WASM module and distributing it with simple JSON data or WASM OCI images. The runtime is based on libbpf only and provides CO-RE to BCC-style eBPF pβ¦
oxidebpf
1_ENTRIES- oxidebpf
A pure Rust library for managing eBPF programs, designed for security use cases. The featureset is more limited than other libraries but emphasizes stability across a wide range of kernels and backwards-compatible compile-once-run-most-places.
bpftool and Other Tools from the Kernel Tree
1_ENTRIES- bpftool
Also some other tools in the kernel tree, under linux/tools/net/ for versions earlier than 4.15, or linux/tools/bpf/ after that:
bpftool- A generic utility that can be used to interact with eBPF programs and maps from userspace,β¦
User Space eBPF
6_ENTRIES- uBPF
Written in C. Contains an interpreter, a JIT compiler for x86_64 architecture, an assembler and a disassembler.
- A generic implementation
With support for FreeBSD kernel, FreeBSD user space, Linux kernel, Linux user space and macOS user space. Used for the VALE software switch's BPF extension module.
- rbpf
Written in Rust. Interpreter for Linux, macOS and Windows, and JIT-compiler for x86_64 under Linux.
- PREVAIL
A user space verifier for eBPF using an abstract interpretation layer, with support for loops.
- oster
Written in Go. A tool for tracing execution of Go programs by attaching eBPF to uprobes.
- wachy
A tracing profiler that aims to make eBPF uprobe-based debugging easier to use. This is done by displaying traces in a UI next to the source code and allowing interactive drilldown analysis.
eBPF on Other Platforms
1_ENTRIES- eBPF for Windows
This project is a work-in-progress that allows using existing eBPF toolchains and APIs familiar in the Linux ecosystem to be used on top of Windows.
Testing in Virtual Environments
2_ENTRIES- A Vagrant setup
To easily test XDP. Less useful now that generic XDP (driver-independant, mostly for testing) exists.
Networking
14_ENTRIES- P4 has some interactions with eBPF
P4 has some interactions with eBPF:P4 on the Edge - P4 with eBPF to create high-performance programmable switches.OvS Orbit episode (#11), called P4 on the Edge - Related to the former item. Audio interview of John Fastabend by Ben Pfaff, one of the core maintainers of Open vSwitch.[P4, EBPF and Linux TC Offload](https://open-nfp.org/m/documents/Open_NFP_P4_EBPF_Linux_TC_Offβ¦
- Cilium
project (GitHub repository) is a technology relying on BPF and XDP to provide "fast in-kernel networking and security policy enforcement for containers based on eBPF programs generated on the fly". Many presentations available (with overlap):Cilium: Networking & Security for Containers with BPF & XDP - Also featuring a load balancer use case[Cilium: Networking & Security for Contβ¦
- Open vSwitch (OvS), and its related p...
Open vSwitch (OvS), and its related project Open Virtual Network (OVN, an open source network virtualization solution) are considering using eBPF at various level:Offloading OVS Flow Processing using eBPFCoupling the Flexibility of OVN with the Efficiency of IOVisor
- Katran
A layer 4 load-balancer based on XDP, open-sourced by Facebook.
- XDP in practice: integrating XDP in our DDoS mitigation pipeline
Protection against DDoS with XDP at Cloudflare.
- Droplet: DDoS countermeasures powered by BPF + XDP
Protection against DDoS with XDP at Facebook.
- CETH for XDP
Common Ethernet Driver Framework for faster network I/O, a technology initiated by Mellanox.
- Suricata, an open source intrusion de...
Suricata, an open source intrusion detection system, relies on eBPF components for its "capture bypass" features:"eBPF and XDP" section of Suricata documentationSEPTun-Mark-II - Extreme Performance Tuning guide - Mark II.[A blog post introducing the feature](https://www.stamus-netwoβ¦
- Project Calico
Calico is an open source networking and network security solution for containers, virtual machines, and native host-based workloads. Calico's eBPF data plane delivers a low latency, high throughput data plane with a rich network security policy model.Enabling eBPF data plane with Calico
- merbridge
Use eBPF to speed up your Service Mesh. Merbridge replaces iptables rules with eBPF to intercept traffic. It also combines msg_redirect to reduce latency with a shortened datapath between sidecars and services.
- PcapPlusPlus
An open-source C++ library for capturing, parsing and crafting network packets. It features a C++ interface for creating AF_XDP sockets, making it easy to send and receive packets through them.
- ApFree WiFiDog
A high performance and lightweight captive portal solution for wireless networks. It leverages eBPF for traffic control and deep packet inspection capabilities, with plans to gradually replace nftables firewall functionality with eBPF-based solutions.
- ipx_wrap
A proof-of-concept IPX implementation for Linux using eBPF.
Observability
11_ENTRIES- DEEP-mon
Helps with measuring power consumption for servers and uses eBPF programs for in-kernel aggregation of data.
- pixie
Observability for Kubernetes using eBPF. Features include protocol tracing, application profiling, and support for distributed bpftrace deployments.
- SkyWalking Rover
Apache SkyWalking is an open-source Application Performance Monitoring (APM) platform specially designed for distributed systems with microservices, cloud-native and container-based (Kubernetes) architectures. SkyWalking Rover is an eBPF-based profiler and metrics collector for C, C++, Golang, and Rust applications.
- parca-agent
eBPF based always-on continuous profiler for analysis of CPU and memory usage, down to the line number and throughout time.
- rbperf
Sampling profiler and tracer for Ruby.
- Hubble
Network, service and security observability for Kubernetes using eBPF.
- Caretta
Instant Kubernetes service dependency map generated by eBPF, right to a Grafana instance.
- DeepFlow
Instant observability for cloud-native and AI applications based on eBPF.
- Coroot
Coroot is an open-source APM & Observability tool, a DataDog and NewRelic alternative.
- kyanos
Kyanos is an eBPF-based network issue analysis tool that enables you to capture network requests, such as HTTP, Redis, and MySQL requests.
Security
11_ENTRIES- Falco
A cloud-native runtime security project used as a Kubernetes threat detection engine.
- Sysmon for Linux
A security monitoring tool. It depends on SysinternalsEBPF.
- Red Canary Linux Agent
Red Canary has started to incorporate eBPF to their Linux security sensor.
- Tracee
A runtime security and forensics tool for Linux which uses eBPF technology to trace the system and applications at runtime, and analyze collected events to detect suspicious behavioral patterns.
- redcanary-ebpf-sensor
A set of BPF programs that gather security relevant event data from the Linux kernel. The BPF programs are combined into a single ELF file from which individual probes can be selectively loaded, depending on the running operating system and kernel version.
- bpflock - Lock Linux machines
An eBPF driven security tool for locking and auditing Linux machines.
- Tetragon
Kubernetes-aware, eBPF-based security observability and runtime enforcement.
- harpoon
Trace syscalls from user-space functions, by using eBPF.
- Synapse
Extended detection and response (XDR) with eBPF-powered firewall and proxy, to protect your Linux servers.
- BPFJailer
BpfJailer is an eBPF-based process jailing system that provides mandatory access control (MAC) for Linux.
Linux Scheduler
2_ENTRIESTools
23_ENTRIES- ply
A small but flexible open source dynamic tracer for Linux, with features similar to the bcc tools, but with a simpler language inspired by awk and DTrace.
- bpftrace
A tool for tracing with its own high-level tracing language. It is flexible enough to be envisioned as a Linux replacement for DTrace and SystemTap.bpftrace Cheat Sheet - Summary and cheat sheet for programming in bpftrace. Contains information about syntax, probe types, variables and functions.
- kubectl trace
A kubectl plug-in for executing bpftrace programs in a Kubernetes cluster.
- inspektor-gadget
A collection tools and framework for data collection and system inspection on Kubernetes clusters and Linux hosts using eBPF.
- bpfd
Framework for running BPF programs with rules on Linux as a daemon. Container aware.
- BPFd
A distinct BPF daemon, trying to leverage the flexibility of the bcc tools to trace and debug remote targets, and in particular devices running with Android.
- adeb
A Linux shell environment for using tracing tools on Android with BPFd.
- greggd
System daemon to compile and load eBPF programs into the kernel, and forward program output to socket for metric aggregation.
- FUSE
Considers using eBPF.
- upf-bpf
An in-kernel solution based on XDP for 5G UPF.
- redbpf
Tooling and framework to write eBPF code in Rust efficiently.
- ebpf-explorer
A web interface to explore system's maps and programs.
- ebpfmon
A TUI (terminal user interface) application for real time monitoring of eBPF programs.
- bpfman
An eBPF Manager for Linux and Kubernetes. Includes a built-in program loader that supports program cooperation for XDP and TC programs, as well as deployment of eBPF programs from OCI images.
- ptcpdump
A process-aware, eBPF-based tcpdump-like tool.
- oryx
A TUI for sniffing network traffic using eBPF on Linux.
- Embrace The Red: Offensive BPF!
A series of posts around the introduction into BPF with a focus to an offensive setting, and also how its misuse can be detected. Posts include discussions on the rootkit capabilities of eBPF, or on which tracing type is needed for different use cases.
- eBPF: Block Linux Fileless Payload "Malware" Execution with BPF LSM
Blog post about how BPF can help detection and blocking fileless malware.
- Blackhat 2021: With Friends Like eBPF, Who Needs Enemies?
Talk about an eBPF rootkit and how the capabilities of eBPF could be abused. The rootkit was also the object of a talk at Defcon, eBPF, I thought we were friends !.
- ebpfkit
A rootkit that leverages multiple eBPF features to implement offensive security techniques.
- ebpfkit-monitor
An utility to statically analyze eBPF bytecode or monitor suspicious eBPF activity at runtime. It was specifically designed to detect ebpfkit.
- Bad BPF
A collection of malicious eBPF programs that make use of eBPF's ability to read and write user data in between the usermode program and the kernel.
- TripleCross
A Linux eBPF rootkit with a backdoor, C2, library injection, execution hijacking, persistence and stealth capabilities.
The Code
8_ENTRIES- The JIT compilers are under the directory of their respective architectures, such as file linux/arch/x86/net/bpf_jit_comp.c for x86. Exception is made for JIT compilers used for hardware offload, sitting in their drivers, such as linux/drivers/net/ethernet/netronome/nfp/bpf/jit.c for Netronome NFP.
- linux/include/linux/bpf.h
with linux/include/uapi/bpf.h: definitions related to eBPF, to be used respectively in the kernel and to interface with userspace programs.
- linux/include/linux/filter.h
with linux/include/uapi/filter.h: information used to run the BPF programs themselves.
- linux/kernel/bpf/
This directory contains most of BPF-related code. In particular, those files are worth of interest:
syscall.c- Different operations permitted by the system call, such as program loading or map management.core.c- BPF interpreter.[verifier.c](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux⦠- linux/net/core/filter.c
Functions and eBPF helpers related to networking (TC, XDP etc.); also contains the code to migrate cBPF bytecode to eBPF (all cBPF programs are translated to eBPF in recent kernels).
- linux/kernel/trace/bpf_trace.c
Functions and eBPF helpers related to tracing and monitoring (kprobes, tracepoints, etc.).
- linux/net/sched/
and in particular in files
act_bpf.c(action) andcls_bpf.c(filter): code related to BPF actions and filters with TC. - linux/net/core/dev.c
contains the function
dev_change_xdp_fd()that is called through a Netlink command to hook a XDP program to a device, after is has been loaded into the kernel from user space. This function in turns uses a callback from the relevant driver.
Development and Community
7_ENTRIES- The bpf-next tree
BPF patches land in this tree. It is regularly merged into net-next, which is itself merged for each release to Linus' tree.
- Kernel documentation
About contributions to BPF.
- The netdev mailing list
Mailing list for Linux kernel networking stack development. All patches are sent there for review and inclusion.
- XDP-newbies
A mailing list specially dedicated to XDP programming (both for architecture or for asking for help).
- IO Visor mailing list
BPF is at the heart of the project, and is regularly discussed on the mailing list.
- The XDP Collaboration Project
A GitHub repository with notes and ideas regarding the future evolutions of XDP.