Skip to content

Commit

Permalink
kernel: remove become_manager and minor refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
tiann committed Mar 24, 2024
1 parent fc613d5 commit dc5f911
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 125 deletions.
3 changes: 1 addition & 2 deletions kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ kernelsu-objs := ksu.o
kernelsu-objs += allowlist.o
kernelsu-objs += apk_sign.o
kernelsu-objs += sucompat.o
kernelsu-objs += uid_observer.o
kernelsu-objs += manager.o
kernelsu-objs += throne_tracker.o
kernelsu-objs += core_hook.o
kernelsu-objs += ksud.o
kernelsu-objs += embed_ksud.o
Expand Down
5 changes: 3 additions & 2 deletions kernel/core_hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
#include "linux/vmalloc.h"
#include "manager.h"
#include "selinux/selinux.h"
#include "uid_observer.h"
#include "throne_tracker.h"
#include "throne_tracker.h"
#include "kernel_compat.h"

static bool ksu_module_mounted = false;
Expand Down Expand Up @@ -199,7 +200,7 @@ int ksu_handle_rename(struct dentry *old_dentry, struct dentry *new_dentry)
pr_info("renameat: %s -> %s, new path: %s\n", old_dentry->d_iname,
new_dentry->d_iname, buf);

update_uid();
track_throne();

return 0;
}
Expand Down
6 changes: 3 additions & 3 deletions kernel/ksu.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "core_hook.h"
#include "klog.h" // IWYU pragma: keep
#include "ksu.h"
#include "uid_observer.h"
#include "throne_tracker.h"

static struct workqueue_struct *ksu_workqueue;

Expand Down Expand Up @@ -53,7 +53,7 @@ int __init kernelsu_init(void)

ksu_allowlist_init();

ksu_uid_observer_init();
ksu_throne_tracker_init();

#ifdef CONFIG_KPROBES
ksu_enable_sucompat();
Expand All @@ -74,7 +74,7 @@ void kernelsu_exit(void)
{
ksu_allowlist_exit();

ksu_uid_observer_exit();
ksu_throne_tracker_exit();

destroy_workqueue(ksu_workqueue);

Expand Down
102 changes: 0 additions & 102 deletions kernel/manager.c

This file was deleted.

2 changes: 0 additions & 2 deletions kernel/manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,4 @@ static inline void ksu_invalidate_manager_uid()
ksu_manager_uid = KSU_INVALID_UID;
}

bool become_manager(char *pkg);

#endif
18 changes: 14 additions & 4 deletions kernel/uid_observer.c → kernel/throne_tracker.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
#include "klog.h" // IWYU pragma: keep
#include "ksu.h"
#include "manager.h"
#include "uid_observer.h"
#include "throne_tracker.h"
#include "kernel_compat.h"

uid_t ksu_manager_uid = KSU_INVALID_UID;

#define SYSTEM_PACKAGES_LIST_PATH "/data/system/packages.list"
static struct work_struct ksu_update_uid_work;

Expand Down Expand Up @@ -71,6 +73,14 @@ static void crown_manager(const char *apk, struct list_head *uid_data)

pr_info("manager pkg: %s\n", pkg);

#ifdef KSU_MANAGER_PACKAGE
// pkg is `/<real package>`
if (strncmp(pkg, KSU_MANAGER_PACKAGE, sizeof(KSU_MANAGER_PACKAGE))) {
pr_info("manager package is inconsistent with kernel build: %s\n",
KSU_MANAGER_PACKAGE);
return;
}
#endif
struct list_head *list = (struct list_head *)uid_data;
struct uid_data *np;

Expand Down Expand Up @@ -292,18 +302,18 @@ static void do_update_uid(struct work_struct *work)
filp_close(fp, 0);
}

void update_uid()
void track_throne()
{
ksu_queue_work(&ksu_update_uid_work);
}

int ksu_uid_observer_init()
int ksu_throne_tracker_init()
{
INIT_WORK(&ksu_update_uid_work, do_update_uid);
return 0;
}

int ksu_uid_observer_exit()
int ksu_throne_tracker_exit()
{
return 0;
}
10 changes: 10 additions & 0 deletions kernel/throne_tracker.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef __KSU_H_UID_OBSERVER
#define __KSU_H_UID_OBSERVER

int ksu_throne_tracker_init();

int ksu_throne_tracker_exit();

void track_throne();

#endif
10 changes: 0 additions & 10 deletions kernel/uid_observer.h

This file was deleted.

0 comments on commit dc5f911

Please sign in to comment.