Skip to content

Commit

Permalink
Temporarily fix loading err on >= 6.6 kernels
Browse files Browse the repository at this point in the history
[1] changed the kprobe loading behavior in a way that if we try to
attach a kprobe to a function with a duplicate name, then it will fail
with EADDRNOTAVAIL [2].

As pwru loads kprobes by using function symbol names, we are prone to
this behavior change.

Fix the loading problem by ignoring EADDRNOTAVAIL w/ the kprobe backend.
Also, instruct users when the kprobe.multi backend is used.

The proper fix is to use function addrs instead of syms when loading.
This is what Leon H. is working on.

[1]: https://lore.kernel.org/all/[email protected]/.
[2]: https://elixir.bootlin.com/linux/v6.6/source/kernel/trace/trace_kprobe.c#L884

Signed-off-by: Leon Hwang <[email protected]>
Signed-off-by: Martynas Pumputis <[email protected]>
  • Loading branch information
brb committed Dec 20, 2023
1 parent c5ae578 commit 9d8ead7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func main() {
kp, err := link.Kprobe(name, fn, nil)
bar.Increment()
if err != nil {
if !errors.Is(err, os.ErrNotExist) {
if !errors.Is(err, os.ErrNotExist) && !errors.Is(err, syscall.EADDRNOTAVAIL) {
log.Fatalf("Opening kprobe %s: %s\n", name, err)
} else {
ignored += 1
Expand All @@ -319,6 +319,10 @@ func main() {
kp, err := link.KprobeMulti(fn, opts)
bar.Add(len(fns))
if err != nil {
if errors.Is(err, syscall.EADDRNOTAVAIL) {
log.Fatalf("Found duplicate function name in the kernel (%s). Set --backend=kprobe to fix the loading error until https://github.com/cilium/pwru/issues/284 has been fixed",
err)
}
log.Fatalf("Opening kprobe-multi for pos %d: %s\n", pos, err)
}
kprobes = append(kprobes, kp)
Expand Down

0 comments on commit 9d8ead7

Please sign in to comment.