From 801bcb0e1f8b20e3aaa0bad6b545311f5b1f5714 Mon Sep 17 00:00:00 2001 From: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com> Date: Tue, 4 Nov 2025 21:55:00 +0800 Subject: [PATCH] Revert "Implement workqueue for unmounting" --- .vscode/settings.json | 5 ---- kernel/core_hook.c | 66 ++++++------------------------------------- 2 files changed, 9 insertions(+), 62 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index db55e624..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "files.associations": { - "selinux.h": "c" - } -} \ No newline at end of file diff --git a/kernel/core_hook.c b/kernel/core_hook.c index fab50114..a6d8f7da 100644 --- a/kernel/core_hook.c +++ b/kernel/core_hook.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include @@ -63,13 +62,6 @@ static void ksu_try_escalate_for_uid(uid_t uid) remove_pending_root(uid); } -static struct workqueue_struct *ksu_workqueue; - -struct ksu_umount_work { - struct work_struct work; - struct mnt_namespace *mnt_ns; -}; - static bool ksu_kernel_umount_enabled = true; static int kernel_umount_feature_get(u64 *value) @@ -516,29 +508,6 @@ static void try_umount(const char *mnt, bool check_mnt, int flags) ksu_umount_mnt(&path, flags); } -static void do_umount_work(struct work_struct *work) -{ - struct ksu_umount_work *umount_work = container_of(work, struct ksu_umount_work, work); - struct mnt_namespace *old_mnt_ns = current->nsproxy->mnt_ns; - - current->nsproxy->mnt_ns = umount_work->mnt_ns; - - try_umount("/odm", true, 0); - try_umount("/system", true, 0); - try_umount("/vendor", true, 0); - try_umount("/product", true, 0); - try_umount("/system_ext", true, 0); - try_umount("/data/adb/modules", false, MNT_DETACH); - - // try umount ksu temp path - try_umount("/debug_ramdisk", false, MNT_DETACH); - - // fixme: dec refcount - current->nsproxy->mnt_ns = old_mnt_ns; - - kfree(umount_work); -} - int ksu_handle_setuid(struct cred *new, const struct cred *old) { if (!new || !old) { @@ -620,22 +589,17 @@ int ksu_handle_setuid(struct cred *new, const struct cred *old) // fixme: use `collect_mounts` and `iterate_mount` to iterate all mountpoint and // filter the mountpoint whose target is `/data/adb` - struct ksu_umount_work *umount_work = kmalloc(sizeof(struct ksu_umount_work), GFP_ATOMIC); - if (!umount_work) { - pr_err("Failed to allocate umount_work\n"); - return 0; - } + try_umount("/odm", true, 0); + try_umount("/system", true, 0); + try_umount("/vendor", true, 0); + try_umount("/product", true, 0); + try_umount("/system_ext", true, 0); - // fixme: inc refcount - umount_work->mnt_ns = current->nsproxy->mnt_ns; + try_umount("/data/adb/modules", false, MNT_DETACH); + try_umount("/data/adb/kpm", false, MNT_DETACH); - INIT_WORK(&umount_work->work, do_umount_work); - - queue_work(ksu_workqueue, &umount_work->work); - - get_task_struct(current); // delay fix - ksu_set_current_proc_umounted(); - put_task_struct(current); + // try umount ksu temp path + try_umount("/debug_ramdisk", false, MNT_DETACH); return 0; } @@ -858,14 +822,6 @@ __maybe_unused int ksu_kprobe_exit(void) void __init ksu_core_init(void) { - if (ksu_register_feature_handler(&kernel_umount_handler)) { - pr_err("Failed to register kernel_umount feature handler\n"); - } - - ksu_workqueue = alloc_workqueue("ksu_umount", WQ_UNBOUND, 0); - if (!ksu_workqueue) { - pr_err("Failed to create ksu workqueue\n"); - } #ifdef CONFIG_KPROBES int rc = ksu_kprobe_init(); if (rc) { @@ -885,8 +841,4 @@ void ksu_core_exit(void) pr_info("ksu_core_exit\n"); ksu_kprobe_exit(); #endif - if (ksu_workqueue) { - flush_workqueue(ksu_workqueue); - destroy_workqueue(ksu_workqueue); - } } \ No newline at end of file