diff --git a/bpf/headers/include/bpf_helpers.h b/bpf/headers/include/bpf_helpers.h index 8526745d94..2242daf378 100644 --- a/bpf/headers/include/bpf_helpers.h +++ b/bpf/headers/include/bpf_helpers.h @@ -286,14 +286,6 @@ static int (*bpf_sk_storage_delete_unsafe) (const struct bpf_map_def* sk_storage __attribute__ ((section(".maps." #name), used)) \ ____btf_map_##name = { } -#define BPF_ASSERT_LOADER_VERSION(min_loader, ignore_eng, ignore_user, ignore_userdebug) \ - _Static_assert( \ - (min_loader) >= BPFLOADER_IGNORED_ON_VERSION || \ - !((ignore_eng).ignore_on_eng || \ - (ignore_user).ignore_on_user || \ - (ignore_userdebug).ignore_on_userdebug), \ - "bpfloader min version must be >= 0.33 in order to use ignored_on"); - #define ABSOLUTE(x) ((x) < 0 ? -(x) : (x)) #define DEFAULT_BPF_MAP_FLAGS(type, num_entries, mapflags) \ @@ -323,11 +315,7 @@ static int (*bpf_sk_storage_delete_unsafe) (const struct bpf_map_def* sk_storage .selinux_context = (selinux), \ .pin_subdir = (pindir), \ .shared = (share).shared, \ - .ignore_on_eng = (ignore_eng).ignore_on_eng, \ - .ignore_on_user = (ignore_user).ignore_on_user, \ - .ignore_on_userdebug = (ignore_userdebug).ignore_on_userdebug, \ - }; \ - BPF_ASSERT_LOADER_VERSION(minloader, ignore_eng, ignore_user, ignore_userdebug); + }; // Type safe macro to declare a ring buffer and related output functions. // Compatibility: @@ -542,9 +530,6 @@ static int (*bpf_trace_printk)(const char* fmt, int fmt_size, ...) = (void*) BPF .bpfloader_max_ver = (max_loader), \ .selinux_context = (selinux), \ .pin_subdir = (pindir), \ - .ignore_on_eng = (ignore_eng).ignore_on_eng, \ - .ignore_on_user = (ignore_user).ignore_on_user, \ - .ignore_on_userdebug = (ignore_userdebug).ignore_on_userdebug, \ }; \ SECTION(SECTION_NAME) \ int the_prog diff --git a/bpf/headers/include/bpf_map_def.h b/bpf/headers/include/bpf_map_def.h index 144c81a471..c98f40b4ea 100644 --- a/bpf/headers/include/bpf_map_def.h +++ b/bpf/headers/include/bpf_map_def.h @@ -124,18 +124,15 @@ struct optional_bool { bool optional; }; #define MANDATORY ((struct optional_bool){ .optional = false }) #define OPTIONAL ((struct optional_bool){ .optional = true }) -// for both maps and programs: -struct ignore_on_eng_bool { bool ignore_on_eng; }; -#define LOAD_ON_ENG ((struct ignore_on_eng_bool){ .ignore_on_eng = false }) -//#define IGNORE_ON_ENG ((struct ignore_on_eng_bool){ .ignore_on_eng = true }) +// (deprecated) for both maps and programs: +struct ignore_on_eng_bool { }; +#define LOAD_ON_ENG ((struct ignore_on_eng_bool){ }) -struct ignore_on_user_bool { bool ignore_on_user; }; -#define LOAD_ON_USER ((struct ignore_on_user_bool){ .ignore_on_user = false }) -//#define IGNORE_ON_USER ((struct ignore_on_user_bool){ .ignore_on_user = true }) +struct ignore_on_user_bool { }; +#define LOAD_ON_USER ((struct ignore_on_user_bool){ }) -struct ignore_on_userdebug_bool { bool ignore_on_userdebug; }; -#define LOAD_ON_USERDEBUG ((struct ignore_on_userdebug_bool){ .ignore_on_userdebug = false }) -//#define IGNORE_ON_USERDEBUG ((struct ignore_on_userdebug_bool){ .ignore_on_userdebug = true }) +struct ignore_on_userdebug_bool { }; +#define LOAD_ON_USERDEBUG ((struct ignore_on_userdebug_bool){ }) // Length of strings (incl. selinux_context and pin_subdir) @@ -198,21 +195,7 @@ struct bpf_map_def { bool shared; // use empty string as 'file' component of pin path - allows cross .o map sharing - // The following 3 ignore_on_* fields were added in version 0.32 (U). These are ignored in - // older bpfloader versions, and zero in programs compiled before 0.32. - bool ignore_on_eng:1; - bool ignore_on_user:1; - bool ignore_on_userdebug:1; - // The following 5 ignore_on_* fields were added in version 0.38 (U). These are ignored in - // older bpfloader versions, and zero in programs compiled before 0.38. - // These are tests on the kernel architecture, ie. they ignore userspace bit-ness. - bool ignore_on_arm32:1; - bool ignore_on_aarch64:1; - bool ignore_on_x86_32:1; - bool ignore_on_x86_64:1; - bool ignore_on_riscv64:1; - - char pad0[2]; // manually pad up to 4 byte alignment, may be used for extensions in the future + char pad0[3]; // manually pad up to 4 byte alignment, may be used for extensions in the future unsigned int uid; // uid_t }; @@ -235,21 +218,7 @@ struct bpf_prog_def { bool optional; // program section (ie. function) may fail to load, continue onto next func. - // The following 3 ignore_on_* fields were added in version 0.33 (U). These are ignored in - // older bpfloader versions, and zero in programs compiled before 0.33. - bool ignore_on_eng:1; - bool ignore_on_user:1; - bool ignore_on_userdebug:1; - // The following 5 ignore_on_* fields were added in version 0.38 (U). These are ignored in - // older bpfloader versions, and zero in programs compiled before 0.38. - // These are tests on the kernel architecture, ie. they ignore userspace bit-ness. - bool ignore_on_arm32:1; - bool ignore_on_aarch64:1; - bool ignore_on_x86_32:1; - bool ignore_on_x86_64:1; - bool ignore_on_riscv64:1; - - char pad0[2]; // manually pad up to 4 byte alignment, may be used for extensions in the future + char pad0[3]; // manually pad up to 4 byte alignment, may be used for extensions in the future // The following fields were added in version 0.1 unsigned int bpfloader_min_ver; // if missing, defaults to 0, ie. v0.0 diff --git a/bpf/loader/NetBpfLoad.cpp b/bpf/loader/NetBpfLoad.cpp index 0fa54013a3..e5d3507a45 100644 --- a/bpf/loader/NetBpfLoad.cpp +++ b/bpf/loader/NetBpfLoad.cpp @@ -904,25 +904,6 @@ static int createMaps(const char* elfPath, ifstream& elfFile, vector& continue; } - if ((md[i].ignore_on_eng && isEng()) || (md[i].ignore_on_user && isUser()) || - (md[i].ignore_on_userdebug && isUserdebug())) { - ALOGD("skipping map %s which is ignored on %s builds", mapNames[i].c_str(), - getBuildType().c_str()); - mapFds.push_back(unique_fd()); - abort(); - } - - if ((isArm() && isKernel32Bit() && md[i].ignore_on_arm32) || - (isArm() && isKernel64Bit() && md[i].ignore_on_aarch64) || - (isX86() && isKernel32Bit() && md[i].ignore_on_x86_32) || - (isX86() && isKernel64Bit() && md[i].ignore_on_x86_64) || - (isRiscV() && md[i].ignore_on_riscv64)) { - ALOGD("skipping map %s which is ignored on %s", mapNames[i].c_str(), - describeArch()); - mapFds.push_back(unique_fd()); - abort(); - } - enum bpf_map_type type = md[i].type; if (type == BPF_MAP_TYPE_LPM_TRIE && !isAtLeastKernelVersion(4, 14, 0)) { // On Linux Kernels older than 4.14 this map type doesn't exist - autoskip. @@ -1177,23 +1158,6 @@ static int loadCodeSections(const char* elfPath, vector& cs, const if (bpfloader_ver < bpfMinVer) continue; if (bpfloader_ver >= bpfMaxVer) continue; - if ((cs[i].prog_def->ignore_on_eng && isEng()) || - (cs[i].prog_def->ignore_on_user && isUser()) || - (cs[i].prog_def->ignore_on_userdebug && isUserdebug())) { - ALOGD("cs[%d].name:%s is ignored on %s builds", i, name.c_str(), - getBuildType().c_str()); - abort(); - } - - if ((isArm() && isKernel32Bit() && cs[i].prog_def->ignore_on_arm32) || - (isArm() && isKernel64Bit() && cs[i].prog_def->ignore_on_aarch64) || - (isX86() && isKernel32Bit() && cs[i].prog_def->ignore_on_x86_32) || - (isX86() && isKernel64Bit() && cs[i].prog_def->ignore_on_x86_64) || - (isRiscV() && cs[i].prog_def->ignore_on_riscv64)) { - ALOGD("cs[%d].name:%s is ignored on %s", i, name.c_str(), describeArch()); - abort(); - } - if (specified(selinux_context)) { ALOGV("prog %s selinux_context [%-32s] -> %d -> '%s' (%s)", name.c_str(), cs[i].prog_def->selinux_context, static_cast(selinux_context),