sys: BPF token discovery rejects Android
Author: celltowerCreated Jul 20, 2026Updated Jul 24, 2026
Describe the bug
Starting with v0.22.0, creating BPF maps or programs on Android fails during automatic BPF token discovery. The returned error contains:
bpf token: not supported on androidAndroid builds use the Linux kernel ABI and select Go's Linux-specific source files, but platform.IsLinux currently checks runtime.GOOS == "linux". runtime.GOOS is "android", so findToken() returns before the bpf() syscall is attempted.
I expected token discovery to run on Android and fall back to creating the BPF object without a token when BPF_TOKEN_CREATE is unavailable.
The same workload reaches the kernel and works on the same device with v0.21.0.
How to reproduce
- Build an Android binary using github.com/cilium/ebpf v0.22.0.
- On a rooted Android device with BPF support, create a map or load a collection.
- Observe that creation fails with "bpf token: not supported on android" before the BPF object is passed to the kernel.
Version information
github.com/cilium/ebpf v0.22.0
Source: cilium/ebpf