Commit graph

7 commits

Author SHA1 Message Date
Gustavo Iñiguez Goia
27509d6fe0
ebpf,dns: initialized structs
On the previus commit we just disabled dns uprobes for armhf/i386 to
avoid loading errors. A better fix is to initialized the structs used.
On armhf still fails after loading it, when attaching to the uprobes
(offsets?), and on i386 it doesn't seem to send anything to userspace
(more analysis needed).

- Increased the number of IPs associated with a domain that are
  delivered to userspace. (getfedora.org returns 30 ipv4+ipv6).
- Fixed getting the aliases of a domain when using gethostbyname().
2024-01-26 20:50:50 +01:00
Gustavo Iñiguez Goia
d55e567dd8
fixed dns ebpf module for i386/arm architecture
The opensnitch-dns module was not loading on i386/arm architectures.
With the following changes it loads and some uprobes are attached.

for-loops unrolling doesn't still work though on i386/armhf (help
needed).

And on armhf the perf_output channel fails to load for some uprobes.
2024-01-26 14:16:43 +01:00
Gustavo Iñiguez Goia
1518cb39de
ebpf: fixed dns uprobes
We were not deleting DNS entries from the hash map, so when it reached
the maximum capacity (12k entries), we couldn't allocate new entries,
resulting in events not being sent to userspace.
2024-01-05 13:33:56 +01:00
munix9
11baad083d
ebpf modules compilation fixes
- don't import hardcoded architecture.
- use generic cpu (-mcpu=generic)
- removed linux/version.h from modules.

related #954
2023-05-28 15:24:33 +02:00
Gustavo Iñiguez Goia
ba64379348
ebpf: new way of compiling the modules
- Don't rename libbpf's bpf_map_def struct, and distribute the needed bpf
  headers.
  The bpf_map_def struct has been deprecated for quite some time now,
  and it was been removed on >= 6.2 anyway.
  We still need it, because we use gobpf.
- Improved compilation behaviour:
  - We don't require the kernel sources anymore. We can just use the
    kernel headers from the distribution.
  - There's no need to copy the sources to the kernel tree, the modules
    can be compiled from the ebpf_prog/ dir.
- Compiling against kernels 6.x seems to solve the problem we had with
  VPNs, where connections were not intercepted with modules compiled
  against 5.8, on kernels >= 5.19.

The modules has been tested on kernels 4.17, 5.4, 5.10, 5.15, 6.1 and
6.2 (kernel connections included).

Closes: #939
2023-05-17 01:20:53 +02:00
Gustavo Iñiguez Goia
31c420ad60
ebpf dns module: fixed compilation warning 2022-10-05 14:33:05 +02:00
calesanz
a4b7f57806
Add ebpf based dns lookup hooks (#582)
When using DoT or DoH opensnitch cannot intercept the dns packets.
Therefore the UI always shows IP addresses instead of hostnames. To fix
this issue an ebpf (uprobe) filter was created to hook getaddrinfo and
gethostbyname calls.

In order to be independent of libbcc an additional module was added to
ebpf_prog. Without libbcc the libc function offsets must be resolved
manually. In order to find the loaded glibc version some cgo code was
added.
2022-02-15 21:25:35 +01:00