kernel: throne_tracker: move throne_tracker to kthread

Runs throne_tracker() in kthread instead of blocking the caller.
Prevents full lockup during installation and removing the manager.

This also looks for manager UID in /data/system/packages.list, not
/data/system/packages.list.tmp

Nice additional side effect is a faster booting.

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
Co-Authored-By: backslashxx <118538522+backslashxx@users.noreply.github.com>
This commit is contained in:
Yaroslav Zviezda
2025-05-14 23:50:57 +03:00
committed by rifsxd
parent d8cb7ef772
commit 6a6fc07cd4

View File

@@ -13,9 +13,13 @@
#include "throne_tracker.h"
#include "kernel_compat.h"
#include <linux/kthread.h>
#include <linux/sched.h>
uid_t ksu_manager_uid = KSU_INVALID_UID;
#define SYSTEM_PACKAGES_LIST_PATH "/data/system/packages.list.tmp"
static struct task_struct *throne_thread;
#define SYSTEM_PACKAGES_LIST_PATH "/data/system/packages.list"
struct uid_data {
struct list_head list;
@@ -284,7 +288,7 @@ static bool is_uid_exist(uid_t uid, char *package, void *data)
return exist;
}
void track_throne()
static void track_throne_function()
{
struct file *fp =
ksu_filp_open_compat(SYSTEM_PACKAGES_LIST_PATH, O_RDONLY, 0);
@@ -379,6 +383,23 @@ out:
}
}
static int throne_tracker_thread(void *data)
{
pr_info("%s: pid: %d started\n", __func__, current->pid);
track_throne_function();
throne_thread = NULL;
pr_info("%s: pid: %d exit!\n", __func__, current->pid);
return 0;
}
void track_throne()
{
throne_thread = kthread_run(throne_tracker_thread, NULL, "throne_tracker");
if (IS_ERR(throne_thread)) {
throne_thread = NULL;
}
}
void ksu_throne_tracker_init()
{
// nothing to do