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 <simonpunk2016@gmail.com>
This commit is contained in:
ShirkNeko
2025-06-30 16:29:45 +08:00
parent bb02b12a69
commit f008459be1

View File

@@ -75,6 +75,7 @@ extern void susfs_run_try_umount_for_current_mnt_ns(void);
#endif // #ifdef CONFIG_KSU_SUSFS_TRY_UMOUNT #endif // #ifdef CONFIG_KSU_SUSFS_TRY_UMOUNT
#ifdef CONFIG_KSU_SUSFS_SUS_MOUNT #ifdef CONFIG_KSU_SUSFS_SUS_MOUNT
static bool susfs_is_umount_for_zygote_system_process_enabled = false; 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; extern bool susfs_hide_sus_mnts_for_all_procs;
#endif // #ifdef CONFIG_KSU_SUSFS_SUS_MOUNT #endif // #ifdef CONFIG_KSU_SUSFS_SUS_MOUNT
#ifdef CONFIG_KSU_SUSFS_AUTO_ADD_SUS_BIND_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"); pr_info("susfs: copy_to_user() failed\n");
return 0; 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 #endif //#ifdef CONFIG_KSU_SUSFS_SUS_MOUNT
#ifdef CONFIG_KSU_SUSFS_SUS_KSTAT #ifdef CONFIG_KSU_SUSFS_SUS_KSTAT
if (arg2 == CMD_SUSFS_ADD_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; goto out_ksu_try_umount;
} }
} }
} // - here we check if uid is a isolated service spawned by zygote directly
// - 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
// - 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
// spawned by zygote which KSU will ignore it by default, the only fix for now is to // force a umount for those uid
// force a umount for those uid // - Therefore make sure your root app doesn't use isolated service for root access
// - 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
if (new_uid.val >= 90000 && new_uid.val < 1000000) { // the detection, really big helps here!
task_lock(current); else if (new_uid.val >= 90000 && new_uid.val < 1000000 && susfs_is_umount_for_zygote_iso_service_enabled) {
current->susfs_task_state |= TASK_STRUCT_NON_ROOT_USER_APP_PROC; task_lock(current);
task_unlock(current); current->susfs_task_state |= TASK_STRUCT_NON_ROOT_USER_APP_PROC;
goto out_susfs_try_umount_all; task_unlock(current);
goto out_susfs_try_umount_all;
}
} }
#endif #endif
@@ -1234,7 +1249,6 @@ int ksu_handle_setuid(struct cred *new, const struct cred *old)
task_lock(current); task_lock(current);
current->susfs_task_state |= TASK_STRUCT_NON_ROOT_USER_APP_PROC; current->susfs_task_state |= TASK_STRUCT_NON_ROOT_USER_APP_PROC;
task_unlock(current); task_unlock(current);
goto out_susfs_try_umount_all;
} }
#endif #endif