1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2017 Facebook
3 
4 #include <linux/ptrace.h>
5 #include <linux/bpf.h>
6 #include <bpf/bpf_helpers.h>
7 
8 int kprobe_res = 0;
9 int kretprobe_res = 0;
10 int uprobe_res = 0;
11 int uretprobe_res = 0;
12 
13 SEC("kprobe/sys_nanosleep")
14 int handle_kprobe(struct pt_regs *ctx)
15 {
16 	kprobe_res = 1;
17 	return 0;
18 }
19 
20 SEC("kretprobe/sys_nanosleep")
21 int handle_kretprobe(struct pt_regs *ctx)
22 {
23 	kretprobe_res = 2;
24 	return 0;
25 }
26 
27 SEC("uprobe/trigger_func")
28 int handle_uprobe(struct pt_regs *ctx)
29 {
30 	uprobe_res = 3;
31 	return 0;
32 }
33 
34 SEC("uretprobe/trigger_func")
35 int handle_uretprobe(struct pt_regs *ctx)
36 {
37 	uretprobe_res = 4;
38 	return 0;
39 }
40 
41 char _license[] SEC("license") = "GPL";
42