/* non exhaustive list of sleepable bpf_lsm_*() functions */
BTF_SET_START(btf_sleepable_lsm_hooks)
#ifdef CONFIG_BPF_LSM
-BTF_ID(func, bpf_lsm_file_mprotect)
BTF_ID(func, bpf_lsm_bprm_committed_creds)
#else
BTF_ID_UNUSED
int mprotect_count = 0;
int bprm_count = 0;
-SEC("lsm.s/file_mprotect")
+SEC("lsm/file_mprotect")
int BPF_PROG(test_int_hook, struct vm_area_struct *vma,
unsigned long reqprot, unsigned long prot, int ret)
{
- char args[64];
- __u32 key = 0;
- __u64 *value;
-
if (ret != 0)
return ret;
is_stack = (vma->vm_start <= vma->vm_mm->start_stack &&
vma->vm_end >= vma->vm_mm->start_stack);
- bpf_copy_from_user(args, sizeof(args), (void *)vma->vm_mm->arg_start);
-
- value = bpf_map_lookup_elem(&array, &key);
- if (value)
- *value = 0;
- value = bpf_map_lookup_elem(&hash, &key);
- if (value)
- *value = 0;
- value = bpf_map_lookup_elem(&lru_hash, &key);
- if (value)
- *value = 0;
-
if (is_stack && monitored_pid == pid) {
mprotect_count++;
ret = -EPERM;
int BPF_PROG(test_void_hook, struct linux_binprm *bprm)
{
__u32 pid = bpf_get_current_pid_tgid() >> 32;
+ char args[64];
+ __u32 key = 0;
+ __u64 *value;
if (monitored_pid == pid)
bprm_count++;
+ bpf_copy_from_user(args, sizeof(args), (void *)bprm->vma->vm_mm->arg_start);
+ bpf_copy_from_user(args, sizeof(args), (void *)bprm->mm->arg_start);
+
+ value = bpf_map_lookup_elem(&array, &key);
+ if (value)
+ *value = 0;
+ value = bpf_map_lookup_elem(&hash, &key);
+ if (value)
+ *value = 0;
+ value = bpf_map_lookup_elem(&lru_hash, &key);
+ if (value)
+ *value = 0;
+
return 0;
}
SEC("lsm/task_free") /* lsm/ is ok, lsm.s/ fails */