From 70f722e6142f968f4bd581a28168d6d05fda12fd Mon Sep 17 00:00:00 2001 From: 5ec1cff <56485584+5ec1cff@users.noreply.github.com> Date: Sat, 15 Nov 2025 17:19:45 +0800 Subject: [PATCH] kernel: no need to remark process on post-fs-data and boot-completed - Remark on post-fs-data may unmark zygote unexpectedly, and there is no necessity to remark on these stages, so simply remove them. --- kernel/ksud.c | 18 +----------------- kernel/syscall_hook_manager.c | 5 +++-- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/kernel/ksud.c b/kernel/ksud.c index 1b89d4f0..ba07ea4e 100644 --- a/kernel/ksud.c +++ b/kernel/ksud.c @@ -33,9 +33,6 @@ #include "klog.h" // IWYU pragma: keep #include "ksud.h" #include "selinux/selinux.h" -#ifndef CONFIG_KSU_SUSFS -#include "syscall_hook_manager.h" -#endif // #ifndef CONFIG_KSU_SUSFS #include "throne_tracker.h" bool ksu_module_mounted __read_mostly = false; @@ -93,10 +90,6 @@ void on_post_fs_data(void) done = true; pr_info("on_post_fs_data!\n"); ksu_load_allow_list(); -#ifndef CONFIG_KSU_SUSFS - pr_info("mark tif for running process\n"); - ksu_mark_running_process(); -#endif // #ifndef CONFIG_KSU_SUSFS ksu_observer_init(); // sanity check, this may influence the performance stop_input_hook(); @@ -142,12 +135,6 @@ void on_boot_completed(void){ ksu_boot_completed = true; pr_info("on_boot_completed!\n"); track_throne(true); -#ifndef CONFIG_KSU_SUSFS - // remark process, we don't want to mark other init - // forked process excepte zygote and adbd - ksu_unmark_all_process(); - ksu_mark_running_process(); -#endif // #ifndef CONFIG_KSU_SUSFS } #ifndef CONFIG_KSU_SUSFS @@ -346,9 +333,6 @@ int ksu_handle_execveat_ksud(int *fd, struct filename **filename_ptr, task_work_add(init_task, &on_post_fs_data_cb, TWA_RESUME); } rcu_read_unlock(); -#ifndef CONFIG_KSU_SUSFS - ksu_set_task_tracepoint_flag(current); // we are zygote! -#endif stop_execve_hook(); } @@ -685,4 +669,4 @@ void ksu_ksud_exit(void) #endif is_boot_phase = false; volumedown_pressed_count = 0; -} \ No newline at end of file +} diff --git a/kernel/syscall_hook_manager.c b/kernel/syscall_hook_manager.c index dc87b4e6..4ecb816d 100644 --- a/kernel/syscall_hook_manager.c +++ b/kernel/syscall_hook_manager.c @@ -242,7 +242,7 @@ static inline bool check_syscall_fastpath(int nr) } } -// Unmark init's child that are not zygote or adbd +// Unmark init's child that are not zygote, adbd or ksud int ksu_handle_init_mark_tracker(const char __user **filename_user) { char path[64]; @@ -253,7 +253,8 @@ int ksu_handle_init_mark_tracker(const char __user **filename_user) memset(path, 0, sizeof(path)); strncpy_from_user_nofault(path, *filename_user, sizeof(path)); - if (likely(strstr(path, "/app_process") == NULL && strstr(path, "/adbd") == NULL)) { + if (likely(strstr(path, "/app_process") == NULL && strstr(path, "/adbd") == NULL && strstr(path, "/ksud") == NULL)) { + pr_info("hook_manager: unmark %d exec %s", current->pid, path); ksu_clear_task_tracepoint_flag_if_needed(current); }