10000 feat(ebpf): make security_socket_accept not rely on sys_enter/exit by OriGlassman · Pull Request #4213 · aquasecurity/tracee · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(ebpf): make security_socket_accept not rely on sys_enter/exit #4213

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

Merged
merged 1 commit into from
Aug 13, 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
14 changes: 9 additions & 5 deletions pkg/ebpf/c/tracee.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -2682,13 +2682,14 @@ int BPF_KPROBE(trace_security_socket_accept)

struct socket *sock = (struct socket *) PT_REGS_PARM1(ctx);
struct socket *new_sock = (struct socket *) PT_REGS_PARM2(ctx);
syscall_data_t *sys = &p.task_info->syscall_data;

struct pt_regs *task_regs = get_current_task_pt_regs();

if (event_is_selected(SOCKET_ACCEPT, p.event->context.policies_version)) {
args_t args = {};
args.args[0] = (unsigned long) sock;
args.args[1] = (unsigned long) new_sock;
args.args[2] = sys->args.args[0]; // sockfd
args.args[2] = get_syscall_arg1(p.event->task, task_regs, false); // sockfd
save_args(&args, SOCKET_ACCEPT);
}

Expand All @@ -2699,14 +2700,17 @@ int BPF_KPROBE(trace_security_socket_accept)
if (!p.task_info->syscall_traced)
return 0;

switch (sys->id) {
int sockfd;
switch (p.event->context.syscall) {
case SYSCALL_ACCEPT:
case SYSCALL_ACCEPT4:
save_to_submit_buf(&p.event->args_buf, (void *) &sys->args.args[0], sizeof(u32), 0);
sockfd = get_syscall_arg1(p.event->task, task_regs, false);
save_to_submit_buf(&p.event->args_buf, (void *) &sockfd, sizeof(int), 0);
break;
#if defined(bpf_target_x86) // armhf makes use of SYSCALL_ACCEPT/4
case SYSCALL_SOCKETCALL:
save_to_submit_buf(&p.event->args_buf, (void *) sys->args.args[1], sizeof(u32), 0);
sockfd = get_syscall_arg2(p.event->task, task_regs, false);
save_to_submit_buf(&p.event->args_buf, (void *) &sockfd, sizeof(int), 0);
break;
#endif
default:
Expand Down
4 changes: 0 additions & 4 deletions pkg/events/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -11646,10 +11646,6 @@ var CoreEvents = map[ID]Definition{
dependencies: Dependencies{
probes: []Probe{
{handle: probes.SecuritySocketAccept, required: true},
{handle: probes.SyscallEnter__Internal, required: true},
},
tailCalls: []TailCall{
{"sys_enter_init_tail", "sys_enter_init", []uint32{uint32(Accept), uint32(Accept4)}},
},
},
sets: []string{"default", "lsm_hooks", "net", "net_sock"},
Expand 4253 Down
Loading
0