1c4781e37SAlexei Starovoitov // SPDX-License-Identifier: GPL-2.0
2c4781e37SAlexei Starovoitov /* Copyright (c) 2019 Facebook */
3ac065870SAndrii Nakryiko #include <stdbool.h>
4ac065870SAndrii Nakryiko #include <stddef.h>
5c4781e37SAlexei Starovoitov #include <linux/bpf.h>
6ac065870SAndrii Nakryiko #include <linux/ptrace.h>
73e689141SToke Høiland-Jørgensen #include <bpf/bpf_helpers.h>
83e689141SToke Høiland-Jørgensen #include <bpf/bpf_tracing.h>
9c4781e37SAlexei Starovoitov
10ac065870SAndrii Nakryiko struct task_struct;
11ac065870SAndrii Nakryiko
12c4781e37SAlexei Starovoitov SEC("kprobe/__set_task_comm")
BPF_KPROBE(prog1,struct task_struct * tsk,const char * buf,bool exec)13ac065870SAndrii Nakryiko int BPF_KPROBE(prog1, struct task_struct *tsk, const char *buf, bool exec)
14c4781e37SAlexei Starovoitov {
15ac065870SAndrii Nakryiko return !tsk;
16c4781e37SAlexei Starovoitov }
17c4781e37SAlexei Starovoitov
18c4781e37SAlexei Starovoitov SEC("kretprobe/__set_task_comm")
BPF_KRETPROBE(prog2,int ret)19396f544eSAndrii Nakryiko int BPF_KRETPROBE(prog2, int ret)
20c4781e37SAlexei Starovoitov {
21396f544eSAndrii Nakryiko return ret;
22c4781e37SAlexei Starovoitov }
23c4781e37SAlexei Starovoitov
24c4781e37SAlexei Starovoitov SEC("raw_tp/task_rename")
prog3(struct bpf_raw_tracepoint_args * ctx)25c4781e37SAlexei Starovoitov int prog3(struct bpf_raw_tracepoint_args *ctx)
26c4781e37SAlexei Starovoitov {
27ac065870SAndrii Nakryiko return !ctx->args[0];
28c4781e37SAlexei Starovoitov }
29c4781e37SAlexei Starovoitov
30ac065870SAndrii Nakryiko SEC("fentry/__set_task_comm")
BPF_PROG(prog4,struct task_struct * tsk,const char * buf,bool exec)31ac065870SAndrii Nakryiko int BPF_PROG(prog4, struct task_struct *tsk, const char *buf, bool exec)
32c4781e37SAlexei Starovoitov {
33*6d74f64bSYonghong Song return 0;
34c4781e37SAlexei Starovoitov }
35c4781e37SAlexei Starovoitov
36ac065870SAndrii Nakryiko SEC("fexit/__set_task_comm")
BPF_PROG(prog5,struct task_struct * tsk,const char * buf,bool exec)37ac065870SAndrii Nakryiko int BPF_PROG(prog5, struct task_struct *tsk, const char *buf, bool exec)
38c4781e37SAlexei Starovoitov {
39*6d74f64bSYonghong Song return 0;
40c4781e37SAlexei Starovoitov }
41c4781e37SAlexei Starovoitov
42c4781e37SAlexei Starovoitov char _license[] SEC("license") = "GPL";
43