Skip to content

Commit

Permalink
kernel: ignore path that's not mountpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
tiann committed Oct 12, 2023
1 parent 8828939 commit 79951f0
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions kernel/core_hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -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/<userId>/<manager_package_name>`
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
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
Expand Down

0 comments on commit 79951f0

Please sign in to comment.