Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
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
8int kprobe_res = 0;
9int kretprobe_res = 0;
10int uprobe_res = 0;
11int uretprobe_res = 0;
12
13SEC("kprobe/sys_nanosleep")
14int handle_kprobe(struct pt_regs *ctx)
15{
16 kprobe_res = 1;
17 return 0;
18}
19
20SEC("kretprobe/sys_nanosleep")
21int handle_kretprobe(struct pt_regs *ctx)
22{
23 kretprobe_res = 2;
24 return 0;
25}
26
27SEC("uprobe/trigger_func")
28int handle_uprobe(struct pt_regs *ctx)
29{
30 uprobe_res = 3;
31 return 0;
32}
33
34SEC("uretprobe/trigger_func")
35int handle_uretprobe(struct pt_regs *ctx)
36{
37 uretprobe_res = 4;
38 return 0;
39}
40
41char _license[] SEC("license") = "GPL";