1 ============= 1 ============= 2 BPF licensing 2 BPF licensing 3 ============= 3 ============= 4 4 5 Background 5 Background 6 ========== 6 ========== 7 7 8 * Classic BPF was BSD licensed 8 * Classic BPF was BSD licensed 9 9 10 "BPF" was originally introduced as BSD Packet 10 "BPF" was originally introduced as BSD Packet Filter in 11 http://www.tcpdump.org/papers/bpf-usenix93.pdf 11 http://www.tcpdump.org/papers/bpf-usenix93.pdf. The corresponding instruction 12 set and its implementation came from BSD with 12 set and its implementation came from BSD with BSD license. That original 13 instruction set is now known as "classic BPF". 13 instruction set is now known as "classic BPF". 14 14 15 However an instruction set is a specification 15 However an instruction set is a specification for machine-language interaction, 16 similar to a programming language. It is not 16 similar to a programming language. It is not a code. Therefore, the 17 application of a BSD license may be misleading 17 application of a BSD license may be misleading in a certain context, as the 18 instruction set may enjoy no copyright protect 18 instruction set may enjoy no copyright protection. 19 19 20 * eBPF (extended BPF) instruction set continue 20 * eBPF (extended BPF) instruction set continues to be BSD 21 21 22 In 2014, the classic BPF instruction set was s 22 In 2014, the classic BPF instruction set was significantly extended. We 23 typically refer to this instruction set as eBP 23 typically refer to this instruction set as eBPF to disambiguate it from cBPF. 24 The eBPF instruction set is still BSD licensed 24 The eBPF instruction set is still BSD licensed. 25 25 26 Implementations of eBPF 26 Implementations of eBPF 27 ======================= 27 ======================= 28 28 29 Using the eBPF instruction set requires implem 29 Using the eBPF instruction set requires implementing code in both kernel space 30 and user space. 30 and user space. 31 31 32 In Linux Kernel 32 In Linux Kernel 33 --------------- 33 --------------- 34 34 35 The reference implementations of the eBPF inte 35 The reference implementations of the eBPF interpreter and various just-in-time 36 compilers are part of Linux and are GPLv2 lice 36 compilers are part of Linux and are GPLv2 licensed. The implementation of 37 eBPF helper functions is also GPLv2 licensed. 37 eBPF helper functions is also GPLv2 licensed. Interpreters, JITs, helpers, 38 and verifiers are called eBPF runtime. 38 and verifiers are called eBPF runtime. 39 39 40 In User Space 40 In User Space 41 ------------- 41 ------------- 42 42 43 There are also implementations of eBPF runtime 43 There are also implementations of eBPF runtime (interpreter, JITs, helper 44 functions) under 44 functions) under 45 Apache2 (https://github.com/iovisor/ubpf), 45 Apache2 (https://github.com/iovisor/ubpf), 46 MIT (https://github.com/qmonnet/rbpf), and 46 MIT (https://github.com/qmonnet/rbpf), and 47 BSD (https://github.com/DPDK/dpdk/blob/main/li 47 BSD (https://github.com/DPDK/dpdk/blob/main/lib/librte_bpf). 48 48 49 In HW 49 In HW 50 ----- 50 ----- 51 51 52 The HW can choose to execute eBPF instruction 52 The HW can choose to execute eBPF instruction natively and provide eBPF runtime 53 in HW or via the use of implementing firmware 53 in HW or via the use of implementing firmware with a proprietary license. 54 54 55 In other operating systems 55 In other operating systems 56 -------------------------- 56 -------------------------- 57 57 58 Other kernels or user space implementations of 58 Other kernels or user space implementations of eBPF instruction set and runtime 59 can have proprietary licenses. 59 can have proprietary licenses. 60 60 61 Using BPF programs in the Linux kernel 61 Using BPF programs in the Linux kernel 62 ====================================== 62 ====================================== 63 63 64 Linux Kernel (while being GPLv2) allows linkin 64 Linux Kernel (while being GPLv2) allows linking of proprietary kernel modules 65 under these rules: 65 under these rules: 66 Documentation/process/license-rules.rst 66 Documentation/process/license-rules.rst 67 67 68 When a kernel module is loaded, the linux kern 68 When a kernel module is loaded, the linux kernel checks which functions it 69 intends to use. If any function is marked as " 69 intends to use. If any function is marked as "GPL only," the corresponding 70 module or program has to have GPL compatible l 70 module or program has to have GPL compatible license. 71 71 72 Loading BPF program into the Linux kernel is s 72 Loading BPF program into the Linux kernel is similar to loading a kernel 73 module. BPF is loaded at run time and not stat 73 module. BPF is loaded at run time and not statically linked to the Linux 74 kernel. BPF program loading follows the same l 74 kernel. BPF program loading follows the same license checking rules as kernel 75 modules. BPF programs can be proprietary if th 75 modules. BPF programs can be proprietary if they don't use "GPL only" BPF 76 helper functions. 76 helper functions. 77 77 78 Further, some BPF program types - Linux Securi 78 Further, some BPF program types - Linux Security Modules (LSM) and TCP 79 Congestion Control (struct_ops), as of Aug 202 79 Congestion Control (struct_ops), as of Aug 2021 - are required to be GPL 80 compatible even if they don't use "GPL only" h 80 compatible even if they don't use "GPL only" helper functions directly. The 81 registration step of LSM and TCP congestion co 81 registration step of LSM and TCP congestion control modules of the Linux 82 kernel is done through EXPORT_SYMBOL_GPL kerne 82 kernel is done through EXPORT_SYMBOL_GPL kernel functions. In that sense LSM 83 and struct_ops BPF programs are implicitly cal 83 and struct_ops BPF programs are implicitly calling "GPL only" functions. 84 The same restriction applies to BPF programs t 84 The same restriction applies to BPF programs that call kernel functions 85 directly via unstable interface also known as 85 directly via unstable interface also known as "kfunc". 86 86 87 Packaging BPF programs with user space applica 87 Packaging BPF programs with user space applications 88 ============================================== 88 ==================================================== 89 89 90 Generally, proprietary-licensed applications a 90 Generally, proprietary-licensed applications and GPL licensed BPF programs 91 written for the Linux kernel in the same packa 91 written for the Linux kernel in the same package can co-exist because they are 92 separate executable processes. This applies to 92 separate executable processes. This applies to both cBPF and eBPF programs.
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.