1 // SPDX-License-Identifier: GPL-2.0
3 #include <bpf/bpf_helpers.h>
4 #include <bpf/bpf_tracing.h>
6 #include "bpf_kfuncs.h"
9 char _license[] SEC("license") = "GPL";
16 __u64 test_uprobe_cookie_entry[6];
17 __u64 test_uprobe_cookie_return[3];
19 static int check_cookie(void)
21 __u64 *cookie = bpf_session_cookie();
23 if (bpf_session_is_return()) {
24 if (idx_return >= ARRAY_SIZE(test_uprobe_cookie_return))
26 test_uprobe_cookie_return[idx_return++] = *cookie;
30 if (idx_entry >= ARRAY_SIZE(test_uprobe_cookie_entry))
32 *cookie = test_uprobe_cookie_entry[idx_entry];
33 return idx_entry++ % 2;
37 SEC("uprobe.session//proc/self/exe:uprobe_session_recursive")
38 int uprobe_recursive(struct pt_regs *ctx)
40 if (bpf_get_current_pid_tgid() >> 32 != pid)
43 return check_cookie();