Software:eBPF

From HandWiki
Revision as of 13:09, 9 February 2024 by Dennis Ross (talk | contribs) (linkage)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Short description: Safe dynamic programs and tools

eBPF
EBPF logo.png
Original author(s)Alexei Starovoitov,
Daniel Borkmann[1][2]
Developer(s)Open source community, Meta, Google, Isovalent, Microsoft, Netflix[1]
Initial release2014; 10 years ago (2014)[3]
RepositoryLinux: git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
Windows: github.com/Microsoft/ebpf-for-windows/
Written inC
Operating systemLinux, Windows[4]
TypeRuntime system
LicenseLinux: GPL
Windows: MIT License
Websiteebpf.io

eBPF (extended Berkeley Packet Filter)[5] is a technology that can run programs in a privileged context such as the operating system kernel.[6] It is the successor to the Berkeley Packet Filter (BPF) filtering mechanism in Linux, and is also used in other parts of the Linux kernel as well.

It is used to safely and efficiently extend the capabilities of the kernel at runtime without requiring changes to kernel source code or loading kernel modules.[7] Safety is provided through an in-kernel verifier which performs static code analysis and rejects programs which crash, hang or otherwise interfere with the kernel negatively.[8][9]

This validation model differs from sandboxed environments, where the execution environment is restricted and the runtime has no insight about the program.[10] Examples of programs that are automatically rejected are programs without strong exit guarantees (i.e. for/while loops without exit conditions) and programs dereferencing pointers without safety checks.[11]

Design

Loaded programs which passed the verifier are either interpreted or in-kernel just-in-time compiled (JIT compiled) for native execution performance. The execution model is event-driven and with few exceptions run-to-completion,[2] meaning, programs can be attached to various hook points in the operating system kernel and are run upon triggering of an event. eBPF use cases include (but are not limited to) networking such as XDP, tracing and security subsystems.[6] Given eBPF's efficiency and flexibility opened up new possibilities to solve production issues, Brendan Gregg famously dubbed eBPF "superpowers for Linux".[12] Linus Torvalds said, "BPF has actually been really useful, and the real power of it is how it allows people to do specialized code that isn't enabled until asked for".[13] Due to its success in Linux, the eBPF runtime has been ported to other operating systems such as Windows.[4]

History

eBPF was built on top of the Berkeley Packet Filter (cBPF). At the lowest level, it introduced the use of ten 64-bit registers (instead of two 32-bit long registers for cBPF), different jump semantics, a call instruction and corresponding register passing convention, new instructions, and a different encoding for these instructions.[14]

Most significant milestones in the evolution of eBPF
Date Event
April 2011 The first in-kernel Linux just-in-time compiler (JIT compiler) for the classic Berkeley Packet Filter got merged.[15]
January 2012 The first non-networking use case of the classic Berkeley Packet Filter, seccomp-bpf,[16] appeared; it allows filtering of system calls using a configurable policy implemented through BPF instructions.
March 2014 David S. Miller, primary maintainer of the Linux networking stack, accepted the rework of the old in-kernel BPF interpreter. It was replaced by an eBPF interpreter and the Linux kernel internally translates classic BPF (cBPF) into eBPF instructions.[17]
March 2015 The ability to attach eBPF to kprobes as first tracing use case was merged.[19] In the same month, initial infrastructure work got accepted to attach eBPF to the networking traffic control (tc) layer allowing to attach eBPF to the core ingress and later also egress paths of the network stack, later heavily used by projects such as Cilium.[20][21][22]
August 2015 The eBPF compiler backend got merged into LLVM 3.7.0 release.[23]
September 2015 Brendan Gregg announced a collection of new eBPF-based tracing tools as the bcc project, providing a front-end for eBPF to make it easier to write programs.[24]
July 2016 eBPF got the ability to be attached into network driver's core receive path. This layer is known today as eXpress DataPath (XDP) and was added as a response to DPDK to create a fast data path which works in combination with the Linux kernel rather than bypassing it.[25][26][27]
August 2016 Cilium was initially announced during LinuxCon as a project providing fast IPv6 container networking with eBPF and XDP. Today, Cilium has been adopted by major cloud provider's Kubernetes offerings and is one of the most widely used CNIs.[28][22][29]
November 2016 Netronome added offload of eBPF programs for XDP and tc BPF layer to their NIC.[30]
May 2017 Meta's layer 4 load-balancer, Katran, went live. Every packet towards facebook.com since then has been processed by eBPF & XDP.[31]
November 2017 eBPF becomes its own kernel subsystem to ease the continuously growing kernel patch management. The first pull request by eBPF maintainers was submitted.[32]
September 2017 Bpftool was added to the Linux kernel as a user space utility to introspect the eBPF subsystem.[33]
January 2018 A new socket family called AF_XDP was published, allowing for high performance packet processing with zero-copy semantics at the XDP layer.[34] Today, DPDK has an official AF_XDP poll-mode driver support.[35]
February 2018 The bpfilter prototype has been published, allowing translation of a subset of iptables rulesets into eBPF via a newly developed user mode driver. The work has caused controversies due to the ongoing nftables development effort and has not been merged into mainline.[36][37]
October 2018 The new bpftrace tool has been announced by Brendan Gregg as DTrace 2.0 for Linux.[38]
November 2018 eBPF introspection has been added for kTLS in order to support the ability for in-kernel TLS policy enforcement.[39]
November 2018 BTF (BPF Type Format) has been added to the Linux kernel as an efficient meta data format which is approximately 100x smaller in size than DWARF.[40]
December 2019 The first 880-page long book on BPF, written by Brendan Gregg, was released.[41]
March 2020 Google upstreamed BPF LSM support into the Linux kernel, enabling programmable Linux Security Modules (LSMs) through eBPF.[42]
September 2020 The eBPF compiler backend for GNU Compiler Collection (GCC) was merged.[43]

Branding

The alias eBPF is often interchangeably used with BPF,[2][44] for example by the Linux kernel community. eBPF and BPF is referred to as a technology name like LLVM.[2] eBPF evolved from the Berkeley Packet Filter as an extended version, but its use case outgrew networking, and today eBPF as a pseudo-acronym is preferred.[2]

The bee is the official logo for eBPF. At the first eBPF Summit there was a vote taken and the bee mascot was named "eBee".[45][46] The logo has originally been created by Vadim Shchekoldin.[46] Earlier unofficial eBPF mascots have existed in the past,[47] but haven't seen widespread adoption.

Governance

The eBPF Foundation was created in August 2021 with the goal to expand the contributions being made to extend the powerful capabilities of eBPF and grow beyond Linux.[1] Founding members include Meta, Google, Isovalent, Microsoft and Netflix. The purpose is to raise, budget and spend funds in support of various open source, open data and/or open standards projects relating to eBPF technologies[48] to further drive the growth and adoption of the eBPF ecosystem. Since inception, Red Hat, Huawei, Crowdstrike, Tigera, DaoCloud, Datoms, FutureWei also joined.[49]

Adoption

eBPF has been adopted by a number of large-scale production users, for example:

Security

Due to the ease of programmability, eBPF has been used as a tool for implementing microarchitectural timing side-channel attacks such as Spectre against vulnerable microprocessors.[84] While unprivileged eBPF implemented mitigations against transient execution attacks,[85] unprivileged use has ultimately been disabled by the kernel community by default to protect from use against future hardware vulnerabilities.[86]

See also

References

  1. 1.0 1.1 1.2 "Meta, Google, Isovalent, Microsoft and Netflix Launch eBPF Foundation as Part of the Linux Foundation". 12 August 2021. https://www.linuxfoundation.org/press-release/facebook-google-isovalent-microsoft-and-netflix-launch-ebpf-foundation-as-part-of-the-linux-foundation/. 
  2. 2.0 2.1 2.2 2.3 2.4 "BPF Internals". 1 June 2021. https://www.usenix.org/conference/lisa21/presentation/gregg-bpf. 
  3. "eBPF and Kubernetes: Little Helper Minions for Scaling Microservices". 19 August 2020. https://kccnceu20.sched.com/event/ZemQ/ebpf-and-kubernetes-little-helper-minions-for-scaling-microservices-daniel-borkmann-cilium. 
  4. 4.0 4.1 "Making eBPF work on Windows". 10 May 2021. https://cloudblogs.microsoft.com/opensource/2021/05/10/making-ebpf-work-on-windows/. 
  5. https://youtube.com/clip/Ugkx_8EhQMmQeowTvS13ziMIL7GEOdM0xxzz?si=8Vtw9_seGUNHSUOq
  6. 6.0 6.1 "eBPF Documentation: What is eBPF?". https://ebpf.io/what-is-ebpf. 
  7. "eBPF - Rethinking the Linux Kernel". https://www.infoq.com/presentations/facebook-google-bpf-linux-kernel/. 
  8. "Safe Programs The Foundation of BPF.". 8 November 2020. https://www.youtube.com/watch?v=AV8xY318rtc. 
  9. "BPF and Spectre: Mitigating transient execution attacks". 22 January 2022. https://popl22.sigplan.org/details/prisc-2022-papers/11/BPF-and-Spectre-Mitigating-transient-execution-attacks. 
  10. "eBPF - The Silent Platform Revolution from Cloud Native". 10 September 2023. https://conferences.sigcomm.org/sigcomm/2023/files/workshop-ebpf/1-CloudNative.pdf#page=20. 
  11. Hedam, Niclas (26 May 2023). "eBPF - From a Programmer's Perspective" (in en). doi:10.13140/RG.2.2.33688.11529/4. https://hed.am/papers/2021-EBPF.pdf. 
  12. "Linux BPF Superpowers". 5 March 2016. https://www.brendangregg.com/blog/2016-03-05/linux-bpf-superpowers.html. 
  13. "Linus Torvalds talks about coming back to work on Linux". 23 October 2018. https://www.zdnet.com/article/linus-torvalds-talks-about-coming-back-to-work-on-linux/. 
  14. "Classic BPF vs eBPF". March 2014. https://www.kernel.org/doc/html/v6.1/bpf/classic_vs_extended.html. 
  15. "net: filter: Just In Time compiler". April 2011. https://lore.kernel.org/netdev/1301838968.2837.200.camel@edumazet-laptop/. 
  16. "Yet another new approach to seccomp". 1 January 2012. https://lwn.net/Articles/475043/. 
  17. "BPF updates". March 2014. https://lore.kernel.org/netdev/1396029506-16776-1-git-send-email-dborkman@redhat.com/. 
  18. "Happy birthday BPF!". September 2014. https://lore.kernel.org/bpf/20210926203409.kn3gzz2eaodflels@ast-mbp.dhcp.thefacebook.com/. 
  19. "tracing: attach eBPF programs to kprobes". March 2015. https://lore.kernel.org/netdev/1425252465-27527-1-git-send-email-ast@plumgrid.com/. 
  20. "eBPF support for cls_bpf". March 2015. https://lore.kernel.org/netdev/cover.1425208501.git.daniel@iogearbox.net/. 
  21. "net, sched: add clsact qdisc". January 2016. https://lore.kernel.org/netdev/61198814638d88ce3555dbecf8ef875523b95743.1452197856.git.daniel@iogearbox.net/. 
  22. 22.0 22.1 "eBPF-based Networking, Observability, Security". January 2016. https://cilium.io/. 
  23. "LLVM 3.7 Release Notes". August 2015. https://releases.llvm.org/3.7.0/docs/ReleaseNotes.html#non-comprehensive-list-of-changes-in-this-release. 
  24. "bcc: Taming Linux 4.3+ Tracing Superpowers". September 2015. https://www.brendangregg.com/blog/2015-09-22/bcc-linux-4.3-tracing.html. 
  25. "Add driver bpf hook for early packet drop and forwarding". July 2016. https://lore.kernel.org/netdev/1468955817-10604-1-git-send-email-bblanco@plumgrid.com/. 
  26. "eCHO episode 9: XDP and Load Balancing". June 2021. https://www.youtube.com/watch?v=OIyPm6K4ooY. 
  27. Høiland-Jørgensen, Toke; Brouer, Jesper Dangaard; Borkmann, Daniel; Fastabend, John; Herbert, Tom; Ahern, David; Miller, David (December 2018). "The eXpress data path: Fast programmable packet processing in the operating system kernel". pp. 54–66. doi:10.1145/3281411.3281443. ISBN 9781450360807. https://dl.acm.org/doi/pdf/10.1145/3281411.3281443. Retrieved 1 July 2022. 
  28. "Cilium - Fast IPv6 Container Networking with BPF and XDP". August 2016. https://www.slideshare.net/ThomasGraf5/cilium-fast-ipv6-container-networking-with-bpf-and-xdp. 
  29. 29.0 29.1 "New GKE Dataplane V2 increases security and visibility for containers". May 2021. https://cloud.google.com/blog/products/containers-kubernetes/bringing-ebpf-and-cilium-to-google-kubernetes-engine. 
  30. "nfp ring reconfiguration and XDP support". November 2016. https://lore.kernel.org/netdev/1478193129-23476-1-git-send-email-jakub.kicinski@netronome.com/. 
  31. 31.0 31.1 "XDP 1.5 Years In Production. Evolution and Lessons Learned.". November 2018. https://lpc.events/event/2/contributions/109/. 
  32. "pull-request: bpf 2017-11-23". November 2017. https://lore.kernel.org/netdev/20171123120135.8371-1-daniel@iogearbox.net/. 
  33. "tools: add bpftool". September 2017. https://lore.kernel.org/netdev/20170926153522.31500-1-jakub.kicinski@netronome.com/. 
  34. "Introducing AF_XDP support". January 2018. https://lore.kernel.org/netdev/20180131135356.19134-1-bjorn.topel@gmail.com/. 
  35. "AF_XDP Poll Mode Driver". August 2022. https://doc.dpdk.org/guides/nics/af_xdp.html. 
  36. "BPF comes to firewalls". February 2018. https://lwn.net/Articles/747551/. 
  37. "Why is the kernel community replacing iptables with BPF?". April 2018. https://cilium.io/blog/2018/04/17/why-is-the-kernel-community-replacing-iptables/. 
  38. "bpftrace (DTrace 2.0) for Linux 2018". October 2018. https://www.brendangregg.com/blog/2018-10-08/dtrace-for-linux-2018.html. 
  39. "Combining kTLS and BPF for Introspection and Policy Enforcement". November 2018. http://vger.kernel.org/lpc_net2018_talks/ktls_bpf.pdf. 
  40. "BTF deduplication and Linux kernel BTF". November 2018. https://nakryiko.com/posts/btf-dedup/. 
  41. "BPF Performance Tools (book)". December 2019. https://www.brendangregg.com/bpf-performance-tools-book.html. 
  42. "MAC and Audit policy using eBPF (KRSI)". March 2020. https://lore.kernel.org/bpf/20200329004356.27286-1-kpsingh@chromium.org/. 
  43. "BPF in GCC". September 2020. https://lwn.net/Articles/831402/. 
  44. Brendan Gregg (December 2019). BPF Performance Tools. Addison-Wesley. ISBN 978-0136554820. 
  45. "eBPF Summit Day Two". October 2020. https://cilium.io/blog/2020/10/29/ebpf-summit-day-2. 
  46. 46.0 46.1 "What is the bee named?". https://ebpf.io/what-is-ebpf#what-is-the-bee-named. 
  47. "eBPF: One Small Step". May 2015. https://www.brendangregg.com/blog/2015-05-15/ebpf-one-small-step.html. 
  48. "eBPF Foundation Charter". June 2021. https://ebpf.foundation/charter/. 
  49. "eBPF Foundation Governance". August 2022. https://ebpf.foundation/governance/. 
  50. "Open-sourcing Katran, a scalable network load balancer". May 2018. https://engineering.fb.com/2018/05/22/open-source/open-sourcing-katran-a-scalable-network-load-balancer/. 
  51. "BPF at Facebook". December 2019. https://www.youtube.com/watch?v=ZYBXZFKPS28. 
  52. "From XDP to socket". September 2021. https://lpc.events/event/11/contributions/950/. 
  53. "eCHO episode 29: BPF LSM with KP Singh". November 2021. https://www.youtube.com/watch?v=OBFYMBHrstI. 
  54. "BPF security auditing at Google - Brendan Jackman/KP Singh". November 2021. https://www.youtube.com/watch?v=URm_q9ylxBk. 
  55. "Replacing HTB with EDT and BPF". July 2020. https://legacy.netdevconf.info/0x14/session.html?talk-replacing-HTB-with-EDT-and-BPF. 
  56. "Cloudflare architecture and how BPF eats the world". May 2019. https://blog.cloudflare.com/cloudflare-architecture-and-how-bpf-eats-the-world/. 
  57. "It's crowded in here!". October 2019. https://blog.cloudflare.com/its-crowded-in-here/. 
  58. "Production ready eBPF, or how we fixed the BSD socket API". February 2022. https://blog.cloudflare.com/tubular-fixing-the-socket-api-with-ebpf/. 
  59. "Live-patching security vulnerabilities inside the Linux kernel with eBPF Linux Security Module". June 2022. https://blog.cloudflare.com/live-patch-security-vulnerabilities-with-ebpf-lsm/. 
  60. "Unimog - Cloudflare's edge load balancer". September 2020. https://blog.cloudflare.com/unimog-cloudflares-edge-load-balancer/. 
  61. "How Netflix uses eBPF flow logs at scale for network insight". June 2021. https://netflixtechblog.com/how-netflix-uses-ebpf-flow-logs-at-scale-for-network-insight-e3ea997dca96. 
  62. "Extending Vector with eBPF to inspect host and container performance". February 2019. https://netflixtechblog.com/extending-vector-with-ebpf-to-inspect-host-and-container-performance-5da3af4c584b. 
  63. "Dropbox traffic infrastructure: Edge network". October 2018. https://dropbox.tech/infrastructure/dropbox-traffic-infrastructure-edge-network. 
  64. "eBPF Traffic Monitoring". August 2022. https://source.android.com/docs/core/datausage/ebpf-traffic-monitor. 
  65. "Extending the Kernel with eBPF". August 2022. https://source.android.com/docs/core/architecture/kernel/bpf. 
  66. "NAT46 translation with BPF". April 2022. https://lore.kernel.org/bpf/20220407084727.10241-1-lina.wang@mediatek.com/. 
  67. "How Does Alibaba Cloud Build High-Performance Cloud-Native Pod Networks in Production Environments?". September 2020. https://www.alibabacloud.com/blog/how-does-alibaba-cloud-build-high-performance-cloud-native-pod-networks-in-production-environments_596590. 
  68. "Datadog on eBPF". February 2021. https://datadogon.datadoghq.com/episodes/datadog-on-ebpf/. 
  69. "Runtime Security Monitoring with eBPF". February 2021. https://www.sstic.org/media/SSTIC2021/SSTIC-actes/runtime_security_with_ebpf/SSTIC2021-Article-runtime_security_with_ebpf-fournier_afchain_baubeau.pdf. 
  70. "Our eBPF Journey at Datadog - Laurent Bernaille & Tabitha Sable, Datadog". November 2020. https://www.youtube.com/watch?v=6mTVuZUHLBg. 
  71. "User Story - How Trip.com uses Cilium". February 2020. https://cilium.io/blog/2020/02/05/how-trip-com-uses-cilium/. 
  72. "Trip.com: Stepping into Cloud Native Networking Era with Cilium+BGP". November 2020. https://arthurchiao.art/blog/trip-stepping-into-cloud-native-networking-era/. 
  73. "Making eBPF work on Windows". May 2021. https://cloudblogs.microsoft.com/opensource/2021/05/10/making-ebpf-work-on-windows/. 
  74. "Getting Linux based eBPF programs to run with eBPF for Windows". February 2022. https://cloudblogs.microsoft.com/opensource/2022/02/22/getting-linux-based-ebpf-programs-to-run-with-ebpf-for-windows/. 
  75. "Progress on making eBPF work on Windows". November 2019. https://cloudblogs.microsoft.com/opensource/2021/11/29/progress-on-making-ebpf-work-on-windows/. 
  76. "Cilium Standalone Layer 4 Load Balancer XDP". July 2022. https://cilium.io/blog/2022/04/12/cilium-standalone-L4LB-XDP/. 
  77. "Building a Secure and Maintainable PaaS - Bradley Whitfield, Capital One". November 2020. https://www.youtube.com/watch?v=hwOpCKBaJ-w. 
  78. "Think eBPF for Kernel Security Monitoring - Falco at Apple- Eric Sage & Melissa Kilby, Apple". October 2021. https://www.youtube.com/watch?v=ZBlJSr6XkN8. 
  79. "eBPF & Cilium at Sky – Sebastian Duff, Anthony Comtois, Jospeh Samuel, Sky". August 2021. https://www.youtube.com/watch?v=u-4naOMfs_w. 
  80. "Running and orchestrating multiple XDP and TC programs – Brian Merrell, Walmart". August 2021. https://www.youtube.com/watch?v=Fu4L8ewcO70. 
  81. "High Performance Load Balancing @Walmart – Kanthi Pavuluri & Karan Dalal, Walmart". August 2021. https://www.youtube.com/watch?v=thmAcyix8FM. 
  82. "DIGLIM eBPF: secure boot at application level with minimal changes to distros - Roberto Sassu". August 2022. https://www.youtube.com/watch?v=iA7T4MAqKUc. 
  83. "IKEA Private Cloud, eBPF Based Networking, Load Balancing, and Observability with... Karsten Nielsen". May 2022. https://www.youtube.com/watch?v=sg-F_R-ZVNc. 
  84. "Reading privileged memory with a side-channel". 3 January 2018. https://googleprojectzero.blogspot.com/2018/01/reading-privileged-memory-with-side.html. 
  85. "BPF and Spectre: Mitigating transient execution attacks". https://popl22.sigplan.org/details/prisc-2022-papers/11/BPF-and-Spectre-Mitigating-transient-execution-attacks. 
  86. "bpf: Disallow unprivileged bpf by default". https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8a03e56b253e9691c90bc52ca199323d71b96204. 

Further reading

  • Gregg, Brendan (December 2019). BPF Performance Tools. Addison-Wesley. ISBN 978-0136554820. 
  • David Calavera, Lorenzo Fontana (December 2019). Linux Observability With BPF. O'Reilly Media, Incorporated. ISBN 978-1492050209. 
  • Gregg, Brendan (December 2020). Systems Performance, Second edition. ISBN 978-0136820154. 
  • Rice, Liz (April 2022). What Is eBPF?. ISBN 978-1492097259. 
  • Rice, Liz (April 2023). Learning eBPF: Programming the Linux Kernel for Enhanced Observability, Networking, and Security. O'Reilly Media. ISBN 978-1098135126. 

External links