Debian Codegraph @

testdata/errors.c

raw symbols SCIP
1 #include "common.h"
2 #include "../btf/testdata/bpf_core_read.h"
3
4 struct nonexist {
5 int non_exist;
6 };
7
8 enum nonexist_enum { NON_EXIST = 1 };
9
10 // Force loading program with BTF by including a relocation for a local type.
11 #define FORCE_BTF \
12 do { \
13 if (bpf_core_type_id_local(int) == 0) \
14 return __LINE__; \
15 } while (0)
16
17 __section("socket") int poisoned_single() {
18 FORCE_BTF;
19 struct nonexist ne;
20 return core_access(ne.non_exist);
21 }
22
23 __section("socket") int poisoned_double() {
24 FORCE_BTF;
25 return bpf_core_enum_value(enum nonexist_enum, NON_EXIST);
26 }
27
28 extern int invalid_kfunc(void) __ksym __weak;
29
30 __section("socket") int poisoned_kfunc() {
31 // NB: This doesn't go via CO-RE but uses a similar mechanism to generate
32 // an invalid instruction. We test it here for convenience.
33 return invalid_kfunc();
34 }