From 0c0f65998d196bd60afe8fd8867a9643ec8a4c5d Mon Sep 17 00:00:00 2001 From: ThePedroo Date: Sat, 26 Apr 2025 06:02:03 -0300 Subject: [PATCH] remove: ReZygiskd `dl.c` This commit removes the "dl.c" file, which was used for using "android_dlopen_ext" in a new namespace, used to isolate libraries, which is not necessary here as they are on different processes, hence "dlopen" can be used. --- zygiskd/build.gradle.kts | 1 - zygiskd/src/companion.c | 3 +-- zygiskd/src/dl.c | 57 ---------------------------------------- zygiskd/src/dl.h | 6 ----- 4 files changed, 1 insertion(+), 66 deletions(-) delete mode 100644 zygiskd/src/dl.c delete mode 100644 zygiskd/src/dl.h diff --git a/zygiskd/build.gradle.kts b/zygiskd/build.gradle.kts index a3a2984..53a486c 100644 --- a/zygiskd/build.gradle.kts +++ b/zygiskd/build.gradle.kts @@ -51,7 +51,6 @@ val Files = arrayOf( "root_impl/kernelsu.c", "root_impl/magisk.c", "companion.c", - "dl.c", "main.c", "utils.c", "zygiskd.c" diff --git a/zygiskd/src/companion.c b/zygiskd/src/companion.c index 9261b6f..4e9ca96 100644 --- a/zygiskd/src/companion.c +++ b/zygiskd/src/companion.c @@ -15,7 +15,6 @@ #include -#include "dl.h" #include "utils.h" #undef LOG_TAG @@ -32,7 +31,7 @@ zygisk_companion_entry load_module(int fd) { char path[PATH_MAX]; snprintf(path, sizeof(path), "/proc/self/fd/%d", fd); - void *handle = dlopen_ext(path, RTLD_NOW); + void *handle = dlopen(path, RTLD_NOW); if (!handle) return NULL; diff --git a/zygiskd/src/dl.c b/zygiskd/src/dl.c deleted file mode 100644 index 0be28f0..0000000 --- a/zygiskd/src/dl.c +++ /dev/null @@ -1,57 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "companion.h" -#include "utils.h" - -#define __LOADER_ANDROID_CREATE_NAMESPACE_TYPE(name) struct android_namespace_t *(*name)( \ - const char *name, \ - const char *ld_library_path, \ - const char *default_library_path, \ - uint64_t type, \ - const char *permitted_when_isolated_path, \ - struct android_namespace_t *parent, \ - const void *caller_addr) - -void *dlopen_ext(const char* path, int flags) { - android_dlextinfo info = { 0 }; - char *dir = dirname(path); - - __LOADER_ANDROID_CREATE_NAMESPACE_TYPE(__loader_android_create_namespace) = (__LOADER_ANDROID_CREATE_NAMESPACE_TYPE( ))dlsym(RTLD_DEFAULT, "__loader_android_create_namespace"); - - struct android_namespace_t *ns = __loader_android_create_namespace == NULL ? NULL : - __loader_android_create_namespace(path, dir, NULL, - 2, /* ANDROID_NAMESPACE_TYPE_SHARED */ - NULL, NULL, - (void *)&dlopen_ext); - - if (ns) { - info.flags = ANDROID_DLEXT_USE_NAMESPACE; - info.library_namespace = ns; - - LOGI("Open %s with namespace %p", path, (void *)ns); - } else { - LOGW("Cannot create namespace for %s", path); - } - - void *handle = android_dlopen_ext(path, flags, &info); - if (handle) { - LOGI("dlopen %s: %p", path, handle); - } else { - LOGE("dlopen %s: %s", path, dlerror()); - } - - return handle; -} diff --git a/zygiskd/src/dl.h b/zygiskd/src/dl.h deleted file mode 100644 index de5060f..0000000 --- a/zygiskd/src/dl.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef DL_H -#define DL_H - -void *dlopen_ext(char *path, int flags); - -#endif /* DL_H */