5 ms·
Question from me, why reinvent the bicycle and not just write proper kernel modules in C?
by baybal2 7y ago
Question from me, why reinvent the bicycle and not just write proper kernel modules in C?
- varelaz 7y agoWell, if you have seen the video, probably you wouldn't ask this. Kernel modules can do everything that can BPF do, but BPF could be easier to write, more isolated and less error prone.
- sanxiyn 7y agoYou need root to load kernel modules. While this isn't possible yet, the intention is to allow loading BPF programs without privilege.
- rhinoceraptor 7y agoBPF is completely production safe. So there is no way for a BPF program to crash the kernel, introduce significant performance latency, or have any side effects on the kernel/user space. Obviously, kernel modules have none of those properties. Also, BPF has been around for almost 30 years, and you're likely using it. tcpdump is basically just a BPF bytecode frontend, for example.
- manyworlds 7y agoYou can maintain production safety by using a BPF->kernel module compiler. This additionally removes the need to have the bpf compiler in the kernel, reducing both core size and vulnerability surface area. No reason BPF must imply JIT
- monocasa 7y agoThe end goal with bpf is to allow arbitrary untrusted programs to load bpf programs. If you were just loading kernel modules you wouldn't be able to maintain kernel integrity and let arbitrary programs load code.
- youareawesome 7y agoLoading BPF requires root, so does loading kernel modules. I.e. if you have permissions to load BPF, you can already load arbitrary code.
- monocasa 7y agoAt the moment.
- sigjuice 7y agoI can't find the LKML thread, but there is some fundamental problem with unloading modules safely. BPF programs might not have such limitations.
- monocasa 7y agoOh, neat! Yeah, I didn't think of this but that totally makes sense. BPF programs declare their resources to the kernel (maps, etc.), but modules are reliant on the __exit function cleaning everything up properly. The correctness of __exit is unverified, difficult, and practically one of the least tested pathways which makes it traditionally fraught with bugs.
- manyworlds 7y agoA BPF->kernel module compiler would ensure all necessary cleanup happens in __exit automatically
- monocasa 7y agoA BPF to kernel module compiler wouldn't let the kernel verify the program in a real way. There's still work to be done, bit the end goal of BPF is pretty obviously to allow non root users to load programs. Doing the verification offline is a non starter. Appending the verification information and reverifying it at load time is more work than a BPF runtime as it is as you have to reproject ISA semantics in a more complex way.
- rhinoceraptor 7y agoeBPF and kernel modules solve completely different tasks. If you need a kernel module to accomplish your task, then by definition you cannot accomplish it with eBPF.
- StreamBright 7y agoI guess you are missing the point by 100000 miles. The whole point of BPF is the avoid writing a C kernel module and pull in the entire problem domain of C programs running in Ring0. this was called out explicitly in the video.
- manyworlds 7y agoHe’s not off the mark completely, you can maintain production safety by using a BPF->kernel module compiler. Unnecessary to have an entire JIT infrastructure in the kernel just to get the safety benefits of BPF.
- deleted 7y ago[deleted]