Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic syscall kprobes #4256

Merged
merged 7 commits into from
Aug 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
pref: Use kprobe for process_vm_writev
yanivagman committed Aug 19, 2024
commit ed64efae8267cc7e929bc4b279cb7c1347687b22
2 changes: 2 additions & 0 deletions pkg/ebpf/c/common/arch.h
Original file line number Diff line number Diff line change
@@ -172,6 +172,7 @@ statfunc struct pt_regs *get_current_task_pt_regs(void)
#define SYSCALL_SYNCFS 306
#define SYSCALL_SENDMMSG 307
#define SYSCALL_SETNS 308
#define SYSCALL_PROCESS_VM_WRITEV 311
#define SYSCALL_FINIT_MODULE 313
#define SYSCALL_EXECVEAT 322
#define SYSCALL_PREADV2 327
@@ -277,6 +278,7 @@ statfunc struct pt_regs *get_current_task_pt_regs(void)
#define SYSCALL_SYNCFS 267
#define SYSCALL_SETNS 268
#define SYSCALL_SENDMMSG 269
#define SYSCALL_PROCESS_VM_WRITEV 271
#define SYSCALL_FINIT_MODULE 273
#define SYSCALL_EXECVEAT 281
#define SYSCALL_PREADV2 286
1 change: 1 addition & 0 deletions pkg/ebpf/c/tracee.bpf.c
Original file line number Diff line number Diff line change
@@ -360,6 +360,7 @@ int trace_sys_exit(struct bpf_raw_tracepoint_args *ctx)

// macros for syscall kprobes
TRACE_SYSCALL(ptrace, SYSCALL_PTRACE)
TRACE_SYSCALL(process_vm_writev, SYSCALL_PROCESS_VM_WRITEV)

SEC("raw_tracepoint/sys_execve")
int syscall__execve_enter(void *ctx)
2 changes: 2 additions & 0 deletions pkg/ebpf/probes/probe_group.go
Original file line number Diff line number Diff line change
@@ -226,6 +226,8 @@ func NewDefaultProbeGroup(module *bpf.Module, netEnabled bool) (*ProbeGroup, err
SecuritySettime64: NewTraceProbe(KProbe, "security_settime64", "trace_security_settime64"),
Ptrace: NewTraceProbe(SyscallEnter, "ptrace", "trace_ptrace"),
PtraceRet: NewTraceProbe(SyscallExit, "ptrace", "trace_ret_ptrace"),
ProcessVmWritev: NewTraceProbe(SyscallEnter, "process_vm_writev", "trace_process_vm_writev"),
ProcessVmWritevRet: NewTraceProbe(SyscallExit, "process_vm_writev", "trace_ret_process_vm_writev"),

TestUnavailableHook: NewTraceProbe(KProbe, "non_existing_func", "empty_kprobe"),
ExecTest: NewTraceProbe(RawTracepoint, "raw_syscalls:sched_process_exec", "tracepoint__exec_test"),
2 changes: 2 additions & 0 deletions pkg/ebpf/probes/probes.go
Original file line number Diff line number Diff line change
@@ -152,6 +152,8 @@ const (
SecuritySettime64
Ptrace
PtraceRet
ProcessVmWritev
ProcessVmWritevRet
)

// Test probe handles
10 changes: 2 additions & 8 deletions pkg/events/core.go
Original file line number Diff line number Diff line change
@@ -7819,14 +7819,8 @@ var CoreEvents = map[ID]Definition{
},
dependencies: Dependencies{
probes: []Probe{
{handle: probes.SyscallEnter__Internal, required: true},
{handle: probes.SyscallExit__Internal, required: true},
},
tailCalls: []TailCall{
{"sys_enter_init_tail", "sys_enter_init", []uint32{uint32(ProcessVmWritev)}},
{"sys_enter_submit_tail", "sys_enter_submit", []uint32{uint32(ProcessVmWritev)}},
{"sys_exit_init_tail", "sys_exit_init", []uint32{uint32(ProcessVmWritev)}},
{"sys_exit_submit_tail", "sys_exit_submit", []uint32{uint32(ProcessVmWritev)}},
{handle: probes.ProcessVmWritev, required: true},
{handle: probes.ProcessVmWritevRet, required: true},
},
},
},