Generating BPF Verifier Friendly Code with Clang
summary
Describes concrete fixes and techniques to make Clang/LLVM emit code the kernel verifier accepts: backend passes that insert intrinsics, targeted LLVM patches to avoid problematic optimizations, and hand-workarounds like a barrier variable or inline asm; notes a 1 million instruction limit and a >10,000 LOC verifier that force lean verifier models (ternary scalar ranges, path-sensitive checks). Several LLVM patches land in the latest toolchain but backporting is hard, so work continues as an ongoing arms race between LLVM optimizations and verifier rules.
AI-written summary · about
chapters (9)
- 0:00Introduction to BPF verifier issues
- 1:02BPF program workflow and verification
- 6:48Preventing verifier failures in code
- 10:45Real-world verifier failure examples
- 13:14Generating verifier-friendly code in LLVM
- 16:03Discussion on LLVM pass control
- 18:09Ongoing battle with LLVM changes
- 21:58Verifier rules and evolution
- 23:02Future of verifier-friendly coding
related talks
53mFrom Within: Compiler Testing and Validation via Compilers
18mCompiling countermeasures against fault attacks with “Tracing LLVM”
16mReconciling Optimization With Secure Compilation
59mCompiler-assisted Translation Validation
34mMaking C Less Dangerous
18mExciting new compiler flags for kernel security
38mAlice in Kernel Land: Lessons Learned From the eBPF Rabbit Hole
44mWhere are we on security features?
