Loading...
Note: File does not exist in v6.8.
1// SPDX-License-Identifier: GPL-2.0
2#include <linux/bpf.h>
3#include <bpf/bpf_helpers.h>
4#include <bpf/bpf_tracing.h>
5#include <stdbool.h>
6#include "bpf_kfuncs.h"
7#include "bpf_misc.h"
8
9char _license[] SEC("license") = "GPL";
10
11int pid = 0;
12
13int idx_entry = 0;
14int idx_return = 0;
15
16__u64 test_uprobe_cookie_entry[6];
17__u64 test_uprobe_cookie_return[3];
18
19static int check_cookie(void)
20{
21 __u64 *cookie = bpf_session_cookie();
22
23 if (bpf_session_is_return()) {
24 if (idx_return >= ARRAY_SIZE(test_uprobe_cookie_return))
25 return 1;
26 test_uprobe_cookie_return[idx_return++] = *cookie;
27 return 0;
28 }
29
30 if (idx_entry >= ARRAY_SIZE(test_uprobe_cookie_entry))
31 return 1;
32 *cookie = test_uprobe_cookie_entry[idx_entry];
33 return idx_entry++ % 2;
34}
35
36
37SEC("uprobe.session//proc/self/exe:uprobe_session_recursive")
38int uprobe_recursive(struct pt_regs *ctx)
39{
40 if (bpf_get_current_pid_tgid() >> 32 != pid)
41 return 1;
42
43 return check_cookie();
44}