Synthesizing safe and efficient kernel extensions for packet processing
Qiongwen Xu, Michael D. Wong, Tanvi Wagle, Srinivas Narayana, Anirudh Sivaraman
摘要
Extended Berkeley Packet Filter (BPF) has emerged as a powerful method to extend packet-processing functionality in the Linux operating system. BPF allows users to write code in high-level languages (like C or Rust) and execute them at specific hooks in the kernel, such as the network device driver. To ensure safe execution of a user-developed BPF program in kernel context, Linux uses an in-kernel static checker. The checker allows a program to execute only if it can prove that the program is crash-free, always accesses memory within safe bounds, and avoids leaking kernel data.
BPF programming is not easy. One, even modest-sized BPF programs are deemed too large to analyze and rejected by the kernel checker. Two, the kernel checker may incorrectly determine that a BPF program exhibits unsafe behaviors. Three, even small performance optimizations to BPF code (e.g., 5% gains) must be meticulously hand-crafted by expert developers. Traditional optimizing compilers for BPF are often inadequate since the kernel checker's safety constraints are incompatible with rule-based optimizations.
We present K2, a program-synthesis-based compiler that automatically optimizes BPF bytecode with formal correctness and safety guarantees. K2 produces code with 6-26% reduced size, 1.36%-55.03% lower average packet-processing latency, and 0-4.75% higher throughput (packets per second per core) relative to the best clang-compiled program, across benchmarks drawn from Cilium, Facebook, and the Linux kernel. K2 incorporates several domainspecific techniques to make synthesis practical by accelerating equivalence-checking of BPF programs by 6 orders of magnitude.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 13 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- Formal Methods for Network Performance Analysis 引用了 Switch Code Generation Using Program Synthesis
- Verified programs can party: optimizing kernel extensions via post-verification merging 引用了 Synthesizing JIT Compilers for In-Kernel DSLs
- Verified programs can party: optimizing kernel extensions via post-verification merging 引用了 Specification and verification in the field: Applying formal methods to BPF just-in-time compilers in the Linux kernel
- Verifying the Verifier: eBPF Range Analysis Verification 引用了 Synthesizing JIT Compilers for In-Kernel DSLs
- Verifying the Verifier: eBPF Range Analysis Verification 引用了 Dataflow-based pruning for speeding up superoptimization
- Verifying the Verifier: eBPF Range Analysis Verification 引用了 Specification and verification in the field: Applying formal methods to BPF just-in-time compilers in the Linux kernel
- Specification and verification in the field: Applying formal methods to BPF just-in-time compilers in the Linux kernel 引用了 Synthesizing JIT Compilers for In-Kernel DSLs
引用它的顶会 Paper13
- Verifying the Verifier: eBPF Range Analysis VerificationHarishankar Vishwanathan, Matan Shachnai, Srinivas Narayana, Santosh NagarakatteCAV 2023 · 37 次引用
- Formal Methods for Network Performance AnalysisMina Tahmasbi Arashloo, Ryan Beckett, Rachit AgarwalNSDI 2023 · 27 次引用
- LiteFlow: towards high-performance adaptive neural networks for kernel datapathJunxue Zhang, Chaoliang Zeng, Hong Zhang, Shuihai Hu 等SIGCOMM 2022 · 23 次引用
- Verified programs can party: optimizing kernel extensions via post-verification mergingHsuan-Chi Kuo, Kai-Hsun Chen, Yicheng Lu, Dan Williams 等EuroSys 2022 · 17 次引用
- Meissa: scalable network testing for programmable data planesNaiqian Zheng, Mengqi Liu, Ennan Zhai, Hongqiang Harry Liu 等SIGCOMM 2022 · 17 次引用
它引用的 Paper5
- Specification and verification in the field: Applying formal methods to BPF just-in-time compilers in the Linux kernelLuke Nelson, Jacob Van Geffen, Emina Torlak, Xi WangOSDI 2020 · 72 次引用
- Switch Code Generation Using Program SynthesisXiangyu Gao, Taegyun Kim, Michael D. Wong, Divya Raghunathan 等SIGCOMM 2020 · 51 次引用
- Reconciling enumerative and deductive program synthesisKangjing Huang, Xiaokang Qiu, Peiyuan Shen, Yanjun WangPLDI 2020 · 46 次引用
- Synthesizing JIT Compilers for In-Kernel DSLsJacob Van Geffen, Luke Nelson, Isil Dillig, Xi Wang 等CAV 2020 · 27 次引用
- Dataflow-based pruning for speeding up superoptimizationManasij Mukherjee, Pranav Kant, Zhengyang Liu, John RegehrOOPSLA 2020 · 21 次引用
相关 Paper
- EPSO: A Caching-Based Efficient Superoptimizer for BPF BytecodeQian Zhu, Yuxuan Liu, Ziyuan Zhu, Shangqing Liu 等ASE 2025
- Merlin: Multi-tier Optimization of eBPF Code for Performance and CompactnessJinsong Mao, Hailun Ding, Juan Zhai, Shiqing MaASPLOS 2024 · 15 次引用
- VEP: A Two-stage Verification Toolchain for Full eBPF ProgrammabilityXiwei Wu, Yueyang Feng, Tianyi Huang, Xiaoyang Lu 等NSDI 2025 · 8 次引用
- LDBF: Deep Exploration of eBPF Runtime via LLM-Driven Program Generation and Adaptive Context OrchestrationYinhao Hu, Kaiyan Mei, Zeyu Sun, Quan Sun 等CCS 2026
- Rex: Closing the language-verifier gap with safe and usable kernel extensionsJinghao Jia, Ruowen Qin, Milo Craun, Egor Lukiyanov 等USENIX ATC 2025 · 11 次引用
