4 ms·
Ah, that makes more sense. The byte code is an evolution and not a clean room design, and the focus has always been on remaining as close to the host ISA as pos
by ilovecaching 5y ago
Ah, that makes more sense. The byte code is an evolution and not a clean room design, and the focus has always been on remaining as close to the host ISA as possible. We've had several academics work on the verifier and most of the time the solutions allow for more programs to pass, but at the cost of far, far slower program loading (upwards of 30 minutes).
> I don't know what you would do in the case of like, livelock though.
The idea is we never allow this to happen by enforcing your use of locks and memory through helpers. Helpers are really the secret sauce to how we are able to enforce memory barriers, etc. without having the author think about them too much. Helpers are essentially the new syscall layer for the kernel with the advantage that they are far less expensive to add, and there's less complaining when it's later decided they were a bad decision... :) Of course, there will be bugs in eBPF, just as their are bugs in any other part of the kernel that will cause unexpected behavior.
You are right in that a different design might have been easier to verify and less error prone, but I think that eBPF overall has been very robust, and is still far better than what we had with loading kernel modules and letting people do whatever they want, or trying to create really rigid policies through syscalls and exposing internals through VFS.
It's sort of hard to solve right now in the "Will this arbitrary C program work or not" sense, because the underlying toolchain and kernel implementation is evolving. I know there's a userspace verifier. What would be excellent is something like the ability to compile the kernel implementation of the verifier, but in userspace, so you could use it in CI. Does this already work, maybe?
There are two issues with loading - the first is as you described, which is that the verifier sometimes reject programs that clang can build. The second is that sometimes there are issues resolving BTF and fixing up programs to run against the target ABI. Both of these problems are hard to solve and I have personally seen users run into this as a major pain point. It needs improvement. Verification in userland is definitely one way to improve this. No matter what though, the nature of sitting inside the kernel is that it's very hard to keep any sort of userland step in lockstep with the kernel, and so I think this will always be a hard problem to solve.