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

process_execute_failed: don't rely on sys_enter #4259

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
Loading