Revert "kernel: add package whitelist check for manager APKs"
This commit is contained in:
@@ -327,31 +327,7 @@ module_param_cb(ksu_debug_manager_uid, &expected_size_ops,
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool is_manager_apk(char *path)
|
||||||
#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;
|
|
||||||
}
|
|
||||||
|
|
||||||
return check_v2_signature(path);
|
return check_v2_signature(path);
|
||||||
}
|
}
|
||||||
@@ -3,8 +3,6 @@
|
|||||||
|
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
|
|
||||||
bool is_manager_apk(char *path, char *package);
|
bool is_manager_apk(char *path);
|
||||||
|
|
||||||
bool is_package_whitelisted(char *package);
|
#endif
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -62,8 +62,14 @@ static int get_pkg_from_apk_path(char *pkg, const char *path)
|
|||||||
return 0;
|
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);
|
pr_info("manager pkg: %s\n", pkg);
|
||||||
|
|
||||||
#ifdef KSU_MANAGER_PACKAGE
|
#ifdef KSU_MANAGER_PACKAGE
|
||||||
@@ -170,7 +176,6 @@ FILLDIR_RETURN_TYPE my_actor(struct dir_context *ctx, const char *name,
|
|||||||
} else {
|
} else {
|
||||||
if ((namelen == 8) && (strncmp(name, "base.apk", namelen) == 0)) {
|
if ((namelen == 8) && (strncmp(name, "base.apk", namelen) == 0)) {
|
||||||
struct apk_path_hash *pos;
|
struct apk_path_hash *pos;
|
||||||
char pkg[KSU_MAX_PACKAGE_NAME];
|
|
||||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)
|
||||||
unsigned int hash = full_name_hash(dirpath, strlen(dirpath));
|
unsigned int hash = full_name_hash(dirpath, strlen(dirpath));
|
||||||
#else
|
#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) {
|
bool is_manager = is_manager_apk(dirpath);
|
||||||
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);
|
|
||||||
pr_info("Found new base.apk at path: %s, is_manager: %d\n",
|
pr_info("Found new base.apk at path: %s, is_manager: %d\n",
|
||||||
dirpath, is_manager);
|
dirpath, is_manager);
|
||||||
if (is_manager) {
|
if (is_manager) {
|
||||||
crown_manager(dirpath, pkg, my_ctx->private_data);
|
crown_manager(dirpath, my_ctx->private_data);
|
||||||
*my_ctx->stop = 1;
|
*my_ctx->stop = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -394,4 +394,4 @@ void ksu_throne_tracker_init()
|
|||||||
void ksu_throne_tracker_exit()
|
void ksu_throne_tracker_exit()
|
||||||
{
|
{
|
||||||
// nothing to do
|
// nothing to do
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user