From ed945905ded236c8e8ad20bed71259ce541d14ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBenczykowski?= Date: Wed, 30 Jul 2025 14:15:10 -0700 Subject: [PATCH] NetBpfLoad: remove validatePinDir() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No longer required now that we have compile time verification. Test: TreeHugger Flag: EXEMPT mainline Signed-off-by: Maciej Żenczykowski Change-Id: I5b18727e8ebf820a06ba647bb7349ba755d5d798 --- bpf/loader/NetBpfLoad.cpp | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/bpf/loader/NetBpfLoad.cpp b/bpf/loader/NetBpfLoad.cpp index 6cf7239476..bb7fdff2f7 100644 --- a/bpf/loader/NetBpfLoad.cpp +++ b/bpf/loader/NetBpfLoad.cpp @@ -111,21 +111,6 @@ inline bool isUserdebug() { static unsigned int page_size = static_cast(getpagesize()); -void validatePinDir(const char s[BPF_PIN_SUBDIR_CHAR_ARRAY_SIZE]) { - if (!strncmp(s, "tethering/", BPF_PIN_SUBDIR_CHAR_ARRAY_SIZE)) return; - if (isAtLeastT) { - if (!strncmp(s, "net_private/", BPF_PIN_SUBDIR_CHAR_ARRAY_SIZE)) return; - if (!strncmp(s, "net_shared/", BPF_PIN_SUBDIR_CHAR_ARRAY_SIZE)) return; - if (!strncmp(s, "netd_readonly/", BPF_PIN_SUBDIR_CHAR_ARRAY_SIZE)) return; - if (!strncmp(s, "netd_shared/", BPF_PIN_SUBDIR_CHAR_ARRAY_SIZE)) return; - if (!strncmp(s, "loader/", BPF_PIN_SUBDIR_CHAR_ARRAY_SIZE)) return; - } - ALOGE("unrecognized pin_subdir '%-*s'", BPF_PIN_SUBDIR_CHAR_ARRAY_SIZE, s); - // Note: we *can* just abort() here as we only load bpf .o files shipped - // in the same mainline module / apex as NetBpfLoad itself. - abort(); -} - static string pathToObjName(const string& path) { // extract everything after the final slash, ie. this is the filename 'foo.o' string filename = Split(path, "/").back(); @@ -797,7 +782,6 @@ static bool isBtfSupported(enum bpf_map_type type) { static int pinMap(const borrowed_fd& fd, const struct bpf_map_def& mapDef, const string& mapPinLoc) { int ret; if (mapDef.selinux_context[0]) { - validatePinDir(mapDef.selinux_context); string createLoc = string(BPF_FS_PATH) + mapDef.selinux_context + "tmp_map"; ret = bpfFdPin(fd, createLoc.c_str()); if (ret) { @@ -899,7 +883,6 @@ static enum bpf_map_type sanitizeMapType(enum bpf_map_type type) { static string buildMapPinLoc(const char pin_subdir[BPF_PIN_SUBDIR_CHAR_ARRAY_SIZE], const string& objName, const string& mapName) { - validatePinDir(pin_subdir); // Format of pin location is /sys/fs/bpf/map__ // Note: refers to the extension-less basename of the .o file (without @ suffix). return string(BPF_FS_PATH) + pin_subdir + "map_" + objName + "_" + mapName; @@ -1100,7 +1083,6 @@ static int pinProg(const borrowed_fd& fd, const struct bpf_prog_def& progDef, const string& progPinLoc) { int ret; if (progDef.selinux_context[0]) { - validatePinDir(progDef.selinux_context); string createLoc = string(BPF_FS_PATH) + progDef.selinux_context + "tmp_prog"; ret = bpfFdPin(fd, createLoc.c_str()); if (ret) { @@ -1175,7 +1157,6 @@ static int validateProg(const borrowed_fd& fd, string& progPinLoc, static string buildProgPinLoc(const char pin_subdir[BPF_PIN_SUBDIR_CHAR_ARRAY_SIZE], const string& objName, const string& name) { - validatePinDir(pin_subdir); // Format of pin location is /sys/fs/bpf/prog__ return string(BPF_FS_PATH) + pin_subdir + "prog_" + objName + '_' + string(name); }