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

feat(ebpf): optimize sendmsg/recvmsg kprobes #3766

Merged
Merged
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
26 changes: 16 additions & 10 deletions pkg/ebpf/c/tracee.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -5373,12 +5373,6 @@ int BPF_KPROBE(trace_security_sk_clone)

statfunc u32 update_net_inodemap(struct socket *sock, event_data_t *event)
{
if (!is_family_supported(sock))
return 0;

if (!is_socket_supported(sock))
return 0;

struct file *sock_file = BPF_CORE_READ(sock, file);
if (!sock_file)
return 0;
Expand All @@ -5399,30 +5393,42 @@ statfunc u32 update_net_inodemap(struct socket *sock, event_data_t *event)
SEC("kprobe/security_socket_recvmsg")
int BPF_KPROBE(trace_security_socket_recvmsg)
{
struct socket *sock = (void *) PT_REGS_PARM1(ctx);
if (sock == NULL)
return 0;
if (!is_family_supported(sock))
return 0;
if (!is_socket_supported(sock))
return 0;

program_data_t p = {};
if (!init_program_data(&p, ctx))
return 0;

if (!should_trace(&p))
return 0;

struct socket *sock = (void *) PT_REGS_PARM1(ctx);

return update_net_inodemap(sock, p.event);
}

SEC("kprobe/security_socket_sendmsg")
int BPF_KPROBE(trace_security_socket_sendmsg)
{
struct socket *sock = (void *) PT_REGS_PARM1(ctx);
if (sock == NULL)
return 0;
if (!is_family_supported(sock))
return 0;
if (!is_socket_supported(sock))
return 0;

program_data_t p = {};
if (!init_program_data(&p, ctx))
return 0;

if (!should_trace(&p))
return 0;

struct socket *sock = (void *) PT_REGS_PARM1(ctx);

return update_net_inodemap(sock, p.event);
}

Expand Down
Loading