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 v6.5-rc7 85 lines 1.9 kB view raw
1// SPDX-License-Identifier: GPL-2.0 2#include <linux/bpf.h> 3#include <bpf/bpf_helpers.h> 4#include <bpf/bpf_tracing.h> 5#include <stdbool.h> 6 7char _license[] SEC("license") = "GPL"; 8 9extern const void bpf_fentry_test1 __ksym; 10extern const void bpf_fentry_test2 __ksym; 11extern const void bpf_fentry_test3 __ksym; 12extern const void bpf_fentry_test4 __ksym; 13extern const void bpf_modify_return_test __ksym; 14extern const void bpf_fentry_test6 __ksym; 15extern const void bpf_fentry_test7 __ksym; 16 17extern bool CONFIG_X86_KERNEL_IBT __kconfig __weak; 18 19/* This function is here to have CONFIG_X86_KERNEL_IBT 20 * used and added to object BTF. 21 */ 22int unused(void) 23{ 24 return CONFIG_X86_KERNEL_IBT ? 0 : 1; 25} 26 27__u64 test1_result = 0; 28SEC("fentry/bpf_fentry_test1") 29int BPF_PROG(test1, int a) 30{ 31 __u64 addr = bpf_get_func_ip(ctx); 32 33 test1_result = (const void *) addr == &bpf_fentry_test1; 34 return 0; 35} 36 37__u64 test2_result = 0; 38SEC("fexit/bpf_fentry_test2") 39int BPF_PROG(test2, int a) 40{ 41 __u64 addr = bpf_get_func_ip(ctx); 42 43 test2_result = (const void *) addr == &bpf_fentry_test2; 44 return 0; 45} 46 47__u64 test3_result = 0; 48SEC("kprobe/bpf_fentry_test3") 49int test3(struct pt_regs *ctx) 50{ 51 __u64 addr = bpf_get_func_ip(ctx); 52 53 test3_result = (const void *) addr == &bpf_fentry_test3; 54 return 0; 55} 56 57__u64 test4_result = 0; 58SEC("kretprobe/bpf_fentry_test4") 59int BPF_KRETPROBE(test4) 60{ 61 __u64 addr = bpf_get_func_ip(ctx); 62 63 test4_result = (const void *) addr == &bpf_fentry_test4; 64 return 0; 65} 66 67__u64 test5_result = 0; 68SEC("fmod_ret/bpf_modify_return_test") 69int BPF_PROG(test5, int a, int *b, int ret) 70{ 71 __u64 addr = bpf_get_func_ip(ctx); 72 73 test5_result = (const void *) addr == &bpf_modify_return_test; 74 return ret; 75} 76 77__u64 test6_result = 0; 78SEC("?kprobe") 79int test6(struct pt_regs *ctx) 80{ 81 __u64 addr = bpf_get_func_ip(ctx); 82 83 test6_result = (const void *) addr == 0; 84 return 0; 85}