ebpf_prog: compile out-of-tree feature request #939
Replies: 8 comments
-
I think these instructions are out of date, but the debian release installs without any kernel patching or modules: ebpf is specifically not a module: https://ebpf.io/ The Debian build instructions should help show the way forward: https://github.com/evilsocket/opensnitch/tree/master/debian/ |
Beta Was this translation helpful? Give feedback.
-
Hi @blshkv , as @emdee-is pointed out, the ebpf module is not a usual kernel module. But in any case, you'd need the kernel sources to compile kernel or ebpf modules. Take a look at how the AUR package does it: https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=opensnitch-ebpf-module-git On the other hand, the deb/rpm packages installs a precompiled ebpf module. That avoids having to compile the module every time a user installs or updates the daemon, besides not having to install gcc+many other tools and download the kernel sources (externally or from your distro). . We should move to BTF+CO:RE, but that's another story. |
Beta Was this translation helpful? Give feedback.
-
Thanks @gustavo-iniguez-goya - that helps a lot. Pentoo is a hardened version of Gentoo, so a recent kernel build from source is available on all Pentoos. The AUR recipe translates easily into a Gentoo ebuild file, although a Gentoo ebuild does more: But a few questions on how you are building opensnitch.o; I'll list them all here and then I can break them into individual issues as needed.
There are real reasons for wanting to do this: hardened people want kernel modules to be signed, and if in effect you are making and loading the equivalent to an unsigned kernel module, and that's very bad news. Is opensnitch.o loaded like a kernel module, so that it could be signed like a kernel module, and the signature checked on loading?
Could you update the documentation and list the configs required for ebpf and the kernel version the requirements are set for. A wiki page on building ebpf_prog/opensnitch.o that is kept up to date, with a copy in the release would be a good thing.
If you like, cut and paste this into individual issues to suit your taste. |
Beta Was this translation helpful? Give feedback.
-
Hi @gustavo-iniguez-goya , I guess what we really need it to be able to compile your source out-of-tree kernel module.
Here is the offical documentation https://www.kernel.org/doc/Documentation/kbuild/modules.txt |
Beta Was this translation helpful? Give feedback.
-
See also #680 |
Beta Was this translation helpful? Give feedback.
-
nop, not related. It's just a hack (not really using ebuild APIs) to compile it inline. The out-of-tree version should be using libbpf (libbpf.so.0 and bpf*.h headers) |
Beta Was this translation helpful? Give feedback.
-
https://github.com/netoptimizer/prototype-kernel
|
Beta Was this translation helpful? Give feedback.
-
I'm not a programmer, so maybe I'm missing something, but it looks to me like this is terrible programming practice. Wouldn't it be easier for ebpf_prog to define and use bpf_map_defnew or something and then not need this patch at all? |
Beta Was this translation helpful? Give feedback.
-
Currently, https://github.com/evilsocket/opensnitch/tree/master/ebpf_prog requires some woo-doo:
copying source into a specific kernel linux kernel, patching kernel and installing opensnitch.o (binary) into /etc.
All that doesn't look right.
Is it possible to make a proper kernel opensnitch_ebpf module and load it with
modprobe
?Beta Was this translation helpful? Give feedback.
All reactions