Skip to content

Instantly share code, notes, and snippets.

@grantseltzer
Created March 2, 2021 19:11
Show Gist options
  • Save grantseltzer/bf0cc4dc0c68407b95823693ae52e514 to your computer and use it in GitHub Desktop.
Save grantseltzer/bf0cc4dc0c68407b95823693ae52e514 to your computer and use it in GitHub Desktop.
SEC("kprobe/sys_mmap")
int kprobe__sys_mmap(struct pt_regs *ctx)
{
__u64 id = bpf_get_current_pid_tgid();
__u32 tgid = id >> 32;
struct process_info *process;
// Reserve space on the ringbuffer for the sample
process = bpf_ringbuf_reserve(&events, sizeof(struct process_info), ringbuffer_flags);
if (!process) {
return 0;
}
process->pid = tgid;
bpf_get_current_comm(&process->comm, 100);
bpf_ringbuf_submit(process, ringbuffer_flags);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment