From f008459be14ad394e7fedc856bac1e9cf631d355 Mon Sep 17 00:00:00 2001 From: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com> Date: Mon, 30 Jun 2025 16:29:45 +0800 Subject: [PATCH] kernel & KernelSU: Added switch for enabling/disabling umount for zygote... kernel & KernelSU: Added switch for enabling/disabling umount for zygote spawned isolated service process - Some modules that overlay sysyem files like framework or other overlay apk may crash when all iso services are umounted by susfs, so a switch is made here for users to switch on/off this funtion at anytime when they need it or want to test it - By default it is disabled in kernel, run "ksu_susfs umount_for_zygote_iso_service <0|1>" to switch on/off the function in userspace - Also user can create new file to "/data/adb/susfs_umount_for_zygote_iso_service" to enable it in kernel on each boot - Alternatively, disable this function and use other modules to handle the umount for iso services until a better solution is found Co-authored-by: simonpunk --- kernel/core_hook.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/kernel/core_hook.c b/kernel/core_hook.c index 2f824919..288ebef4 100644 --- a/kernel/core_hook.c +++ b/kernel/core_hook.c @@ -75,6 +75,7 @@ extern void susfs_run_try_umount_for_current_mnt_ns(void); #endif // #ifdef CONFIG_KSU_SUSFS_TRY_UMOUNT #ifdef CONFIG_KSU_SUSFS_SUS_MOUNT static bool susfs_is_umount_for_zygote_system_process_enabled = false; +static bool susfs_is_umount_for_zygote_iso_service_enabled = false; extern bool susfs_hide_sus_mnts_for_all_procs; #endif // #ifdef CONFIG_KSU_SUSFS_SUS_MOUNT #ifdef CONFIG_KSU_SUSFS_AUTO_ADD_SUS_BIND_MOUNT @@ -675,6 +676,18 @@ int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3, pr_info("susfs: copy_to_user() failed\n"); return 0; } + if (arg2 == CMD_SUSFS_UMOUNT_FOR_ZYGOTE_ISO_SERVICE) { + int error = 0; + if (arg3 != 0 && arg3 != 1) { + pr_err("susfs: CMD_SUSFS_UMOUNT_FOR_ZYGOTE_ISO_SERVICE -> arg3 can only be 0 or 1\n"); + return 0; + } + susfs_is_umount_for_zygote_iso_service_enabled = arg3; + pr_info("susfs: CMD_SUSFS_UMOUNT_FOR_ZYGOTE_ISO_SERVICE -> susfs_is_umount_for_zygote_iso_service_enabled: %lu\n", arg3); + if (copy_to_user((void __user*)arg5, &error, sizeof(error))) + pr_info("susfs: copy_to_user() failed\n"); + return 0; + } #endif //#ifdef CONFIG_KSU_SUSFS_SUS_MOUNT #ifdef CONFIG_KSU_SUSFS_SUS_KSTAT if (arg2 == CMD_SUSFS_ADD_SUS_KSTAT) { @@ -1206,17 +1219,19 @@ int ksu_handle_setuid(struct cred *new, const struct cred *old) goto out_ksu_try_umount; } } - } - // - here we check if uid is a isolated service spawned by zygote directly - // - Apps that do not use "useAppZyogte" to start a isolated service will be directly - // spawned by zygote which KSU will ignore it by default, the only fix for now is to - // force a umount for those uid - // - Therefore make sure your root app doesn't use isolated service for root access - if (new_uid.val >= 90000 && new_uid.val < 1000000) { - task_lock(current); - current->susfs_task_state |= TASK_STRUCT_NON_ROOT_USER_APP_PROC; - task_unlock(current); - goto out_susfs_try_umount_all; + // - here we check if uid is a isolated service spawned by zygote directly + // - Apps that do not use "useAppZyogte" to start a isolated service will be directly + // spawned by zygote which KSU will ignore it by default, the only fix for now is to + // force a umount for those uid + // - Therefore make sure your root app doesn't use isolated service for root access + // - Kudos to ThePedroo, the author and maintainer of Rezygisk for finding and reporting + // 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; + task_unlock(current); + goto out_susfs_try_umount_all; + } } #endif @@ -1234,7 +1249,6 @@ int ksu_handle_setuid(struct cred *new, const struct cred *old) task_lock(current); current->susfs_task_state |= TASK_STRUCT_NON_ROOT_USER_APP_PROC; task_unlock(current); - goto out_susfs_try_umount_all; } #endif