Created
March 2, 2021 19:11
-
-
Save grantseltzer/bf0cc4dc0c68407b95823693ae52e514 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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