LWN: Comments on "BPF as a safer kernel programming environment" https://lwn.net/Articles/909095/ This is a special feed containing comments posted to the individual LWN article titled "BPF as a safer kernel programming environment". en-us Tue, 04 Nov 2025 09:44:59 +0000 Tue, 04 Nov 2025 09:44:59 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net BPF as a safer kernel programming environment https://lwn.net/Articles/910923/ https://lwn.net/Articles/910923/ sammythesnake <div class="FormattedComment"> If the eBPF program is to do anything useful, it has to calculate something that isn't already calculated. In the general case, the only way to know what values it will be manipulating is to run it. C.f. the halting problem.<br> <p> There's still value in assertions at the start of the program regarding its input state (e.g. a range parameter must be under a certain size, perhaps) which might be checked before execution, but that's a fairly small subset of the assertions that might be useful within the eBPF program.<br> <p> The approach taken by the verifier has been to verify the subset and reject anything it doesn't know how to verify. I guess there could be a mode that understands some subset of assertions (perhaps defined declaratively in metadata alongside the eBPF program) and falls back to executing assertion statements for others but that requires some means to respond to a failed assertion during execution, which might be decidedly nontrivial in some cases...<br> </div> Wed, 12 Oct 2022 08:47:11 +0000 BPF as a safer kernel programming environment https://lwn.net/Articles/910544/ https://lwn.net/Articles/910544/ njs <div class="FormattedComment"> I think the issue is that if your program is mutating kernel structures, then it may not be safe to kill it mid-stream -- you need some strategy for safely unwinding from an arbitrary point in execution. This seems like a pretty reasonable thing to me, but I guess so far eBPF has decided to make the tradeoff of investing in the verifier infrastructure instead of unwinding infrastructure.<br> </div> Thu, 06 Oct 2022 21:53:54 +0000 BPF as a safer kernel programming environment https://lwn.net/Articles/910354/ https://lwn.net/Articles/910354/ hiraditya <div class="FormattedComment"> Is there any document describing the type system of eBPF? I&#x27;m curious if we can provide the semantics of linear types using eBPF<br> </div> Wed, 05 Oct 2022 05:48:00 +0000 BPF as a safer kernel programming environment https://lwn.net/Articles/910056/ https://lwn.net/Articles/910056/ developer122 <div class="FormattedComment"> can&#x27;t you just check assertions during verification? if everything is known beforehand, just check if they&#x27;re reachable given current values.<br> </div> Sun, 02 Oct 2022 06:12:29 +0000 BPF as a safer kernel programming environment https://lwn.net/Articles/909721/ https://lwn.net/Articles/909721/ Cyberax <div class="FormattedComment"> <font class="QuotedText">&gt; BPF verifier does have the notable feature (or misfeature) of being able to prove that the program will successfully complete in a bounded execution time.</font><br> <p> WASM programs can be suspended after a given number of instructions (&quot;fuel&quot;), at least if you&#x27;re using the &quot;wasmtime&quot; runtime. This is essentially the same functionality. Moreover the &quot;fuel&quot; limits can be configured during the runtime so you can easily have different settings for different types of instrumentation.<br> <p> <font class="QuotedText">&gt; Wasm doesn&#x27;t do that. A wasm program is allowed to loop forever, or to abort.</font><br> <p> The only thing you really need to add to WASM is the &quot;default value&quot; that would be returned on termination or fuel exhaustion.<br> </div> Wed, 28 Sep 2022 16:36:18 +0000 BPF as a safer kernel programming environment https://lwn.net/Articles/909652/ https://lwn.net/Articles/909652/ foom <div class="FormattedComment"> BPF verifier does have the notable feature (or misfeature) of being able to prove that the program will successfully complete in a bounded execution time.<br> <p> Wasm doesn&#x27;t do that. A wasm program is allowed to loop forever, or to abort.<br> </div> Wed, 28 Sep 2022 11:13:44 +0000 BPF as a safer kernel programming environment https://lwn.net/Articles/909484/ https://lwn.net/Articles/909484/ Cyberax <div class="FormattedComment"> WASM is designed from ground up to be safe, as it&#x27;s used in browsers (which is probably the most aggressive computing medium imaginable). eBPF verifier is far less robust.<br> </div> Mon, 26 Sep 2022 18:14:55 +0000 BPF as a safer kernel programming environment https://lwn.net/Articles/909476/ https://lwn.net/Articles/909476/ kid_meier <div class="FormattedComment"> Can WASM be verified as safe in the same way that the BPF verifier currently is able to validate eBPF?<br> <p> I am ignorant of details myself but had the impression that BPF is designed to be (easily?) verifiable and maybe WASM is less suitable in this context. <br> </div> Mon, 26 Sep 2022 17:18:07 +0000 BPF as a safer kernel programming environment https://lwn.net/Articles/909472/ https://lwn.net/Articles/909472/ Cyberax <div class="FormattedComment"> There is a fairly straightforward proposal to add 64-bit indexes to WASM: <a href="https://github.com/WebAssembly/memory64">https://github.com/WebAssembly/memory64</a><br> <p> But it won&#x27;t even be necessary, because WASM is used in a sandbox and works with the external world via well-defined accessors only. Just like eBPF for that matter.<br> </div> Mon, 26 Sep 2022 15:39:24 +0000 BPF as a safer kernel programming environment https://lwn.net/Articles/909406/ https://lwn.net/Articles/909406/ ballombe <div class="FormattedComment"> Would not lack of 64bit WASM be a problem ?<br> </div> Mon, 26 Sep 2022 14:33:55 +0000 BPF as a safer kernel programming environment https://lwn.net/Articles/909397/ https://lwn.net/Articles/909397/ Cyberax <div class="FormattedComment"> BPF is used mostly for dynamic instrumentation, which should be a perfect use-case for WASM.<br> </div> Mon, 26 Sep 2022 05:07:13 +0000 BPF as a safer kernel programming environment https://lwn.net/Articles/909378/ https://lwn.net/Articles/909378/ Subsentient <div class="FormattedComment"> Why bother with WASM? Just use Rust. It&#x27;s now possible to write good kernel drivers in Rust, though support isn&#x27;t mainline until 6.1. Still should be good enough in the meantime, especially if you&#x27;re writing a proprietary module that doesn&#x27;t need to be mainlined.<br> </div> Sun, 25 Sep 2022 21:30:48 +0000 BPF as a safer kernel programming environment https://lwn.net/Articles/909376/ https://lwn.net/Articles/909376/ amarao <div class="FormattedComment"> Yes. Systemd is using it to implement firewall (AllowedIP stanza). It&#x27;s sound ironic, but ebpf is used as bpf...<br> </div> Sun, 25 Sep 2022 20:34:57 +0000 BPF as a safer kernel programming environment https://lwn.net/Articles/909374/ https://lwn.net/Articles/909374/ Cyberax <div class="FormattedComment"> Can we just switch from BPF to WASM? <br> </div> Sun, 25 Sep 2022 19:55:14 +0000 BPF as a safer kernel programming environment https://lwn.net/Articles/909357/ https://lwn.net/Articles/909357/ zdzichu <div class="FormattedComment"> If something is used by hyperscalers, doesn&#x27;t it automatically cover 90+% of Linux use (excluding Android)?<br> </div> Sun, 25 Sep 2022 13:16:24 +0000 BPF as a safer kernel programming environment https://lwn.net/Articles/909354/ https://lwn.net/Articles/909354/ Sesse <div class="FormattedComment"> For all the hype of eBPF—is it actually widely used? I mean, I&#x27;ve used xfsslower and such from bfpcc-tools (which is neat, although it takes way too long to start up and is fairly primitive), but in my normal day-to-day work, I don&#x27;t really feel like all these kernel hooks is something I _need_ or even can make good use of. I&#x27;m sure hyperscalers can do all sorts of weird and wonderful things with it, but it still feels like a long way to go before this is mainstream?<br> </div> Sun, 25 Sep 2022 09:10:44 +0000 BPF as a safer kernel programming environment https://lwn.net/Articles/909327/ https://lwn.net/Articles/909327/ corbet Most symbols (including all kfuncs as I understand it) for BPF programs are GPL-only. Of course, the kernel has to trust a BPF program that declares itself to be GPL-licensed, but the situation is no different that for modules in that regard. Sat, 24 Sep 2022 15:19:26 +0000 BPF as a safer kernel programming environment https://lwn.net/Articles/909325/ https://lwn.net/Articles/909325/ gray_-_wolf <div class="FormattedComment"> <font class="QuotedText">&gt; I suspect the main limitation to a wave of proprietary eBPF programs is that it&#x27;s still pretty far from parity with a full blown module.</font><br> <p> If that is indeed the case, I must say I&#x27;m unhappy about it from the freedom point of view :/<br> <p> I know that kernel does have some functions exposed only for GPL-licensed modules, at least that is my understanding. Is something similar also in the eBPF or there every program has everything available, regardless of licensing?<br> </div> Sat, 24 Sep 2022 15:12:16 +0000 BPF as a safer kernel programming environment https://lwn.net/Articles/909312/ https://lwn.net/Articles/909312/ Wol <div class="FormattedComment"> <font class="QuotedText">&gt; So, BPF and eBPF are still restricted to bounded loops — no infinite loops, and no recursion? In other words they are not Turing complete. (This is not a criticism, just want to clarify.)</font><br> <p> I believe that is in the language specification - a program must complete in bounded time or fail. This precludes Turing completeness ... :-)<br> <p> (Enforced by the checker - if it cannot solve the Halting Problem for that particular executable, it is not allowed to start.)<br> <p> Cheers,<br> Wol<br> </div> Sat, 24 Sep 2022 08:05:18 +0000 BPF as a safer kernel programming environment https://lwn.net/Articles/909309/ https://lwn.net/Articles/909309/ epa <div class="FormattedComment"> So, BPF and eBPF are still restricted to bounded loops — no infinite loops, and no recursion? In other words they are not Turing complete. (This is not a criticism, just want to clarify.)<br> <p> In a way the use of BPF to replace kernel modules reminds me of Firefox extensions moving from the original C++ compiled blobs to JavaScript. And that suggests that in some cases BPF might be useful as an extension language in user space. I don’t think it will ever replace JavaScript for web browsers but maybe for in-house use? Like how Emacs has a core in C and the rest in Lisp. For soft real-time applications you might want to guarantee that the non-core code can never hang or get stuck in a loop. <br> </div> Sat, 24 Sep 2022 07:23:59 +0000 BPF as a safer kernel programming environment https://lwn.net/Articles/909289/ https://lwn.net/Articles/909289/ tux3 <div class="FormattedComment"> I&#x27;ve seen one instance already. Crowdstrike has a thoroughly closed-source endpoint surveillance sensor program that until now relied on a kernel module to do most of the snooping and hooking. This involves them shipping about 800MB of kernel modules binaries in an .xz archive, one for every supported system under the sun. And of course it breaks if you update your system.<br> They&#x27;re apparently giving up on maintaining their module and planning to replace it with eBPF, even if that currently means losing some functionality.<br> <p> I suspect the main limitation to a wave of proprietary eBPF programs is that it&#x27;s still pretty far from parity with a full blown module. For vendors that don&#x27;t mind the loss (or that can do everything in eBPF), I suppose we&#x27;ll have to see how much worse the eBPF binary blobs are to deal with than the binary modules. <br> <p> My hope is that decompilers will eventually handle eBPF bytecode as well if not better than compiled C. At the end of the day this could even be a slightly lesser evil for end-users, if it turns out that the blobs are easier to reverse.<br> <p> </div> Fri, 23 Sep 2022 22:17:55 +0000 BPF as a safer kernel programming environment https://lwn.net/Articles/909266/ https://lwn.net/Articles/909266/ gray_-_wolf <div class="FormattedComment"> Given all the work on making eBPF more powerful (and portable between kernel versions), can we expect new wave of proprietary closed-source kernel modules, but this time implemented as eBPF programs?<br> </div> Fri, 23 Sep 2022 19:11:18 +0000 BPF as a safer kernel programming environment https://lwn.net/Articles/909248/ https://lwn.net/Articles/909248/ mdaverde I'm excited for the future that's laid out by ast. It feels like a new primitive has been added to the kernel where the value that is to be unlocked on top of it is still unknown but leans powerful. One aspect I will be critical in is that if that is the stated "mission statement" then a lot of work has to be done outside of core kernel technical work to allow others to innovate. Hopefully the eBPF foundation can successfully foster a community around documentation, tooling, standardization in an accessible way. Fri, 23 Sep 2022 17:18:55 +0000