1 // SPDX-License-Identifier: GPL-2.0
4 * Copyright 2020 Google LLC.
8 #include <bpf/bpf_helpers.h>
9 #include <bpf/bpf_tracing.h>
12 char _license[] SEC("license") = "GPL";
14 int monitored_pid = 0;
15 int mprotect_count = 0;
18 SEC("lsm/file_mprotect")
19 int BPF_PROG(test_int_hook, struct vm_area_struct *vma,
20 unsigned long reqprot, unsigned long prot, int ret)
25 __u32 pid = bpf_get_current_pid_tgid() >> 32;
28 is_heap = (vma->vm_start >= vma->vm_mm->start_brk &&
29 vma->vm_end <= vma->vm_mm->brk);
31 if (is_heap && monitored_pid == pid) {
39 SEC("lsm/bprm_committed_creds")
40 int BPF_PROG(test_void_hook, struct linux_binprm *bprm)
42 __u32 pid = bpf_get_current_pid_tgid() >> 32;
44 if (monitored_pid == pid)