0001
0002
0003
0004
0005
0006
0007
0008 #include <linux/ptrace.h>
0009 #include <uapi/linux/bpf.h>
0010 #include <linux/version.h>
0011 #include <bpf/bpf_helpers.h>
0012 #include <uapi/linux/utsname.h>
0013 #include "trace_common.h"
0014
0015 struct {
0016 __uint(type, BPF_MAP_TYPE_CGROUP_ARRAY);
0017 __uint(key_size, sizeof(u32));
0018 __uint(value_size, sizeof(u32));
0019 __uint(max_entries, 1);
0020 } cgroup_map SEC(".maps");
0021
0022 struct {
0023 __uint(type, BPF_MAP_TYPE_ARRAY);
0024 __type(key, u32);
0025 __type(value, u64);
0026 __uint(max_entries, 1);
0027 } perf_map SEC(".maps");
0028
0029
0030 SEC("kprobe/" SYSCALL(sys_sync))
0031 int bpf_prog1(struct pt_regs *ctx)
0032 {
0033 u64 pid = bpf_get_current_pid_tgid();
0034 int idx = 0;
0035
0036 if (!bpf_current_task_under_cgroup(&cgroup_map, 0))
0037 return 0;
0038
0039 bpf_map_update_elem(&perf_map, &idx, &pid, BPF_ANY);
0040 return 0;
0041 }
0042
0043 char _license[] SEC("license") = "GPL";
0044 u32 _version SEC("version") = LINUX_VERSION_CODE;