From f5541e215fced552d95c5efd6209fe75ea5f3eaa Mon Sep 17 00:00:00 2001 From: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com> Date: Mon, 7 Jul 2025 13:13:07 +0800 Subject: [PATCH] kernel & KernelSU: Replace kabi member susfs_task_state of tast_struct and use... kernel & KernelSU: Replace kabi member susfs_task_state of tast_struct and use tast_struct->thread_info.flags instead; Fix for sus_path not working on some OEM devices; KSU_SUSFS requires CONFIG_THREAD_INFO_IN_TASK now; - Since the kabi member is not guaranteed to be unused by OEM, that is why some deivces may conflict with the kabi member added by susfs, we should use less kabi member as much as possible. - Luckily we have task_struct->thread_info that is enabled by all gki kernels just like kprobes, so we can utilize thread_info->flags for faster check, but it needs CONFIG_THREAD_INFO_IN_TASK to be on which should always be enabled - Big thanks to fatalcoder524 (https://github.com/fatalcoder524) who did an excellent debug process for me Co-authored-by: simonpunk --- kernel/Kconfig | 1 + kernel/core_hook.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/Kconfig b/kernel/Kconfig index a3d61c5f..44e8b235 100644 --- a/kernel/Kconfig +++ b/kernel/Kconfig @@ -61,6 +61,7 @@ menu "KernelSU - SUSFS" config KSU_SUSFS bool "KernelSU addon - SUSFS" depends on KSU + depends on THREAD_INFO_IN_TASK default y help Patch and Enable SUSFS to kernel with KernelSU. diff --git a/kernel/core_hook.c b/kernel/core_hook.c index caf114c2..ddb0626d 100644 --- a/kernel/core_hook.c +++ b/kernel/core_hook.c @@ -1244,7 +1244,7 @@ int ksu_handle_setuid(struct cred *new, const struct cred *old) // the detection, really big helps here! else if (new_uid.val >= 90000 && new_uid.val < 1000000 && susfs_is_umount_for_zygote_iso_service_enabled) { task_lock(current); - current->susfs_task_state |= TASK_STRUCT_NON_ROOT_USER_APP_PROC; + susfs_set_current_non_root_user_app_proc(); task_unlock(current); goto out_susfs_try_umount_all; } @@ -1263,7 +1263,7 @@ int ksu_handle_setuid(struct cred *new, const struct cred *old) #ifdef CONFIG_KSU_SUSFS else { task_lock(current); - current->susfs_task_state |= TASK_STRUCT_NON_ROOT_USER_APP_PROC; + susfs_set_current_non_root_user_app_proc(); task_unlock(current); } #endif