From c1aa0690c5b2ecee6c83b02446c9b34aefa41c4b Mon Sep 17 00:00:00 2001 From: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com> Date: Thu, 12 Jun 2025 15:14:37 +0800 Subject: [PATCH] Revert "kernel: add package whitelist check for manager APKs" --- kernel/apk_sign.c | 30 +++--------------------------- kernel/apk_sign.h | 6 ++---- kernel/throne_tracker.c | 20 ++++++++++---------- 3 files changed, 15 insertions(+), 41 deletions(-) diff --git a/kernel/apk_sign.c b/kernel/apk_sign.c index f62b9411..fcb2aedc 100644 --- a/kernel/apk_sign.c +++ b/kernel/apk_sign.c @@ -327,31 +327,7 @@ module_param_cb(ksu_debug_manager_uid, &expected_size_ops, #endif - -#define MANAGERPKG_WLSIZE 3 -static const char *manager_package_whitelist[] = { - "zako.zako.zako", - "com.sukisu.ultra", - "me.weishu.kernelsu" -}; - -bool is_package_whitelisted(char *package) { - int i; - for (i = 0; i < MANAGERPKG_WLSIZE; i ++) { - const char* expected = manager_package_whitelist[i]; - if (strcmp(expected, package) == 0) { - return true; - } - } - - return false; -} - -bool is_manager_apk(char *path, char *package) { - if (!is_package_whitelisted(package)) { - pr_info("refused to crown %s (not in whitelist)", package); - return false; - } - +bool is_manager_apk(char *path) +{ return check_v2_signature(path); -} +} \ No newline at end of file diff --git a/kernel/apk_sign.h b/kernel/apk_sign.h index f12fc2b2..786d17bc 100644 --- a/kernel/apk_sign.h +++ b/kernel/apk_sign.h @@ -3,8 +3,6 @@ #include -bool is_manager_apk(char *path, char *package); +bool is_manager_apk(char *path); -bool is_package_whitelisted(char *package); - -#endif +#endif \ No newline at end of file diff --git a/kernel/throne_tracker.c b/kernel/throne_tracker.c index 38321988..109daa20 100644 --- a/kernel/throne_tracker.c +++ b/kernel/throne_tracker.c @@ -62,8 +62,14 @@ static int get_pkg_from_apk_path(char *pkg, const char *path) return 0; } -static void crown_manager(const char *apk, char *pkg, struct list_head *uid_data) +static void crown_manager(const char *apk, struct list_head *uid_data) { + char pkg[KSU_MAX_PACKAGE_NAME]; + if (get_pkg_from_apk_path(pkg, apk) < 0) { + pr_err("Failed to get package name from apk path: %s\n", apk); + return; + } + pr_info("manager pkg: %s\n", pkg); #ifdef KSU_MANAGER_PACKAGE @@ -170,7 +176,6 @@ FILLDIR_RETURN_TYPE my_actor(struct dir_context *ctx, const char *name, } else { if ((namelen == 8) && (strncmp(name, "base.apk", namelen) == 0)) { struct apk_path_hash *pos; - char pkg[KSU_MAX_PACKAGE_NAME]; #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0) unsigned int hash = full_name_hash(dirpath, strlen(dirpath)); #else @@ -183,16 +188,11 @@ FILLDIR_RETURN_TYPE my_actor(struct dir_context *ctx, const char *name, } } - if (get_pkg_from_apk_path(pkg, dirpath) < 0) { - pr_err("Failed to get package name from apk path: %s\n", dirpath); - return FILLDIR_ACTOR_CONTINUE; - } - - bool is_manager = is_manager_apk(dirpath, pkg); + bool is_manager = is_manager_apk(dirpath); pr_info("Found new base.apk at path: %s, is_manager: %d\n", dirpath, is_manager); if (is_manager) { - crown_manager(dirpath, pkg, my_ctx->private_data); + crown_manager(dirpath, my_ctx->private_data); *my_ctx->stop = 1; } } @@ -394,4 +394,4 @@ void ksu_throne_tracker_init() void ksu_throne_tracker_exit() { // nothing to do -} +} \ No newline at end of file