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.
This commit is contained in:
5ec1cff
2025-11-15 17:19:45 +08:00
committed by ShirkNeko
parent 83209a5259
commit 04ca981e4d
2 changed files with 4 additions and 11 deletions

View File

@@ -23,7 +23,6 @@
#include "klog.h" // IWYU pragma: keep #include "klog.h" // IWYU pragma: keep
#include "ksud.h" #include "ksud.h"
#include "selinux/selinux.h" #include "selinux/selinux.h"
#include "syscall_hook_manager.h"
#include "throne_tracker.h" #include "throne_tracker.h"
bool ksu_module_mounted __read_mostly = false; bool ksu_module_mounted __read_mostly = false;
@@ -81,8 +80,6 @@ void on_post_fs_data(void)
done = true; done = true;
pr_info("on_post_fs_data!\n"); pr_info("on_post_fs_data!\n");
ksu_load_allow_list(); ksu_load_allow_list();
pr_info("mark tif for running process\n");
ksu_mark_running_process();
ksu_observer_init(); ksu_observer_init();
// sanity check, this may influence the performance // sanity check, this may influence the performance
stop_input_hook(); stop_input_hook();
@@ -128,9 +125,6 @@ void on_boot_completed(void){
ksu_boot_completed = true; ksu_boot_completed = true;
pr_info("on_boot_completed!\n"); pr_info("on_boot_completed!\n");
track_throne(true); track_throne(true);
// remark process, we don't want to mark other init
// forked process excepte zygote and adbd
ksu_mark_running_process();
} }
#define MAX_ARG_STRINGS 0x7FFFFFFF #define MAX_ARG_STRINGS 0x7FFFFFFF
@@ -327,7 +321,6 @@ int ksu_handle_execveat_ksud(int *fd, struct filename **filename_ptr,
task_work_add(init_task, &on_post_fs_data_cb, TWA_RESUME); task_work_add(init_task, &on_post_fs_data_cb, TWA_RESUME);
} }
rcu_read_unlock(); rcu_read_unlock();
ksu_set_task_tracepoint_flag(current); // we are zygote!
stop_execve_hook(); stop_execve_hook();
} }
@@ -662,6 +655,5 @@ void ksu_ksud_exit()
// unregister_kprobe(&vfs_read_kp); // unregister_kprobe(&vfs_read_kp);
unregister_kprobe(&input_event_kp); unregister_kprobe(&input_event_kp);
#endif #endif
is_boot_phase = false; is_boot_phase = false;
} }

View File

@@ -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) int ksu_handle_init_mark_tracker(const char __user **filename_user)
{ {
char path[64]; char path[64];
@@ -253,7 +253,8 @@ int ksu_handle_init_mark_tracker(const char __user **filename_user)
memset(path, 0, sizeof(path)); memset(path, 0, sizeof(path));
strncpy_from_user_nofault(path, *filename_user, 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); ksu_clear_task_tracepoint_flag_if_needed(current);
} }