diff options
Diffstat (limited to 'common/native/bpf_headers/include/bpf/bpf_helpers.h')
-rw-r--r-- | common/native/bpf_headers/include/bpf/bpf_helpers.h | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/common/native/bpf_headers/include/bpf/bpf_helpers.h b/common/native/bpf_headers/include/bpf/bpf_helpers.h index 8bc8eb17..236318d6 100644 --- a/common/native/bpf_headers/include/bpf/bpf_helpers.h +++ b/common/native/bpf_headers/include/bpf/bpf_helpers.h @@ -37,6 +37,9 @@ // Android T / 13 (api level 33) - support for shared/selinux_context/pindir #define BPFLOADER_T_VERSION 19u +// BpfLoader v0.25+ support obj@ver.o files +#define BPFLOADER_OBJ_AT_VER_VERSION 25u + /* For mainline module use, you can #define BPFLOADER_{MIN/MAX}_VER * before #include "bpf_helpers.h" to change which bpfloaders will * process the resulting .o file. @@ -179,20 +182,39 @@ static int (*bpf_map_delete_elem_unsafe)(const struct bpf_map_def* map, return bpf_map_delete_elem_unsafe(&the_map, k); \ }; +#ifndef DEFAULT_BPF_MAP_SELINUX_CONTEXT +#define DEFAULT_BPF_MAP_SELINUX_CONTEXT "" +#endif + +#ifndef DEFAULT_BPF_MAP_PIN_SUBDIR +#define DEFAULT_BPF_MAP_PIN_SUBDIR "" +#endif + +#ifndef DEFAULT_BPF_MAP_UID +#define DEFAULT_BPF_MAP_UID AID_ROOT +#elif BPFLOADER_MIN_VER < 21u +#error "Bpf Map UID must be left at default of AID_ROOT for BpfLoader prior to v0.21" +#endif + #define DEFINE_BPF_MAP_UGM(the_map, TYPE, KeyType, ValueType, num_entries, usr, grp, md) \ - DEFINE_BPF_MAP_EXT(the_map, TYPE, KeyType, ValueType, num_entries, usr, grp, md, "", "", false) + DEFINE_BPF_MAP_EXT(the_map, TYPE, KeyType, ValueType, num_entries, usr, grp, md, \ + DEFAULT_BPF_MAP_SELINUX_CONTEXT, DEFAULT_BPF_MAP_PIN_SUBDIR, false) #define DEFINE_BPF_MAP(the_map, TYPE, KeyType, ValueType, num_entries) \ - DEFINE_BPF_MAP_UGM(the_map, TYPE, KeyType, ValueType, num_entries, AID_ROOT, AID_ROOT, 0600) + DEFINE_BPF_MAP_UGM(the_map, TYPE, KeyType, ValueType, num_entries, \ + DEFAULT_BPF_MAP_UID, AID_ROOT, 0600) #define DEFINE_BPF_MAP_GWO(the_map, TYPE, KeyType, ValueType, num_entries, gid) \ - DEFINE_BPF_MAP_UGM(the_map, TYPE, KeyType, ValueType, num_entries, AID_ROOT, gid, 0620) + DEFINE_BPF_MAP_UGM(the_map, TYPE, KeyType, ValueType, num_entries, \ + DEFAULT_BPF_MAP_UID, gid, 0620) #define DEFINE_BPF_MAP_GRO(the_map, TYPE, KeyType, ValueType, num_entries, gid) \ - DEFINE_BPF_MAP_UGM(the_map, TYPE, KeyType, ValueType, num_entries, AID_ROOT, gid, 0640) + DEFINE_BPF_MAP_UGM(the_map, TYPE, KeyType, ValueType, num_entries, \ + DEFAULT_BPF_MAP_UID, gid, 0640) #define DEFINE_BPF_MAP_GRW(the_map, TYPE, KeyType, ValueType, num_entries, gid) \ - DEFINE_BPF_MAP_UGM(the_map, TYPE, KeyType, ValueType, num_entries, AID_ROOT, gid, 0660) + DEFINE_BPF_MAP_UGM(the_map, TYPE, KeyType, ValueType, num_entries, \ + DEFAULT_BPF_MAP_UID, gid, 0660) static int (*bpf_probe_read)(void* dst, int size, void* unsafe_ptr) = (void*) BPF_FUNC_probe_read; static int (*bpf_probe_read_str)(void* dst, int size, void* unsafe_ptr) = (void*) BPF_FUNC_probe_read_str; @@ -221,9 +243,18 @@ static long (*bpf_get_current_comm)(void* buf, uint32_t buf_size) = (void*) BPF_ SECTION(SECTION_NAME) \ int the_prog +#ifndef DEFAULT_BPF_PROG_SELINUX_CONTEXT +#define DEFAULT_BPF_PROG_SELINUX_CONTEXT "" +#endif + +#ifndef DEFAULT_BPF_PROG_PIN_SUBDIR +#define DEFAULT_BPF_PROG_PIN_SUBDIR "" +#endif + #define DEFINE_BPF_PROG_KVER_RANGE_OPT(SECTION_NAME, prog_uid, prog_gid, the_prog, min_kv, max_kv, \ opt) \ - DEFINE_BPF_PROG_EXT(SECTION_NAME, prog_uid, prog_gid, the_prog, min_kv, max_kv, opt, "", "") + DEFINE_BPF_PROG_EXT(SECTION_NAME, prog_uid, prog_gid, the_prog, min_kv, max_kv, opt, \ + DEFAULT_BPF_PROG_SELINUX_CONTEXT, DEFAULT_BPF_PROG_PIN_SUBDIR) // Programs (here used in the sense of functions/sections) marked optional are allowed to fail // to load (for example due to missing kernel patches). |