1// SPDX-License-Identifier: GPL-2.0
2/* Copyright (c) 2023 Hengqi Chen */
3
4#include "vmlinux.h"
5#include <bpf/bpf_helpers.h>
6#include <bpf/bpf_tracing.h>
7
8pid_t my_pid = 0;
9
10int test1_result = 0;
11int test2_result = 0;
12int test3_result = 0;
13int test4_result = 0;
14
15SEC("uprobe/./liburandom_read.so:urandlib_api_sameoffset")
16int BPF_UPROBE(test1)
17{
18	pid_t pid = bpf_get_current_pid_tgid() >> 32;
19
20	if (pid != my_pid)
21		return 0;
22
23	test1_result = 1;
24	return 0;
25}
26
27SEC("uprobe/./liburandom_read.so:urandlib_api_sameoffset@LIBURANDOM_READ_1.0.0")
28int BPF_UPROBE(test2)
29{
30	pid_t pid = bpf_get_current_pid_tgid() >> 32;
31
32	if (pid != my_pid)
33		return 0;
34
35	test2_result = 1;
36	return 0;
37}
38
39SEC("uretprobe/./liburandom_read.so:urandlib_api_sameoffset@@LIBURANDOM_READ_2.0.0")
40int BPF_URETPROBE(test3, int ret)
41{
42	pid_t pid = bpf_get_current_pid_tgid() >> 32;
43
44	if (pid != my_pid)
45		return 0;
46
47	test3_result = ret;
48	return 0;
49}
50
51SEC("uprobe")
52int BPF_UPROBE(test4)
53{
54	pid_t pid = bpf_get_current_pid_tgid() >> 32;
55
56	if (pid != my_pid)
57		return 0;
58
59	test4_result = 1;
60	return 0;
61}
62