You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You don't expect to see 600 iterations... that's the maximum amount it'll do without reporting a warning.
Generally you'd expect around the number of kernel modules loaded in your system.
To get a full unroll, the pragma should be #pragma clang loop unroll(full). The problem with that is if we just force the unrolling a bit... clang crashes.
Try it with 61 and it works,
diff --git a/pkg/ebpf/c/tracee.bpf.c b/pkg/ebpf/c/tracee.bpf.c
index 3cec1a9ad..beef6e2ba 100644
--- a/pkg/ebpf/c/tracee.bpf.c+++ b/pkg/ebpf/c/tracee.bpf.c@@ -715,7 +715,7 @@ int tracepoint__sched__sched_process_fork(struct bpf_raw_tracepoint_args *ctx)
}
// number of iterations - value that the verifier was seen to cope with - the higher, the better
-#define MAX_NUM_MODULES 450+#define MAX_NUM_MODULES 61
enum
{
@@ -871,7 +871,7 @@ statfunc int find_modules_from_module_kset_list(program_data_t *p)
struct kobject *n = list_next_entry_ebpf(pos, entry);
u32 flags = KSET | HIDDEN_MODULE;
-#pragma unroll+#pragma clang loop unroll(full)
for (int i = 0; i < MAX_NUM_MODULES; i++) {
if (BPF_CORE_READ(n, name) ==
NULL) { // Without this the list seems infinite. Also, using pos
fatal error: error in backend: Branch target out of insn range
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
So, based on that I suspect that #pragma unroll doesn't guarantee the full expected iterations. More tests are required.
Description
We expect to see 600 iterations and get only 60 in
find_modules_from_module_kset_list()
:tracee/pkg/ebpf/c/tracee.bpf.c
Lines 799 to 800 in f61866b
tracee/pkg/ebpf/c/tracee.bpf.c
Line 644 in f61866b
Steps to check it
sudo bpftool prog list | grep lkm_seeker_kset
sudo bpftool prog dump xlated id ID > lkm_seeker_kset_tail_xlated
grep 'if (mod_kobj) {' lkm_seeker_kset_tail_xlated | wc -l
Output of
tracee version
:Output of
uname -a
:Additional details
Tested on:
The text was updated successfully, but these errors were encountered: