From 79951f06ed94baad11d2e6a85745311535e6df87 Mon Sep 17 00:00:00 2001 From: weishu Date: Thu, 12 Oct 2023 14:24:41 +0800 Subject: [PATCH] kernel: ignore path that's not mountpoint --- kernel/core_hook.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/kernel/core_hook.c b/kernel/core_hook.c index 3ab88f572fe7..176a0239db0a 100644 --- a/kernel/core_hook.c +++ b/kernel/core_hook.c @@ -233,7 +233,8 @@ int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3, // someone wants to be root manager, just check it! // arg3 should be `/data/user//` char param[128]; - if (ksu_strncpy_from_user_nofault(param, arg3, sizeof(param)) == -EFAULT) { + if (ksu_strncpy_from_user_nofault(param, arg3, sizeof(param)) == + -EFAULT) { #ifdef CONFIG_KSU_DEBUG pr_err("become_manager: copy param err\n"); #endif @@ -483,7 +484,8 @@ static bool should_umount(struct path *path) return false; } -static void ksu_umount_mnt(struct path *path, int flags) { +static void ksu_umount_mnt(struct path *path, int flags) +{ #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0) int err = path_umount(path, flags); if (err) { @@ -502,6 +504,11 @@ static void try_umount(const char *mnt, bool check_mnt, int flags) return; } + if (path.dentry != path.mnt->mnt_root) { + // it is not root mountpoint, maybe umounted by others already. + return; + } + // we are only interest in some specific mounts if (check_mnt && !should_umount(&path)) { return;