how to change kprobe.c(sys_execve) to know which binary is executed? #1446
Replies: 4 comments 2 replies
-
Maybe you can consider replacing (const char *)PT_REGS_PARM1(ctx) with ctx->rdi. Of course, this is under the x86-64 system, and your header file should define the corresponding pt_regs structure under the x86-64 system. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the reply. I tried , go generate complains as below
I found the 'pt_regs' 's definition in '/usr/src/linux-headers-5.15.0-102-generic/arch/x86/include/asm/ptrace.h' and try to include it and its dependencies into 'main.go' to build 'kprobe.c'. So it still complains, I think the dependency of 'pt_regs', 'PT_REGS_PARM1' is not correct , and need fix the dependency.
complains
|
Beta Was this translation helpful? Give feedback.
-
Hi, I tested with 'vmlinux.h' before, it didn't work. $ sudo bpftool btf dump file /sys/kernel/btf/vmlinux format c > vmlinux.h #include "common.h"
uncomment "common.h"$ vim kprobe.c //#include "common.h"
|
Beta Was this translation helpful? Give feedback.
-
you can include vmlinux.h and add some defs in c file,
|
Beta Was this translation helpful? Give feedback.
-
I change the kprobe.c as belows. It seems not working.
Beta Was this translation helpful? Give feedback.
All reactions