1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2020 Facebook
4 #include <bpf/bpf_helpers.h>
5 #include <bpf/bpf_core_read.h>
9 } __attribute__((preserve_access_index));
12 __uint(type, BPF_MAP_TYPE_ARRAY);
13 __uint(max_entries, 1);
16 } exp_tgid_map SEC(".maps");
19 __uint(type, BPF_MAP_TYPE_ARRAY);
20 __uint(max_entries, 1);
23 } results SEC(".maps");
25 SEC("tp/raw_syscalls/sys_enter")
26 int handle_sys_enter(void *ctx)
28 struct task_struct *task = (void *)bpf_get_current_task();
29 int tgid = BPF_CORE_READ(task, tgid);
31 int real_tgid = bpf_get_current_pid_tgid() >> 32;
32 int *exp_tgid = bpf_map_lookup_elem(&exp_tgid_map, &zero);
34 /* only pass through sys_enters from test process */
35 if (!exp_tgid || *exp_tgid != real_tgid)
38 bpf_map_update_elem(&results, &zero, &tgid, 0);
43 char _license[] SEC("license") = "GPL";