~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/bpf/progs/uretprobe_stack.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 /* Copyright (c) 2024 Meta Platforms, Inc. and affiliates. */
  3 #include <vmlinux.h>
  4 #include <bpf/bpf_helpers.h>
  5 #include <bpf/bpf_tracing.h>
  6 #include <bpf/usdt.bpf.h>
  7 
  8 char _license[] SEC("license") = "GPL";
  9 
 10 __u64 entry_stack1[32], exit_stack1[32];
 11 __u64 entry_stack1_recur[32], exit_stack1_recur[32];
 12 __u64 entry_stack2[32];
 13 __u64 entry_stack3[32];
 14 __u64 entry_stack4[32], exit_stack4[32];
 15 __u64 usdt_stack[32];
 16 
 17 int entry1_len, exit1_len;
 18 int entry1_recur_len, exit1_recur_len;
 19 int entry2_len, exit2_len;
 20 int entry3_len, exit3_len;
 21 int entry4_len, exit4_len;
 22 int usdt_len;
 23 
 24 #define SZ sizeof(usdt_stack)
 25 
 26 SEC("uprobe//proc/self/exe:target_1")
 27 int BPF_UPROBE(uprobe_1)
 28 {
 29         /* target_1 is recursive wit depth of 2, so we capture two separate
 30          * stack traces, depending on which occurence it is
 31          */
 32         static bool recur = false;
 33 
 34         if (!recur)
 35                 entry1_len = bpf_get_stack(ctx, &entry_stack1, SZ, BPF_F_USER_STACK);
 36         else
 37                 entry1_recur_len = bpf_get_stack(ctx, &entry_stack1_recur, SZ, BPF_F_USER_STACK);
 38 
 39         recur = true;
 40         return 0;
 41 }
 42 
 43 SEC("uretprobe//proc/self/exe:target_1")
 44 int BPF_URETPROBE(uretprobe_1)
 45 {
 46         /* see above, target_1 is recursive */
 47         static bool recur = false;
 48 
 49         /* NOTE: order of returns is reversed to order of entries */
 50         if (!recur)
 51                 exit1_recur_len = bpf_get_stack(ctx, &exit_stack1_recur, SZ, BPF_F_USER_STACK);
 52         else
 53                 exit1_len = bpf_get_stack(ctx, &exit_stack1, SZ, BPF_F_USER_STACK);
 54 
 55         recur = true;
 56         return 0;
 57 }
 58 
 59 SEC("uprobe//proc/self/exe:target_2")
 60 int BPF_UPROBE(uprobe_2)
 61 {
 62         entry2_len = bpf_get_stack(ctx, &entry_stack2, SZ, BPF_F_USER_STACK);
 63         return 0;
 64 }
 65 
 66 /* no uretprobe for target_2 */
 67 
 68 SEC("uprobe//proc/self/exe:target_3")
 69 int BPF_UPROBE(uprobe_3)
 70 {
 71         entry3_len = bpf_get_stack(ctx, &entry_stack3, SZ, BPF_F_USER_STACK);
 72         return 0;
 73 }
 74 
 75 /* no uretprobe for target_3 */
 76 
 77 SEC("uprobe//proc/self/exe:target_4")
 78 int BPF_UPROBE(uprobe_4)
 79 {
 80         entry4_len = bpf_get_stack(ctx, &entry_stack4, SZ, BPF_F_USER_STACK);
 81         return 0;
 82 }
 83 
 84 SEC("uretprobe//proc/self/exe:target_4")
 85 int BPF_URETPROBE(uretprobe_4)
 86 {
 87         exit4_len = bpf_get_stack(ctx, &exit_stack4, SZ, BPF_F_USER_STACK);
 88         return 0;
 89 }
 90 
 91 SEC("usdt//proc/self/exe:uretprobe_stack:target")
 92 int BPF_USDT(usdt_probe)
 93 {
 94         usdt_len = bpf_get_stack(ctx, &usdt_stack, SZ, BPF_F_USER_STACK);
 95         return 0;
 96 }
 97 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php