• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2019 Facebook
3 
4 #include <linux/bpf.h>
5 #include <stdint.h>
6 #include "bpf_helpers.h"
7 
8 char _license[] SEC("license") = "GPL";
9 
10 static volatile struct data {
11 	char in[256];
12 	char out[256];
13 } data;
14 
15 struct core_reloc_mods_output {
16 	int a, b, c, d, e, f, g, h;
17 };
18 
19 typedef const int int_t;
20 typedef const char *char_ptr_t;
21 typedef const int arr_t[7];
22 
23 struct core_reloc_mods_substruct {
24 	int x;
25 	int y;
26 };
27 
28 typedef struct {
29 	int x;
30 	int y;
31 } core_reloc_mods_substruct_t;
32 
33 struct core_reloc_mods {
34 	int a;
35 	int_t b;
36 	char *c;
37 	char_ptr_t d;
38 	int e[3];
39 	arr_t f;
40 	struct core_reloc_mods_substruct g;
41 	core_reloc_mods_substruct_t h;
42 };
43 
44 SEC("raw_tracepoint/sys_enter")
test_core_mods(void * ctx)45 int test_core_mods(void *ctx)
46 {
47 	struct core_reloc_mods *in = (void *)&data.in;
48 	struct core_reloc_mods_output *out = (void *)&data.out;
49 
50 	if (BPF_CORE_READ(&out->a, &in->a) ||
51 	    BPF_CORE_READ(&out->b, &in->b) ||
52 	    BPF_CORE_READ(&out->c, &in->c) ||
53 	    BPF_CORE_READ(&out->d, &in->d) ||
54 	    BPF_CORE_READ(&out->e, &in->e[2]) ||
55 	    BPF_CORE_READ(&out->f, &in->f[1]) ||
56 	    BPF_CORE_READ(&out->g, &in->g.x) ||
57 	    BPF_CORE_READ(&out->h, &in->h.y))
58 		return 1;
59 
60 	return 0;
61 }
62 
63