Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
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
12SEC("raw_tp/bpf_testmod_test_read")
13int 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 tp_btf_read_sz = 0;
21
22SEC("tp_btf/bpf_testmod_test_read")
23int BPF_PROG(handle_tp_btf,
24 struct task_struct *task, struct bpf_testmod_test_read_ctx *read_ctx)
25{
26 tp_btf_read_sz = read_ctx->len;
27 return 0;
28}
29
30__u32 fentry_read_sz = 0;
31
32SEC("fentry/bpf_testmod_test_read")
33int BPF_PROG(handle_fentry,
34 struct file *file, struct kobject *kobj,
35 struct bin_attribute *bin_attr, char *buf, loff_t off, size_t len)
36{
37 fentry_read_sz = len;
38 return 0;
39}
40
41__u32 fentry_manual_read_sz = 0;
42
43SEC("fentry/placeholder")
44int BPF_PROG(handle_fentry_manual,
45 struct file *file, struct kobject *kobj,
46 struct bin_attribute *bin_attr, char *buf, loff_t off, size_t len)
47{
48 fentry_manual_read_sz = len;
49 return 0;
50}
51
52__u32 fexit_read_sz = 0;
53int fexit_ret = 0;
54
55SEC("fexit/bpf_testmod_test_read")
56int BPF_PROG(handle_fexit,
57 struct file *file, struct kobject *kobj,
58 struct bin_attribute *bin_attr, char *buf, loff_t off, size_t len,
59 int ret)
60{
61 fexit_read_sz = len;
62 fexit_ret = ret;
63 return 0;
64}
65
66__u32 fmod_ret_read_sz = 0;
67
68SEC("fmod_ret/bpf_testmod_test_read")
69int BPF_PROG(handle_fmod_ret,
70 struct file *file, struct kobject *kobj,
71 struct bin_attribute *bin_attr, char *buf, loff_t off, size_t len)
72{
73 fmod_ret_read_sz = len;
74 return 0; /* don't override the exit code */
75}
76
77char _license[] SEC("license") = "GPL";