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

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

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ 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) 2020 Facebook */
  3 
  4 #include "vmlinux.h"
  5 #include <bpf/bpf_helpers.h>
  6 #include <bpf/bpf_tracing.h>
  7 #include <bpf/bpf_core_read.h>
  8 #include "../bpf_testmod/bpf_testmod.h"
  9 
 10 __u32 raw_tp_read_sz = 0;
 11 
 12 SEC("raw_tp/bpf_testmod_test_read")
 13 int BPF_PROG(handle_raw_tp,
 14              struct task_struct *task, struct bpf_testmod_test_read_ctx *read_ctx)
 15 {
 16         raw_tp_read_sz = BPF_CORE_READ(read_ctx, len);
 17         return 0;
 18 }
 19 
 20 __u32 raw_tp_bare_write_sz = 0;
 21 
 22 SEC("raw_tp/bpf_testmod_test_write_bare")
 23 int BPF_PROG(handle_raw_tp_bare,
 24              struct task_struct *task, struct bpf_testmod_test_write_ctx *write_ctx)
 25 {
 26         raw_tp_bare_write_sz = BPF_CORE_READ(write_ctx, len);
 27         return 0;
 28 }
 29 
 30 int raw_tp_writable_bare_in_val = 0;
 31 int raw_tp_writable_bare_early_ret = 0;
 32 int raw_tp_writable_bare_out_val = 0;
 33 
 34 SEC("raw_tp.w/bpf_testmod_test_writable_bare")
 35 int BPF_PROG(handle_raw_tp_writable_bare,
 36              struct bpf_testmod_test_writable_ctx *writable)
 37 {
 38         raw_tp_writable_bare_in_val = writable->val;
 39         writable->early_ret = raw_tp_writable_bare_early_ret;
 40         writable->val = raw_tp_writable_bare_out_val;
 41         return 0;
 42 }
 43 
 44 __u32 tp_btf_read_sz = 0;
 45 
 46 SEC("tp_btf/bpf_testmod_test_read")
 47 int BPF_PROG(handle_tp_btf,
 48              struct task_struct *task, struct bpf_testmod_test_read_ctx *read_ctx)
 49 {
 50         tp_btf_read_sz = read_ctx->len;
 51         return 0;
 52 }
 53 
 54 __u32 fentry_read_sz = 0;
 55 
 56 SEC("fentry/bpf_testmod_test_read")
 57 int BPF_PROG(handle_fentry,
 58              struct file *file, struct kobject *kobj,
 59              struct bin_attribute *bin_attr, char *buf, loff_t off, size_t len)
 60 {
 61         fentry_read_sz = len;
 62         return 0;
 63 }
 64 
 65 __u32 fentry_manual_read_sz = 0;
 66 
 67 SEC("fentry")
 68 int BPF_PROG(handle_fentry_manual,
 69              struct file *file, struct kobject *kobj,
 70              struct bin_attribute *bin_attr, char *buf, loff_t off, size_t len)
 71 {
 72         fentry_manual_read_sz = len;
 73         return 0;
 74 }
 75 
 76 __u32 fentry_explicit_read_sz = 0;
 77 
 78 SEC("fentry/bpf_testmod:bpf_testmod_test_read")
 79 int BPF_PROG(handle_fentry_explicit,
 80              struct file *file, struct kobject *kobj,
 81              struct bin_attribute *bin_attr, char *buf, loff_t off, size_t len)
 82 {
 83         fentry_explicit_read_sz = len;
 84         return 0;
 85 }
 86 
 87 
 88 __u32 fentry_explicit_manual_read_sz = 0;
 89 
 90 SEC("fentry")
 91 int BPF_PROG(handle_fentry_explicit_manual,
 92              struct file *file, struct kobject *kobj,
 93              struct bin_attribute *bin_attr, char *buf, loff_t off, size_t len)
 94 {
 95         fentry_explicit_manual_read_sz = len;
 96         return 0;
 97 }
 98 
 99 __u32 fexit_read_sz = 0;
100 int fexit_ret = 0;
101 
102 SEC("fexit/bpf_testmod_test_read")
103 int BPF_PROG(handle_fexit,
104              struct file *file, struct kobject *kobj,
105              struct bin_attribute *bin_attr, char *buf, loff_t off, size_t len,
106              int ret)
107 {
108         fexit_read_sz = len;
109         fexit_ret = ret;
110         return 0;
111 }
112 
113 SEC("fexit/bpf_testmod_return_ptr")
114 int BPF_PROG(handle_fexit_ret, int arg, struct file *ret)
115 {
116         long buf = 0;
117 
118         bpf_probe_read_kernel(&buf, 8, ret);
119         bpf_probe_read_kernel(&buf, 8, (char *)ret + 256);
120         *(volatile long long *)ret;
121         *(volatile int *)&ret->f_mode;
122         return 0;
123 }
124 
125 __u32 fmod_ret_read_sz = 0;
126 
127 SEC("fmod_ret/bpf_testmod_test_read")
128 int BPF_PROG(handle_fmod_ret,
129              struct file *file, struct kobject *kobj,
130              struct bin_attribute *bin_attr, char *buf, loff_t off, size_t len)
131 {
132         fmod_ret_read_sz = len;
133         return 0; /* don't override the exit code */
134 }
135 
136 SEC("kprobe.multi/bpf_testmod_test_read")
137 int BPF_PROG(kprobe_multi)
138 {
139         return 0;
140 }
141 
142 char _license[] SEC("license") = "GPL";
143 

~ [ 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