From 59141b2e05def211ce9cb562151e1a0682124264 Mon Sep 17 00:00:00 2001 From: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com> Date: Tue, 18 Nov 2025 15:47:03 +0800 Subject: [PATCH] kernel & KernelSU: Synced with upstream; Original add_try_umount will be used if susfs TRY_UMOUNT is disabled during compile time Co-authored-by: simonpunk --- kernel/kernel_umount.c | 21 ++++++++------------- kernel/kernel_umount.h | 4 ++-- kernel/setuid_hook.c | 3 +++ 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/kernel/kernel_umount.c b/kernel/kernel_umount.c index 694f9921..8156b62e 100644 --- a/kernel/kernel_umount.c +++ b/kernel/kernel_umount.c @@ -96,11 +96,11 @@ static int ksu_sys_umount(const char *mnt, int flags) }) #endif -#ifdef CONFIG_KSU_SUSFS_TRY_UMOUNT -void try_umount(const char *mnt, int flags) -#else +#ifndef CONFIG_KSU_SUSFS_TRY_UMOUNT static void try_umount(const char *mnt, int flags) -#endif // #ifdef CONFIG_KSU_SUSFS_TRY_UMOUNT +#else +void try_umount(const char *mnt, int flags) +#endif // #ifndef CONFIG_KSU_SUSFS_TRY_UMOUNT { struct path path; int ret; @@ -132,17 +132,10 @@ static void try_umount(const char *mnt, int flags) #ifdef CONFIG_KSU_SUSFS_TRY_UMOUNT void susfs_try_umount_all(void) { susfs_try_umount(); - try_umount("/odm", true, 0); - try_umount("/system", true, 0); - try_umount("/vendor", true, 0); - try_umount("/product", true, 0); - try_umount("/system_ext", true, 0); - try_umount("/data/adb/modules", false, MNT_DETACH); - try_umount("/debug_ramdisk", true, MNT_DETACH); } #endif // #ifdef CONFIG_KSU_SUSFS_TRY_UMOUNT -#ifndef CONFIG_KSU_SUSFS +#if !defined(CONFIG_KSU_SUSFS) || !defined(CONFIG_KSU_SUSFS_TRY_UMOUNT) struct umount_tw { struct callback_head cb; const struct cred *old_cred; @@ -177,6 +170,7 @@ int ksu_handle_umount(uid_t old_uid, uid_t new_uid) { struct umount_tw *tw; +#if defined(CONFIG_KSU_SUSFS) || !defined(CONFIG_KSU_SUSFS_TRY_UMOUNT) // this hook is used for umounting overlayfs for some uid, if there isn't any module mounted, just ignore it! if (!ksu_module_mounted) { return 0; @@ -206,6 +200,7 @@ int ksu_handle_umount(uid_t old_uid, uid_t new_uid) #if __SULOG_GATE ksu_sulog_report_syscall(new_uid, NULL, "setuid", NULL); #endif +#endif // #if defined(CONFIG_KSU_SUSFS) || !defined(CONFIG_KSU_SUSFS_TRY_UMOUNT) // umount the target mnt pr_info("handle umount for uid: %d, pid: %d\n", new_uid, current->pid); @@ -227,7 +222,7 @@ int ksu_handle_umount(uid_t old_uid, uid_t new_uid) return 0; } -#endif // #ifndef CONFIG_KSU_SUSFS +#endif // #if !defined(CONFIG_KSU_SUSFS) || !defined(CONFIG_KSU_SUSFS_TRY_UMOUNT) void ksu_kernel_umount_init(void) { diff --git a/kernel/kernel_umount.h b/kernel/kernel_umount.h index 96cf56ce..dcb05597 100644 --- a/kernel/kernel_umount.h +++ b/kernel/kernel_umount.h @@ -8,10 +8,10 @@ void ksu_kernel_umount_init(void); void ksu_kernel_umount_exit(void); -#ifndef CONFIG_KSU_SUSFS +#if !defined(CONFIG_KSU_SUSFS) || !defined(CONFIG_KSU_SUSFS_TRY_UMOUNT) // Handler function to be called from setresuid hook int ksu_handle_umount(uid_t old_uid, uid_t new_uid); -#endif // #ifndef CONFIG_KSU_SUSFS +#endif // #if !defined(CONFIG_KSU_SUSFS) || !defined(CONFIG_KSU_SUSFS_TRY_UMOUNT) // for the umount list struct mount_entry { diff --git a/kernel/setuid_hook.c b/kernel/setuid_hook.c index e16f7be8..07c9a3fe 100644 --- a/kernel/setuid_hook.c +++ b/kernel/setuid_hook.c @@ -318,6 +318,9 @@ do_umount: #ifdef CONFIG_KSU_SUSFS_TRY_UMOUNT pr_info("susfs: running susfs_try_umount_all() for uid: %u\n", new_uid); susfs_try_umount_all(); +#else + // Handle kernel umount + ksu_handle_umount(old_uid, new_uid); #endif // #ifdef CONFIG_KSU_SUSFS_TRY_UMOUNT skip_try_umount: