From f5cfb3288221cb22d40167572a9cb91a1c6634db Mon Sep 17 00:00:00 2001 From: weishu Date: Thu, 22 Jun 2023 15:17:32 +0800 Subject: [PATCH] kernel: fix incorrect umount for apps --- kernel/core_hook.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/kernel/core_hook.c b/kernel/core_hook.c index b0acb224..654e2782 100644 --- a/kernel/core_hook.c +++ b/kernel/core_hook.c @@ -475,12 +475,7 @@ static bool should_umount(struct path *path) if (path->mnt && path->mnt->mnt_sb && path->mnt->mnt_sb->s_type) { const char *fstype = path->mnt->mnt_sb->s_type->name; - if (strcmp(fstype, "overlay") == 0) { - return ksu_uid_should_umount(current_uid().val); - } -#ifdef CONFIG_KSU_DEBUG - pr_info("uid: %d should not umount!\n", current_uid().val); -#endif + return strcmp(fstype, "overlay") == 0; } return false; } @@ -532,6 +527,14 @@ int ksu_handle_setuid(struct cred *new, const struct cred *old) return 0; } + if (!ksu_uid_should_umount(new_uid.val)) { + return 0; + } else { +#ifdef CONFIG_KSU_DEBUG + pr_info("uid: %d should not umount!\n", current_uid().val); +#endif + } + // umount the target mnt pr_info("handle umount for uid: %d\n", new_uid.val);