Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /* Copyright (c) 2020 Facebook */
0003 
0004 #include "vmlinux.h"
0005 #include <bpf/bpf_helpers.h>
0006 #include <bpf/bpf_tracing.h>
0007 #include <bpf/bpf_core_read.h>
0008 
0009 bool prog1_called = false;
0010 bool prog2_called = false;
0011 bool prog3_called = false;
0012 
0013 SEC("raw_tp/sys_enter")
0014 int prog1(const void *ctx)
0015 {
0016     prog1_called = true;
0017     return 0;
0018 }
0019 
0020 SEC("raw_tp/sys_exit")
0021 int prog2(const void *ctx)
0022 {
0023     prog2_called = true;
0024     return 0;
0025 }
0026 
0027 struct fake_kernel_struct {
0028     int whatever;
0029 } __attribute__((preserve_access_index));
0030 
0031 SEC("fentry/unexisting-kprobe-will-fail-if-loaded")
0032 int prog3(const void *ctx)
0033 {
0034     struct fake_kernel_struct *fake = (void *)ctx;
0035     fake->whatever = 123;
0036     prog3_called = true;
0037     return 0;
0038 }
0039 
0040 char _license[] SEC("license") = "GPL";