From 037a1cee8c5e38a93e5137ee5aa920a8c3cf4215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBenczykowski?= Date: Mon, 28 Jul 2025 15:51:48 -0700 Subject: [PATCH] NetBpfLoad: remove specified(pin_subdir) checks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pin_subdir is now always specified... Of the 4 checks, 2 are only for ALOGV low-value logging, I've always thought we should probably just remove that. The other 2 checks appear to actually be buggy. They should probably be checking selinux_context rather than pin_subdir, since pin_subdir likely (untested) just works fine. Verify via: git grep 'specified[(]pin_subdir[)]' Test: TreeHugger Flag: EXEMPT mainline Signed-off-by: Maciej Żenczykowski & } domain pin_subdir = getDomainFromPinSubdir(md[i].pin_subdir); - if (specified(pin_subdir)) { - ALOGV("map %s pin_subdir [%-32s] -> %d -> '%s'", mapNames[i].c_str(), md[i].pin_subdir, - static_cast(pin_subdir), lookupPinSubdir(pin_subdir)); - } - string mapPinLoc = buildMapPinLoc(pin_subdir, objName, mapNames[i]); unique_fd fd; int saved_errno; @@ -1309,12 +1304,6 @@ static int loadCodeSections(const char* elfPath, vector& cs, const if (bpfloader_ver < bpfMinVer) continue; if (bpfloader_ver >= bpfMaxVer) continue; - if (specified(pin_subdir)) { - ALOGV("prog %s pin_subdir [%-32s] -> %d -> '%s'", name.c_str(), - cs[i].prog_def->pin_subdir, static_cast(pin_subdir), - lookupPinSubdir(pin_subdir)); - } - // strip any potential $foo suffix // this can be used to provide duplicate programs // conditionally loaded based on running kernel version @@ -1489,11 +1478,6 @@ static int pinMaps(const char* const elfPath, const struct bpf_object* obj, if (!bpf_map__autocreate(m)) continue; domain pin_subdir = getDomainFromPinSubdir(md[i].pin_subdir); - if (specified(pin_subdir)) { - ALOGE("map %s pin_subdir [%-32s] -> %d -> '%s'", mapNames[i].c_str(), md[i].pin_subdir, - static_cast(pin_subdir), lookupPinSubdir(pin_subdir)); - return -1; - } string mapPinLoc = buildMapPinLoc(pin_subdir, objName, mapNames[i]); if (access(mapPinLoc.c_str(), F_OK) == 0) { ALOGE("Reusing map is not supported: %s", mapNames[i].c_str()); @@ -1524,12 +1508,6 @@ static int pinProgs(const char* const elfPath, const struct bpf_object * obj, string name = cs[i].name; name = name.substr(0, name.find_last_of('$')); domain pin_subdir = getDomainFromPinSubdir(cs[i].prog_def->pin_subdir); - if (specified(pin_subdir)) { - ALOGE("prog %s pin_subdir [%-32s] -> %d -> '%s'", name.c_str(), - cs[i].prog_def->pin_subdir, static_cast(pin_subdir), - lookupPinSubdir(pin_subdir)); - return -1; - } string progPinLoc = buildProgPinLoc(pin_subdir, objName, name); if (access(progPinLoc.c_str(), F_OK) == 0) { // TODO: Skip loading lower priority program