brintos

brintos / linux-shallow public Read only

0
0
Text · 3.5 KiB · b19c433 Raw
93 lines · plain
1=============2BPF licensing3=============4 5Background6==========7 8* Classic BPF was BSD licensed9 10"BPF" was originally introduced as BSD Packet Filter in11http://www.tcpdump.org/papers/bpf-usenix93.pdf. The corresponding instruction12set and its implementation came from BSD with BSD license. That original13instruction set is now known as "classic BPF".14 15However an instruction set is a specification for machine-language interaction,16similar to a programming language.  It is not a code. Therefore, the17application of a BSD license may be misleading in a certain context, as the18instruction set may enjoy no copyright protection.19 20* eBPF (extended BPF) instruction set continues to be BSD21 22In 2014, the classic BPF instruction set was significantly extended. We23typically refer to this instruction set as eBPF to disambiguate it from cBPF.24The eBPF instruction set is still BSD licensed.25 26Implementations of eBPF27=======================28 29Using the eBPF instruction set requires implementing code in both kernel space30and user space.31 32In Linux Kernel33---------------34 35The reference implementations of the eBPF interpreter and various just-in-time36compilers are part of Linux and are GPLv2 licensed. The implementation of37eBPF helper functions is also GPLv2 licensed. Interpreters, JITs, helpers,38and verifiers are called eBPF runtime.39 40In User Space41-------------42 43There are also implementations of eBPF runtime (interpreter, JITs, helper44functions) under45Apache2 (https://github.com/iovisor/ubpf),46MIT (https://github.com/qmonnet/rbpf), and47BSD (https://github.com/DPDK/dpdk/blob/main/lib/librte_bpf).48 49In HW50-----51 52The HW can choose to execute eBPF instruction natively and provide eBPF runtime53in HW or via the use of implementing firmware with a proprietary license.54 55In other operating systems56--------------------------57 58Other kernels or user space implementations of eBPF instruction set and runtime59can have proprietary licenses.60 61Using BPF programs in the Linux kernel62======================================63 64Linux Kernel (while being GPLv2) allows linking of proprietary kernel modules65under these rules:66Documentation/process/license-rules.rst67 68When a kernel module is loaded, the linux kernel checks which functions it69intends to use. If any function is marked as "GPL only," the corresponding70module or program has to have GPL compatible license.71 72Loading BPF program into the Linux kernel is similar to loading a kernel73module. BPF is loaded at run time and not statically linked to the Linux74kernel. BPF program loading follows the same license checking rules as kernel75modules. BPF programs can be proprietary if they don't use "GPL only" BPF76helper functions.77 78Further, some BPF program types - Linux Security Modules (LSM) and TCP79Congestion Control (struct_ops), as of Aug 2021 - are required to be GPL80compatible even if they don't use "GPL only" helper functions directly. The81registration step of LSM and TCP congestion control modules of the Linux82kernel is done through EXPORT_SYMBOL_GPL kernel functions. In that sense LSM83and struct_ops BPF programs are implicitly calling "GPL only" functions.84The same restriction applies to BPF programs that call kernel functions85directly via unstable interface also known as "kfunc".86 87Packaging BPF programs with user space applications88====================================================89 90Generally, proprietary-licensed applications and GPL licensed BPF programs91written for the Linux kernel in the same package can co-exist because they are92separate executable processes. This applies to both cBPF and eBPF programs.93