1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2022, Oracle and/or its affiliates. */
6 #include <bpf/bpf_core_read.h>
7 #include <bpf/bpf_helpers.h>
8 #include <bpf/bpf_tracing.h>
11 int uprobe_byname_parm1 = 0;
12 int uprobe_byname_ran = 0;
13 int uretprobe_byname_rc = 0;
14 int uretprobe_byname_ret = 0;
15 int uretprobe_byname_ran = 0;
16 u64 uprobe_byname2_parm1 = 0;
17 int uprobe_byname2_ran = 0;
18 u64 uretprobe_byname2_rc = 0;
19 int uretprobe_byname2_ran = 0;
25 /* This program cannot auto-attach, but that should not stop other
26 * programs from attaching.
29 int handle_uprobe_noautoattach(struct pt_regs *ctx)
34 SEC("uprobe//proc/self/exe:autoattach_trigger_func")
35 int BPF_UPROBE(handle_uprobe_byname
39 #if FUNC_REG_ARG_CNT > 3
42 #if FUNC_REG_ARG_CNT > 4
45 #if FUNC_REG_ARG_CNT > 5
48 #if FUNC_REG_ARG_CNT > 6
51 #if FUNC_REG_ARG_CNT > 7
56 uprobe_byname_parm1 = PT_REGS_PARM1_CORE(ctx);
57 uprobe_byname_ran = 1;
62 #if FUNC_REG_ARG_CNT > 3
65 #if FUNC_REG_ARG_CNT > 4
68 #if FUNC_REG_ARG_CNT > 5
71 #if FUNC_REG_ARG_CNT > 6
74 #if FUNC_REG_ARG_CNT > 7
80 SEC("uretprobe//proc/self/exe:autoattach_trigger_func")
81 int BPF_URETPROBE(handle_uretprobe_byname, int ret)
83 uretprobe_byname_rc = PT_REGS_RC_CORE(ctx);
84 uretprobe_byname_ret = ret;
85 uretprobe_byname_ran = 2;
91 SEC("uprobe/libc.so.6:fopen")
92 int BPF_UPROBE(handle_uprobe_byname2, const char *pathname, const char *mode)
94 int pid = bpf_get_current_pid_tgid() >> 32;
96 /* ignore irrelevant invocations */
99 uprobe_byname2_parm1 = (u64)(long)pathname;
100 uprobe_byname2_ran = 3;
104 SEC("uretprobe/libc.so.6:fopen")
105 int BPF_URETPROBE(handle_uretprobe_byname2, void *ret)
107 int pid = bpf_get_current_pid_tgid() >> 32;
109 /* ignore irrelevant invocations */
112 uretprobe_byname2_rc = (u64)(long)ret;
113 uretprobe_byname2_ran = 4;
117 char _license[] SEC("license") = "GPL";