diff --git a/ebpf/symtab/kallsyms.go b/ebpf/symtab/kallsyms.go index 3601dafa96..722c1acc28 100644 --- a/ebpf/symtab/kallsyms.go +++ b/ebpf/symtab/kallsyms.go @@ -5,6 +5,7 @@ import ( "fmt" "os" "runtime" + "sort" "strconv" ) @@ -94,5 +95,9 @@ func NewKallsymsFromData(kallsyms []byte) (*SymbolTab, error) { if allZeros { return NewSymbolTab(nil), nil } + // kallsyms maybe unsorted when bpf/modules are loaded from userspace after kernel boot. + sort.Slice(syms, func(i, j int) bool { + return syms[i].Start < syms[j].Start + }) return NewSymbolTab(syms), nil }