evilsocket / evilsocket/opensnitch

eBPF compatibility with custom and hardened kernels (xanmod, liquorix, etc)

Open
#774 9 comments 5 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
14.1k
Forks
665
PR merge metrics
No merged PRs in 30d

Description

We've had several issues in the past regarding compatibility with this type of kernels and eBPF.

### Custom kernels (xanmod, liquorix, others)

In order to use [eBPF as process monitor method](https://github.com/evilsocket/opensnitch/wiki/monitor-method-ebpf), the kernel must have some features enabled:

Basic:

- [x] CONFIG_FTRACE=y
(Without this option, the path `/sys/kernel/debug/tracing/` is not created.)
- [x] CONFIG_KPROBES=y , CONFIG_KPROBES_ON_FTRACE=y, CONFIG_HAVE_KPROBES=y , CONFIG_HAVE_KPROBES_ON_FTRACE=y, CONFIG_KPROBE_EVENTS=y

Additionally:

- [x] CONFIG_HAVE_SYSCALL_TRACEPOINTS=y
- [x] CONFIG_FTRACE_SYSCALLS=y
(Without these options, opensnitch-procs.o module will fail)

Extras:

- [x] CONFIG_UPROBE_EVENTS=y
(Without this option, the path `/sys/kernel/debug/tracing/uprobe_events` is not created. Thus the opensnitch-dns.o module, and any other that hooks userland libs won't work.)

You can check these options out with the following command: `$ grep FTRACE /boot/config-$(uname -r)` (or KPROBE, etc)

On the other hand, the path `/sys/kernel/debug/tracing/kprobe_events` must exist. Usually it's created when debugfs is mounted.
Since version 1.6.0rc2 opensnitch will try to mount it (some distros like devuan do not mount it by default). If we fail to mount it, then much probably one of the mentioned kernel features is not enabled.

- **xanmod kernels:**
CONFIG_FTRACE is not set, thus `ebpf` proc monitor method doesn't work.

- **liquorix kernels:**
`ebpf` proc monitor method works partially: connections are intercepted, but new/exit processes don't (CONFIG_FTRACE_SYSCALLS not set).
DNS passive requests interception doesn't work either (CONFIG_UPROBE_EVENTS not set).

- **Arch / Manjaro hardened kernels (as of 29/10/2023)**
/sys/kernel/debug/tracing/ path does not exist, thus we cannot configure kprobes or tracepoints. See this comment: https://github.com/evilsocket/opensnitch/issues/774#issuecomment-1783870063

### Hardened kernels / systems

There're some configurable kernel options that prevent us from working as expected (eBPF only, AFAIK). #767
In particular these scripts seem to block some eBPF features: https://github.com/Kicksecure/security-misc#enhances-miscellaneous-security-settings

One of these options is `lockdown=confidentiality`:
> [tjbbjt](https://github.com/tjbbjt) said:
> Removing lockdown=confidentiality from grub boot parameters fixed eBPF disabling for me.

(thank you @tjbbjt for reporting this!)

---

**What happen if eBPF is not supported**

We fallback to `proc` monitor method. Starting from v1.6.0rc3 you'll receive an alert on the desktop. If you want to stop seeing those alerts: 1) you can change proc monitor method to `proc` (Preferences -> Nodes), or 2) run a kernel with needed requirements.

For example, a desktop notification alerting that opensnitch-procs.o failed loading on liquorix kernel:
![image](https://user-images.githubusercontent.com/2742953/207380237-6fac903b-34e0-42fa-92de-3b2de156d510.png)

---

For iptables rules to work, you need at least this option enabled in your kernel configuration:

CONFIG_NETFILTER_XT_TARGET_NFQUEUE=y

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.