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 <simonpunk2016@gmail.com>
This commit is contained in:
ShirkNeko
2025-11-18 15:47:03 +08:00
parent 02c3f70ab5
commit 59141b2e05
3 changed files with 13 additions and 15 deletions

View File

@@ -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)
{

View File

@@ -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 {

View File

@@ -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: