diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-06-21 17:05:47 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-06-21 17:05:47 +0000 |
commit | 4b88b0ab97a914b102f1da819b3f48a71fecd1e2 (patch) | |
tree | 074a5d3fef0741d7512e19f84d93e5018fec6e1a | |
parent | d11f55649b7cdd934826d51e343f4aeac1be8dba (diff) | |
parent | 8482e88f9e31c928161edfb5c3e5a8a762e1ef91 (diff) | |
download | bpf-android13-frc-resolv-release.tar.gz |
Snap for 8748865 from 8482e88f9e31c928161edfb5c3e5a8a762e1ef91 to tm-frc-resolv-releaset_frc_res_330443000android13-frc-resolv-release
Change-Id: Ic03467e8ba6be9579dc83ab3a7ce105ed2712ce5
-rw-r--r-- | bpfloader/BpfLoader.cpp | 15 | ||||
-rw-r--r-- | libbpf_android/Loader.cpp | 181 |
2 files changed, 128 insertions, 68 deletions
diff --git a/bpfloader/BpfLoader.cpp b/bpfloader/BpfLoader.cpp index 739932d..4e5a6ce 100644 --- a/bpfloader/BpfLoader.cpp +++ b/bpfloader/BpfLoader.cpp @@ -69,22 +69,29 @@ struct Location { }; const Location locations[] = { - // Tethering mainline module: tether offload + // S+ Tethering mainline module (network_stack): tether offload { .dir = "/apex/com.android.tethering/etc/bpf/", .prefix = "tethering/", }, - // Tethering mainline module (shared with netd & system server) + // T+ Tethering mainline module (shared with netd & system server) + // netutils_wrapper (for iptables xt_bpf) has access to programs { .dir = "/apex/com.android.tethering/etc/bpf/netd_shared/", .prefix = "netd_shared/", }, - // Tethering mainline module (shared with system server) + // T+ Tethering mainline module (shared with netd & system server) + // netutils_wrapper has no access, netd has read only access + { + .dir = "/apex/com.android.tethering/etc/bpf/netd_readonly/", + .prefix = "netd_readonly/", + }, + // T+ Tethering mainline module (shared with system server) { .dir = "/apex/com.android.tethering/etc/bpf/net_shared/", .prefix = "net_shared/", }, - // Tethering mainline module (not shared) + // T+ Tethering mainline module (not shared, just network_stack) { .dir = "/apex/com.android.tethering/etc/bpf/net_private/", .prefix = "net_private/", diff --git a/libbpf_android/Loader.cpp b/libbpf_android/Loader.cpp index 5f2bc70..f06d20f 100644 --- a/libbpf_android/Loader.cpp +++ b/libbpf_android/Loader.cpp @@ -30,9 +30,9 @@ #include <sys/wait.h> #include <unistd.h> -// This is BpfLoader v0.14 +// This is BpfLoader v0.17 #define BPFLOADER_VERSION_MAJOR 0u -#define BPFLOADER_VERSION_MINOR 14u +#define BPFLOADER_VERSION_MINOR 17u #define BPFLOADER_VERSION ((BPFLOADER_VERSION_MAJOR << 16) | BPFLOADER_VERSION_MINOR) #include "bpf/BpfUtils.h" @@ -106,6 +106,7 @@ sectionType sectionNameTypes[] = { {"cgroupskb/", BPF_PROG_TYPE_CGROUP_SKB, BPF_ATTACH_TYPE_UNSPEC}, {"cgroupsock/", BPF_PROG_TYPE_CGROUP_SOCK, BPF_ATTACH_TYPE_UNSPEC}, {"kprobe/", BPF_PROG_TYPE_KPROBE, BPF_ATTACH_TYPE_UNSPEC}, + {"perf_event/", BPF_PROG_TYPE_PERF_EVENT, BPF_ATTACH_TYPE_UNSPEC}, {"schedact/", BPF_PROG_TYPE_SCHED_ACT, BPF_ATTACH_TYPE_UNSPEC}, {"schedcls/", BPF_PROG_TYPE_SCHED_CLS, BPF_ATTACH_TYPE_UNSPEC}, {"skfilter/", BPF_PROG_TYPE_SOCKET_FILTER, BPF_ATTACH_TYPE_UNSPEC}, @@ -229,10 +230,10 @@ unsigned int readSectionUint(const char* name, ifstream& elfFile, unsigned int d vector<char> theBytes; int ret = readSectionByName(name, elfFile, theBytes); if (ret) { - ALOGD("Couldn't find section %s (defaulting to %u [0x%x]).\n", name, defVal, defVal); + ALOGD("Couldn't find section %s (defaulting to %u [0x%x]).", name, defVal, defVal); return defVal; } else if (theBytes.size() < sizeof(unsigned int)) { - ALOGE("Section %s too short (defaulting to %u [0x%x]).\n", name, defVal, defVal); + ALOGE("Section %s too short (defaulting to %u [0x%x]).", name, defVal, defVal); return defVal; } else { // decode first 4 bytes as LE32 uint, there will likely be more bytes due to alignment. @@ -243,7 +244,7 @@ unsigned int readSectionUint(const char* name, ifstream& elfFile, unsigned int d value += static_cast<unsigned char>(theBytes[1]); value <<= 8; value += static_cast<unsigned char>(theBytes[0]); - ALOGI("Section %s value is %u [0x%x]\n", name, value, value); + ALOGI("Section %s value is %u [0x%x]", name, value, value); return value; } } @@ -331,7 +332,7 @@ static int readProgDefs(ifstream& elfFile, vector<struct bpf_prog_def>& pd, if (ret) return ret; if (pdData.size() % sizeOfBpfProgDef) { - ALOGE("readProgDefs failed due to improper sized progs section, %zu %% %zu != 0\n", + ALOGE("readProgDefs failed due to improper sized progs section, %zu %% %zu != 0", pdData.size(), sizeOfBpfProgDef); return -1; }; @@ -381,7 +382,7 @@ static int getSectionSymNames(ifstream& elfFile, const string& sectionName, vect /* No section found with matching name*/ if (sec_idx == -1) { - ALOGW("No %s section could be found in elf object\n", sectionName.c_str()); + ALOGW("No %s section could be found in elf object", sectionName.c_str()); return -1; } @@ -456,7 +457,7 @@ static int readCodeSections(ifstream& elfFile, vector<codeSection>& cs, size_t s ret = readSectionByIdx(elfFile, i, cs_temp.data); if (ret) return ret; - ALOGD("Loaded code section %d (%s)\n", i, name.c_str()); + ALOGD("Loaded code section %d (%s)", i, name.c_str()); vector<string> csSymNames; ret = getSectionSymNames(elfFile, oldName, csSymNames, STT_FUNC); @@ -476,13 +477,13 @@ static int readCodeSections(ifstream& elfFile, vector<codeSection>& cs, size_t s if (name == (".rel" + oldName)) { ret = readSectionByIdx(elfFile, i + 1, cs_temp.rel_data); if (ret) return ret; - ALOGD("Loaded relo section %d (%s)\n", i, name.c_str()); + ALOGD("Loaded relo section %d (%s)", i, name.c_str()); } } if (cs_temp.data.size() > 0) { cs.push_back(std::move(cs_temp)); - ALOGD("Adding section %d to cs list\n", i); + ALOGD("Adding section %d to cs list", i); } } return 0; @@ -544,7 +545,7 @@ static std::optional<unique_fd> getMapBtfInfo(const char* elfPath, if (execl("/system/bin/btfloader", "/system/bin/btfloader", socketFdStr.c_str(), pipeFdStr.c_str(), elfPath, NULL) == -1) { - ALOGW("exec btfloader failed with errno %d (%s)\n", errno, strerror(errno)); + ALOGW("exec btfloader failed with errno %d (%s)", errno, strerror(errno)); exit(EX_UNAVAILABLE); } } @@ -560,7 +561,7 @@ static std::optional<unique_fd> getMapBtfInfo(const char* elfPath, std::string btfTypeIdStr; if (!android::base::ReadFdToString(pipeRead, &btfTypeIdStr)) return {}; - if (btfFd.get() < 0) return {}; + if (!btfFd.ok()) return {}; const auto mapTypeIdLines = android::base::Split(btfTypeIdStr, "\n"); for (const auto &line : mapTypeIdLines) { @@ -575,6 +576,52 @@ static std::optional<unique_fd> getMapBtfInfo(const char* elfPath, return btfFd; } +static bool mapMatchesExpectations(unique_fd& fd, string& mapName, struct bpf_map_def& mapDef, + enum bpf_map_type type) { + // bpfGetFd... family of functions require at minimum a 4.14 kernel, + // so on 4.9 kernels just pretend the map matches our expectations. + // This isn't really a problem as we only really support 4.14+ anyway... + // Additionally we'll get almost equivalent test coverage on newer devices/kernels. + // This is because the primary failure mode we're trying to detect here + // is either a source code misconfiguration (which is likely kernel independent) + // or a newly introduced kernel feature/bug (which is unlikely to get backported to 4.9). + if (!isAtLeastKernelVersion(4, 14, 0)) return true; + + // These asserts should *never* trigger, if one of them somehow does, + // it probably means a bpf .o file has been changed/replaced at runtime + // and bpfloader was manually rerun (normally it should only run *once* + // early during the boot process). + // Another possibility is that something is misconfigured in the code: + // most likely a shared map is declared twice differently. + // But such a change should never be checked into the source tree... + int fd_type = bpfGetFdMapType(fd); + int fd_key_size = bpfGetFdKeySize(fd); + int fd_value_size = bpfGetFdValueSize(fd); + int fd_max_entries = bpfGetFdMaxEntries(fd); + int fd_map_flags = bpfGetFdMapFlags(fd); + + // DEVMAPs are readonly from the bpf program side's point of view, as such + // the kernel in kernel/bpf/devmap.c dev_map_init_map() will set the flag + int desired_map_flags = (int)mapDef.map_flags; + if (type == BPF_MAP_TYPE_DEVMAP || type == BPF_MAP_TYPE_DEVMAP_HASH) + desired_map_flags |= BPF_F_RDONLY_PROG; + + // If anything doesn't match, just close the fd - it's of no use anyway. + if (fd_type != type) fd.reset(); + if (fd_key_size != (int)mapDef.key_size) fd.reset(); + if (fd_value_size != (int)mapDef.value_size) fd.reset(); + if (fd_max_entries != (int)mapDef.max_entries) fd.reset(); + if (fd_map_flags != desired_map_flags) fd.reset(); + + if (fd.ok()) return true; + + ALOGE("bpf map name %s mismatch: desired/found: " + "type:%d/%d key:%u/%d value:%u/%d entries:%u/%d flags:%u/%d", + mapName.c_str(), type, fd_type, mapDef.key_size, fd_key_size, mapDef.value_size, + fd_value_size, mapDef.max_entries, fd_max_entries, desired_map_flags, fd_map_flags); + return false; +} + static int createMaps(const char* elfPath, ifstream& elfFile, vector<unique_fd>& mapFds, const char* prefix, size_t sizeOfBpfMapDef) { int ret; @@ -589,7 +636,7 @@ static int createMaps(const char* elfPath, ifstream& elfFile, vector<unique_fd>& if (ret) return ret; if (mdData.size() % sizeOfBpfMapDef) { - ALOGE("createMaps failed due to improper sized maps section, %zu %% %zu != 0\n", + ALOGE("createMaps failed due to improper sized maps section, %zu %% %zu != 0", mdData.size(), sizeOfBpfMapDef); return -1; }; @@ -623,33 +670,55 @@ static int createMaps(const char* elfPath, ifstream& elfFile, vector<unique_fd>& for (int i = 0; i < (int)mapNames.size(); i++) { if (BPFLOADER_VERSION < md[i].bpfloader_min_ver) { - ALOGI("skipping map %s which requires bpfloader min ver 0x%05x\n", mapNames[i].c_str(), + ALOGI("skipping map %s which requires bpfloader min ver 0x%05x", mapNames[i].c_str(), md[i].bpfloader_min_ver); mapFds.push_back(unique_fd()); continue; } if (BPFLOADER_VERSION >= md[i].bpfloader_max_ver) { - ALOGI("skipping map %s which requires bpfloader max ver 0x%05x\n", mapNames[i].c_str(), + ALOGI("skipping map %s which requires bpfloader max ver 0x%05x", mapNames[i].c_str(), md[i].bpfloader_max_ver); mapFds.push_back(unique_fd()); continue; } if (kvers < md[i].min_kver) { - ALOGI("skipping map %s which requires kernel version 0x%x >= 0x%x\n", + ALOGI("skipping map %s which requires kernel version 0x%x >= 0x%x", mapNames[i].c_str(), kvers, md[i].min_kver); mapFds.push_back(unique_fd()); continue; } if (kvers >= md[i].max_kver) { - ALOGI("skipping map %s which requires kernel version 0x%x < 0x%x\n", + ALOGI("skipping map %s which requires kernel version 0x%x < 0x%x", mapNames[i].c_str(), kvers, md[i].max_kver); mapFds.push_back(unique_fd()); continue; } + enum bpf_map_type type = md[i].type; + if (type == BPF_MAP_TYPE_DEVMAP && !isAtLeastKernelVersion(4, 14, 0)) { + // On Linux Kernels older than 4.14 this map type doesn't exist, but it can kind + // of be approximated: ARRAY has the same userspace api, though it is not usable + // by the same ebpf programs. However, that's okay because the bpf_redirect_map() + // helper doesn't exist on 4.9 anyway (so the bpf program would fail to load, + // and thus needs to be tagged as 4.14+ either way), so there's nothing useful you + // could do with a DEVMAP anyway (that isn't already provided by an ARRAY)... + // Hence using an ARRAY instead of a DEVMAP simply makes life easier for userspace. + type = BPF_MAP_TYPE_ARRAY; + } + if (type == BPF_MAP_TYPE_DEVMAP_HASH && !isAtLeastKernelVersion(5, 4, 0)) { + // On Linux Kernels older than 5.4 this map type doesn't exist, but it can kind + // of be approximated: HASH has the same userspace visible api. + // However it cannot be used by ebpf programs in the same way. + // Since bpf_redirect_map() only requires 4.14, a program using a DEVMAP_HASH map + // would fail to load (due to trying to redirect to a HASH instead of DEVMAP_HASH). + // One must thus tag any BPF_MAP_TYPE_DEVMAP_HASH + bpf_redirect_map() using + // programs as being 5.4+... + type = BPF_MAP_TYPE_HASH; + } + // Format of pin location is /sys/fs/bpf/<prefix>map_<filename>_<mapname> string mapPinLoc = string(BPF_FS_PATH) + prefix + "map_" + fname + "_" + string(mapNames[i]); @@ -660,30 +729,9 @@ static int createMaps(const char* elfPath, ifstream& elfFile, vector<unique_fd>& if (access(mapPinLoc.c_str(), F_OK) == 0) { fd.reset(bpf_obj_get(mapPinLoc.c_str())); saved_errno = errno; - ALOGD("bpf_create_map reusing map %s, ret: %d\n", mapNames[i].c_str(), fd.get()); + ALOGD("bpf_create_map reusing map %s, ret: %d", mapNames[i].c_str(), fd.get()); reuse = true; } else { - enum bpf_map_type type = md[i].type; - if (type == BPF_MAP_TYPE_DEVMAP && !isAtLeastKernelVersion(4, 14, 0)) { - // On Linux Kernels older than 4.14 this map type doesn't exist, but it can kind - // of be approximated: ARRAY has the same userspace api, though it is not usable - // by the same ebpf programs. However, that's okay because the bpf_redirect_map() - // helper doesn't exist on 4.9 anyway (so the bpf program would fail to load, - // and thus needs to be tagged as 4.14+ either way), so there's nothing useful you - // could do with a DEVMAP anyway (that isn't already provided by an ARRAY)... - // Hence using an ARRAY instead of a DEVMAP simply makes life easier for userspace. - type = BPF_MAP_TYPE_ARRAY; - } - if (type == BPF_MAP_TYPE_DEVMAP_HASH && !isAtLeastKernelVersion(5, 4, 0)) { - // On Linux Kernels older than 5.4 this map type doesn't exist, but it can kind - // of be approximated: HASH has the same userspace visible api. - // However it cannot be used by ebpf programs in the same way. - // Since bpf_redirect_map() only requires 4.14, a program using a DEVMAP_HASH map - // would fail to load (due to trying to redirect to a HASH instead of DEVMAP_HASH). - // One must thus tag any BPF_MAP_TYPE_DEVMAP_HASH + bpf_redirect_map() using - // programs as being 5.4+... - type = BPF_MAP_TYPE_HASH; - } struct bpf_create_map_attr attr = { .name = mapNames[i].c_str(), .map_type = type, @@ -699,10 +747,15 @@ static int createMaps(const char* elfPath, ifstream& elfFile, vector<unique_fd>& } fd.reset(bcc_create_map_xattr(&attr, true)); saved_errno = errno; - ALOGD("bpf_create_map name %s, ret: %d\n", mapNames[i].c_str(), fd.get()); + ALOGD("bpf_create_map name %s, ret: %d", mapNames[i].c_str(), fd.get()); } - if (fd < 0) return -saved_errno; + if (!fd.ok()) return -saved_errno; + + // When reusing a pinned map, we need to check the map type/sizes/etc match, but for + // safety (since reuse code path is rare) run these checks even if we just created it. + // We assume failure is due to pinned map mismatch, hence the 'NOT UNIQUE' return code. + if (!mapMatchesExpectations(fd, mapNames[i], md[i], type)) return -ENOTUNIQ; if (!reuse) { ret = bpf_obj_pin(fd, mapPinLoc.c_str()); @@ -717,9 +770,9 @@ static int createMaps(const char* elfPath, ifstream& elfFile, vector<unique_fd>& __u32 map_info_len = sizeof(map_info); int rv = bpf_obj_get_info_by_fd(fd, &map_info, &map_info_len); if (rv) { - ALOGE("bpf_obj_get_info_by_fd failed, ret: %d [%d]\n", rv, errno); + ALOGE("bpf_obj_get_info_by_fd failed, ret: %d [%d]", rv, errno); } else { - ALOGI("map %s id %d\n", mapPinLoc.c_str(), map_info.id); + ALOGI("map %s id %d", mapPinLoc.c_str(), map_info.id); } mapFds.push_back(std::move(fd)); @@ -742,9 +795,9 @@ static void dumpIns(char* ins, int size) { /* For debugging, dump all code sections from cs list */ static void dumpAllCs(vector<codeSection>& cs) { for (int i = 0; i < (int)cs.size(); i++) { - ALOGE("Dumping cs %d, name %s\n", int(i), cs[i].name.c_str()); + ALOGE("Dumping cs %d, name %s", int(i), cs[i].name.c_str()); dumpIns((char*)cs[i].data.data(), cs[i].data.size()); - ALOGE("-----------\n"); + ALOGE("-----------"); } } @@ -763,8 +816,8 @@ static void applyRelo(void* insnsPtr, Elf64_Addr offset, int fd) { (int)offset, (int)insnIndex, *(unsigned long*)insn); if (insn->code != (BPF_LD | BPF_IMM | BPF_DW)) { - ALOGE("Dumping all instructions till ins %d\n", insnIndex); - ALOGE("invalid relo for insn %d: code 0x%x\n", insnIndex, insn->code); + ALOGE("Dumping all instructions till ins %d", insnIndex); + ALOGE("invalid relo for insn %d: code 0x%x", insnIndex, insn->code); dumpIns((char*)insnsPtr, (insnIndex + 3) * 8); return; } @@ -818,7 +871,7 @@ static int loadCodeSections(const char* elfPath, vector<codeSection>& cs, const if (cs[i].prog_def.has_value()) { unsigned min_kver = cs[i].prog_def->min_kver; unsigned max_kver = cs[i].prog_def->max_kver; - ALOGD("cs[%d].name:%s min_kver:%x .max_kver:%x (kvers:%x)\n", i, name.c_str(), min_kver, + ALOGD("cs[%d].name:%s min_kver:%x .max_kver:%x (kvers:%x)", i, name.c_str(), min_kver, max_kver, kvers); if (kvers < min_kver) continue; if (kvers >= max_kver) continue; @@ -827,7 +880,7 @@ static int loadCodeSections(const char* elfPath, vector<codeSection>& cs, const bpfMaxVer = cs[i].prog_def->bpfloader_max_ver; } - ALOGD("cs[%d].name:%s requires bpfloader version [0x%05x,0x%05x)\n", i, name.c_str(), + ALOGD("cs[%d].name:%s requires bpfloader version [0x%05x,0x%05x)", i, name.c_str(), bpfMinVer, bpfMaxVer); if (BPFLOADER_VERSION < bpfMinVer) continue; if (BPFLOADER_VERSION >= bpfMaxVer) continue; @@ -848,7 +901,7 @@ static int loadCodeSections(const char* elfPath, vector<codeSection>& cs, const progPinLoc += name; if (access(progPinLoc.c_str(), F_OK) == 0) { fd = retrieveProgram(progPinLoc.c_str()); - ALOGD("New bpf prog load reusing prog %s, ret: %d (%s)\n", progPinLoc.c_str(), fd, + ALOGD("New bpf prog load reusing prog %s, ret: %d (%s)", progPinLoc.c_str(), fd, (fd < 0 ? std::strerror(errno) : "no error")); reuse = true; } else { @@ -866,7 +919,7 @@ static int loadCodeSections(const char* elfPath, vector<codeSection>& cs, const fd = bcc_prog_load_xattr(&attr, cs[i].data.size(), log_buf.data(), log_buf.size(), true); - ALOGD("bpf_prog_load lib call for %s (%s) returned fd: %d (%s)\n", elfPath, + ALOGD("bpf_prog_load lib call for %s (%s) returned fd: %d (%s)", elfPath, cs[i].name.c_str(), fd, (fd < 0 ? std::strerror(errno) : "no error")); if (fd < 0) { @@ -903,9 +956,9 @@ static int loadCodeSections(const char* elfPath, vector<codeSection>& cs, const __u32 prog_info_len = sizeof(prog_info); int rv = bpf_obj_get_info_by_fd(fd, &prog_info, &prog_info_len); if (rv) { - ALOGE("bpf_obj_get_info_by_fd failed, ret: %d [%d]\n", rv, errno); + ALOGE("bpf_obj_get_info_by_fd failed, ret: %d [%d]", rv, errno); } else { - ALOGI("prog %s id %d\n", progPinLoc.c_str(), prog_info.id); + ALOGI("prog %s id %d", progPinLoc.c_str(), prog_info.id); } cs[i].prog_fd.reset(fd); @@ -933,10 +986,10 @@ int loadProg(const char* elfPath, bool* isCritical, const char* prefix, ret = readSectionByName("license", elfFile, license); if (ret) { - ALOGE("Couldn't find license in %s\n", elfPath); + ALOGE("Couldn't find license in %s", elfPath); return ret; } else { - ALOGD("Loading %s%s ELF object %s with license %s\n", + ALOGD("Loading %s%s ELF object %s with license %s", *isCritical ? "critical for " : "optional", *isCritical ? (char*)critical.data() : "", elfPath, (char*)license.data()); } @@ -953,36 +1006,36 @@ int loadProg(const char* elfPath, bool* isCritical, const char* prefix, // inclusive lower bound check if (BPFLOADER_VERSION < bpfLoaderMinVer) { - ALOGI("BpfLoader version 0x%05x ignoring ELF object %s with min ver 0x%05x\n", + ALOGI("BpfLoader version 0x%05x ignoring ELF object %s with min ver 0x%05x", BPFLOADER_VERSION, elfPath, bpfLoaderMinVer); return 0; } // exclusive upper bound check if (BPFLOADER_VERSION >= bpfLoaderMaxVer) { - ALOGI("BpfLoader version 0x%05x ignoring ELF object %s with max ver 0x%05x\n", + ALOGI("BpfLoader version 0x%05x ignoring ELF object %s with max ver 0x%05x", BPFLOADER_VERSION, elfPath, bpfLoaderMaxVer); return 0; } - ALOGI("BpfLoader version 0x%05x processing ELF object %s with ver [0x%05x,0x%05x)\n", + ALOGI("BpfLoader version 0x%05x processing ELF object %s with ver [0x%05x,0x%05x)", BPFLOADER_VERSION, elfPath, bpfLoaderMinVer, bpfLoaderMaxVer); if (sizeOfBpfMapDef < DEFAULT_SIZEOF_BPF_MAP_DEF) { - ALOGE("sizeof(bpf_map_def) of %zu is too small (< %d)\n", sizeOfBpfMapDef, + ALOGE("sizeof(bpf_map_def) of %zu is too small (< %d)", sizeOfBpfMapDef, DEFAULT_SIZEOF_BPF_MAP_DEF); return -1; } if (sizeOfBpfProgDef < DEFAULT_SIZEOF_BPF_PROG_DEF) { - ALOGE("sizeof(bpf_prog_def) of %zu is too small (< %d)\n", sizeOfBpfProgDef, + ALOGE("sizeof(bpf_prog_def) of %zu is too small (< %d)", sizeOfBpfProgDef, DEFAULT_SIZEOF_BPF_PROG_DEF); return -1; } ret = readCodeSections(elfFile, cs, sizeOfBpfProgDef, allowed, numAllowed); if (ret) { - ALOGE("Couldn't read all code sections in %s\n", elfPath); + ALOGE("Couldn't read all code sections in %s", elfPath); return ret; } @@ -991,17 +1044,17 @@ int loadProg(const char* elfPath, bool* isCritical, const char* prefix, ret = createMaps(elfPath, elfFile, mapFds, prefix, sizeOfBpfMapDef); if (ret) { - ALOGE("Failed to create maps: (ret=%d) in %s\n", ret, elfPath); + ALOGE("Failed to create maps: (ret=%d) in %s", ret, elfPath); return ret; } for (int i = 0; i < (int)mapFds.size(); i++) - ALOGD("map_fd found at %d is %d in %s\n", i, mapFds[i].get(), elfPath); + ALOGD("map_fd found at %d is %d in %s", i, mapFds[i].get(), elfPath); applyMapRelo(elfFile, mapFds, cs); ret = loadCodeSections(elfPath, cs, string(license.data()), prefix); - if (ret) ALOGE("Failed to load programs, loadCodeSections ret=%d\n", ret); + if (ret) ALOGE("Failed to load programs, loadCodeSections ret=%d", ret); return ret; } |