News for hackers. Stuff that matters.
Re:Notes on BPF and eBPF by _3u10 on Sunday January 02, 2022 @04:11PM (#29773941)
It’s not an easier interface. It’s much easier to write kernel modules than to mess around with eBPF.
Re:Notes on BPF and eBPF by tptacek on Sunday January 02, 2022 @08:36PM (#29776319)
That seems wrong. The build environment for eBPF programs is simpler (you don't even need a working kernel tree), and, much more importantly, eBPF programs are constrained and can't crash the kernel, which is easy to do accidentally when writing an freestyle C LKM. You can learn enough to get stuff done with eBPF inside of a couple days; the same is absolutely not true of kernel modules.
Re:Notes on BPF and eBPF by _3u10 on Sunday January 02, 2022 @11:00PM (#29777185)
I find the verifier to be extremely frustrating. It's also very difficult to debug eBPF programs, especially in regards to why it's not passing verifier. Combine with ridiculous restrictions from BCC like not being able to use functions in macros, or the vagueries of the bpf target in clang and it's extremely frustrating.

I've personally never found obtaining a working kernel tree to be difficult, certainly easier than a working BCC toolchain. Or all of the various compiler flags needed for clang not to emit code incompatible with the verifier.

Re:Notes on BPF and eBPF by tptacek on Sunday January 02, 2022 @11:12PM (#29777257)
I don't use BCC or really understand why anyone would; I use clang, and just produce .o's.

The verifier is definitely annoying, especially at first, but I found myself sort of quickly working out the verifier's expected idiom, and a lot of it can be wrapped with macros.

All of this drama pales in comparison to writing freestyle C code in the Linux kernel without causing random panics.

Re:Notes on BPF and eBPF by stormbrew on Sunday January 02, 2022 @05:29PM (#29774753)
Easier to get started maybe, but there's something to be said for the 'ease' of having to worry a lot less about crashing the kernel you're working on.
Re:Notes on BPF and eBPF by xyzzy_plugh on Sunday January 02, 2022 @06:04PM (#29775092)
I've crashed multiple kernels with eBPF programs. I don't buy this argument at all.
Re:Notes on BPF and eBPF by zokula on Sunday January 02, 2022 @08:13PM (#29776151)
I call bullshit! Ebpf programs cannot crash the kernel since they cannot be run if they contain bugs in the first place.
Re:Notes on BPF and eBPF by xyzzy_plugh on Sunday January 02, 2022 @11:25PM (#29777323)
The kernel, however, can and does have bugs. I've seen several thousand hosts get taken down with a perfectly correct eBPF program due to a buggy kernel.
Re:Notes on BPF and eBPF by daenz on Sunday January 02, 2022 @08:31PM (#29776274)
That assumes that the virtual machine has no bugs
Re:Notes on BPF and eBPF by tptacek on Sunday January 02, 2022 @08:38PM (#29776330)
Not so much (eBPF VM bugs are pretty rare, as you'd expect, since the VM is very simple) --- you're much more likely to run into bugs in the C-code helpers the kernel exports. If you're malicious, you can also hit verifier bugs that'll give your eBPF code raw pointers, but I don't think you're likely to stumble on them accidentally.
Re:Notes on BPF and eBPF by stormbrew on Sunday January 02, 2022 @07:28PM (#29775783)
I said 'less' rather than 'at all' for a reason. I'm not really sure what to tell you if you disagree that it's a lot easier to accidentally crash your kernel with a from-scratch module than ebpf though. That's an experience pretty drastically at odds with mine.
Re:Notes on BPF and eBPF by tptacek on Sunday January 02, 2022 @08:37PM (#29776324)
Can you describe some of those bugs? What helpers were you using? I've been doing bonkers stuff with eBPF for the last year and, while I've definitely had bugs, none of them took my kernel down.
Re:Notes on BPF and eBPF by xyzzy_plugh on Sunday January 02, 2022 @11:21PM (#29777302)
I no longer have access to the code, and the kernel has since been patched. Mostly doing some observability around new network connections.

We definitely hit this one at some point: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1763454

We also ran into a couple of similar but unrelated panic bugs on much newer kernels on non-Ubuntu distros.

Re:Notes on BPF and eBPF by roblabla on Sunday January 02, 2022 @07:15PM (#29775688)
Those would be considered kernel bugs though, and should be getting fixed when reported. While a crash in a kernel module is just a bug in the kernel module itself
Re:Notes on BPF and eBPF by justicezyx on Saturday January 08, 2022 @03:10PM (#29855653)
Could you share the ebpf program and the external dependencies that can reproduce the crash?

It'll be valuable to learn this, so that we might be able to proactively address them. Ebpf is the core of our product.