Skip to content

Commit 36c39b0

Browse files
committed
kernel: core_hook: tweak and rename path_umount handler
rename function to ksu_path_umount to clearly differntiate it from sys_umount. Pass mnt string directly to avoid redundant resolution for debug logging. Small touches, to make it neater. - also fix missed path_put Signed-off-by: backslashxx <[email protected]>
1 parent f13db8c commit 36c39b0

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

kernel/core_hook.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <linux/mount.h>
1717
#include <linux/fs.h>
1818
#include <linux/namei.h>
19-
#ifndef KSU_HAS_PATH_UMOUNT
19+
#if !(LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0)) && !defined(KSU_HAS_PATH_UMOUNT)
2020
#include <linux/syscalls.h> // sys_umount
2121
#endif
2222

@@ -509,13 +509,11 @@ static bool should_umount(struct path *path)
509509
return false;
510510
}
511511

512-
#ifdef KSU_HAS_PATH_UMOUNT
513-
static void ksu_umount_mnt(struct path *path, int flags)
512+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0) || defined(KSU_HAS_PATH_UMOUNT)
513+
static void ksu_path_umount(const char *mnt, struct path *path, int flags)
514514
{
515515
int err = path_umount(path, flags);
516-
if (err) {
517-
pr_info("umount %s failed: %d\n", path->dentry->d_iname, err);
518-
}
516+
pr_info("%s: path: %s code: %d\n", __func__, mnt, err);
519517
}
520518
#else
521519
static void ksu_sys_umount(const char *mnt, int flags)
@@ -543,6 +541,7 @@ static void try_umount(const char *mnt, bool check_mnt, int flags)
543541
}
544542

545543
if (path.dentry != path.mnt->mnt_root) {
544+
path_put(&path);
546545
// it is not root mountpoint, maybe umounted by others already.
547546
return;
548547
}
@@ -553,10 +552,11 @@ static void try_umount(const char *mnt, bool check_mnt, int flags)
553552
}
554553

555554
#ifdef KSU_HAS_PATH_UMOUNT
556-
ksu_umount_mnt(&path, flags);
555+
ksu_path_umount(mnt, &path, flags);
557556
#else
558557
ksu_sys_umount(mnt, flags);
559558
#endif
559+
path_put(&path);
560560
}
561561

562562
int ksu_handle_setuid(struct cred *new, const struct cred *old)

0 commit comments

Comments
 (0)