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): add path&ctime to module_load event #4235

Merged
merged 1 commit into from
Aug 15, 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
16 changes: 16 additions & 0 deletions pkg/ebpf/c/tracee.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -4320,6 +4320,22 @@ int tracepoint__module__module_load(struct bpf_raw_tracepoint_args *ctx)
if (!evaluate_scope_filters(&p))
return 0;

if (p.event->context.syscall == SYSCALL_FINIT_MODULE) {
struct pt_regs *task_regs = get_current_task_pt_regs();
int fd = get_syscall_arg1(p.event->task, task_regs, false);
struct file *file = get_struct_file_from_fd(fd);
void *file_path = get_path_str(__builtin_preserve_access_index(&file->f_path));
dev_t dev = get_dev_from_file(file);
unsigned long inode = get_inode_nr_from_file(file);
u64 ctime = get_ctime_nanosec_from_file(file);

// add file related info
save_str_to_buf(&p.event->args_buf, file_path, 3);
save_to_submit_buf(&p.event->args_buf, &dev, sizeof(dev_t), 4);
save_to_submit_buf(&p.event->args_buf, &inode, sizeof(unsigned long), 5);
save_to_submit_buf(&p.event->args_buf, &ctime, sizeof(u64), 6);
}

const char *version = BPF_CORE_READ(mod, version);
const char *srcversion = BPF_CORE_READ(mod, srcversion);
save_str_to_buf(&p.event->args_buf, &mod->name, 0);
Expand Down
4 changes: 4 additions & 0 deletions pkg/events/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -12499,6 +12499,10 @@ var CoreEvents = map[ID]Definition{
{Type: "const char*", Name: "name"},
{Type: "const char*", Name: "version"},
{Type: "const char*", Name: "src_version"},
{Type: "const char*", Name: "pathname"},
{Type: "dev_t", Name: "dev"},
{Type: "unsigned long", Name: "inode"},
{Type: "u64", Name: "ctime"},
},
},
ModuleFree: {
Expand Down
Loading