| 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 |
|
| 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 |
|
| 32 |
|
| 33 |
return invalid_kfunc(); |
| 34 |
} |