Replies: 1 comment 1 reply
-
|
The error occurs because the section name in your BPF C code doesn't match what cilium/ebpf expects for kretprobes. Change your section name from // Wrong
SEC("kprobe/sys_execve")
int kretprobe_execve(struct pt_regs *ctx) {
// ...
}
// Correct
SEC("kretprobe/sys_execve")
int kretprobe_execve(struct pt_regs *ctx) {
// ...
}cilium/ebpf uses the
When the section name is wrong, the library can't infer the program type, resulting in "program type is unspecified". //go:build ignore
#include "vmlinux.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>
SEC("kretprobe/sys_execve")
int kretprobe_execve(struct pt_regs *ctx) {
int ret = PT_REGS_RC(ctx); // get return value
bpf_printk("execve returned: %d\n", ret);
return 0;
}
char LICENSE[] SEC("license") = "GPL";Then in Go, attach it with: kp, err := link.Kretprobe("sys_execve", objs.KretprobeExecve, nil)
if err != nil {
log.Fatalf("opening kretprobe: %s", err)
}
defer kp.Close()For kernels with syscall wrappers (most modern kernels), you may need to use |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I can run ringbuff example,but when i want to replace kprobe to Kretprobe, i get the erro:
2023/06/15 06:38:27 loading objects: field KretprobeExecve: cannot load program kretprobe_execve: program type is unspecifiedBeta Was this translation helpful? Give feedback.
All reactions