Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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