Skip to content

Commit

Permalink
process_execute_failed: don't rely on sys_enter (#4259)
Browse files Browse the repository at this point in the history
  • Loading branch information
oshaked1 authored Aug 22, 2024
1 parent a325d64 commit 4df40aa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
18 changes: 13 additions & 5 deletions pkg/ebpf/c/tracee.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -4984,13 +4984,21 @@ statfunc int execute_failed_tail2(struct pt_regs *ctx)
if (!init_tailcall_program_data(&p, ctx))
return -1;

syscall_data_t *sys = &p.task_info->syscall_data;
save_str_arr_to_buf(
&p.event->args_buf, (const char *const *) sys->args.args[1], 10); // userspace argv
long long argv, envp;
struct pt_regs *regs = get_current_task_pt_regs();

if (p.event->context.syscall == SYSCALL_EXECVE) {
argv = get_syscall_arg2(p.event->task, regs, false);
envp = get_syscall_arg3(p.event->task, regs, false);
} else {
argv = get_syscall_arg3(p.event->task, regs, false);
envp = get_syscall_arg4(p.event->task, regs, false);
}

save_str_arr_to_buf(&p.event->args_buf, (const char *const *) argv, 10); // userspace argv

if (p.config->options & OPT_EXEC_ENV) {
save_str_arr_to_buf(
&p.event->args_buf, (const char *const *) sys->args.args[2], 11); // userspace envp
save_str_arr_to_buf(&p.event->args_buf, (const char *const *) envp, 11); // userspace envp
}

int ret = PT_REGS_RC(ctx); // needs to be int
Expand Down
1 change: 0 additions & 1 deletion pkg/events/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -12954,7 +12954,6 @@ var CoreEvents = map[ID]Definition{
probes: []Probe{
{handle: probes.ExecBinprm, required: false},
{handle: probes.ExecBinprmRet, required: false},
{handle: probes.SyscallEnter__Internal, required: true},
},
tailCalls: []TailCall{
{"prog_array", "trace_execute_failed1", []uint32{TailProcessExecuteFailed1}},
Expand Down

0 comments on commit 4df40aa

Please sign in to comment.