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 
9 bool prog1_called = false;
10 bool prog2_called = false;
11 bool prog3_called = false;
12 
13 SEC("raw_tp/sys_enter")
prog1(const void * ctx)14 int prog1(const void *ctx)
15 {
16 	prog1_called = true;
17 	return 0;
18 }
19 
20 SEC("raw_tp/sys_exit")
prog2(const void * ctx)21 int prog2(const void *ctx)
22 {
23 	prog2_called = true;
24 	return 0;
25 }
26 
27 struct fake_kernel_struct {
28 	int whatever;
29 } __attribute__((preserve_access_index));
30 
31 SEC("fentry/unexisting-kprobe-will-fail-if-loaded")
prog3(const void * ctx)32 int prog3(const void *ctx)
33 {
34 	struct fake_kernel_struct *fake = (void *)ctx;
35 	fake->whatever = 123;
36 	prog3_called = true;
37 	return 0;
38 }
39 
40 char _license[] SEC("license") = "GPL";
41