diff --git a/kernel/kernel_umount.c b/kernel/kernel_umount.c index 0e65f13d..d714a221 100644 --- a/kernel/kernel_umount.c +++ b/kernel/kernel_umount.c @@ -71,7 +71,7 @@ static void ksu_umount_mnt(struct path *path, int flags) } } -static void try_umount(const char *mnt, bool check_mnt, int flags) +void try_umount(const char *mnt, bool check_mnt, int flags) { struct path path; int err = kern_path(mnt, 0, &path); diff --git a/kernel/kernel_umount.h b/kernel/kernel_umount.h index 4c7a158c..68d2f759 100644 --- a/kernel/kernel_umount.h +++ b/kernel/kernel_umount.h @@ -6,6 +6,8 @@ void ksu_kernel_umount_init(void); void ksu_kernel_umount_exit(void); +void try_umount(const char *mnt, bool check_mnt, int flags); + // Handler function to be called from setresuid hook int ksu_handle_umount(uid_t old_uid, uid_t new_uid); diff --git a/kernel/umount_manager.c b/kernel/umount_manager.c index e143a644..5d1e6039 100644 --- a/kernel/umount_manager.c +++ b/kernel/umount_manager.c @@ -1,4 +1,3 @@ -#include "umount_manager.h" #include #include #include @@ -6,29 +5,19 @@ #include #include #include + #include "klog.h" +#include "kernel_umount.h" +#include "umount_manager.h" static struct umount_manager g_umount_mgr = { .entry_count = 0, .max_entries = 64, }; -extern int path_umount(struct path *path, int flags); - -static bool check_path_busy(const char *path) +static void try_umount_path(struct umount_entry *entry) { - struct path kpath; - int err; - - err = kern_path(path, 0, &kpath); - if (err) { - return false; - } - - bool busy = (kpath.mnt->mnt_root != kpath.dentry); - path_put(&kpath); - - return busy; + try_umount(entry->path, entry->check_mnt, entry->flags); } static struct umount_entry *find_entry_locked(const char *path) @@ -196,44 +185,6 @@ out: return ret; } -bool ksu_umount_path_is_busy(const char *path) -{ - return check_path_busy(path); -} - -static void try_umount_path(struct umount_entry *entry) -{ - struct path kpath; - int err; - - err = kern_path(entry->path, 0, &kpath); - if (err) { - return; - } - - if (kpath.dentry != kpath.mnt->mnt_root) { - path_put(&kpath); - return; - } - - if (entry->check_mnt) { - if (kpath.mnt && kpath.mnt->mnt_sb && kpath.mnt->mnt_sb->s_type) { - const char *fstype = kpath.mnt->mnt_sb->s_type->name; - if (strcmp(fstype, "overlay") != 0) { - path_put(&kpath); - return; - } - } - } - - err = path_umount(&kpath, entry->flags); - if (err) { - pr_info("umount %s failed: %d\n", entry->path, err); - } - - path_put(&kpath); -} - void ksu_umount_manager_execute_all(const struct cred *cred) { struct umount_entry *entry; diff --git a/kernel/umount_manager.h b/kernel/umount_manager.h index 75c550e1..f0299b40 100644 --- a/kernel/umount_manager.h +++ b/kernel/umount_manager.h @@ -59,7 +59,6 @@ int ksu_umount_manager_init(void); void ksu_umount_manager_exit(void); int ksu_umount_manager_add(const char *path, bool check_mnt, int flags, bool is_default); int ksu_umount_manager_remove(const char *path); -bool ksu_umount_path_is_busy(const char *path); void ksu_umount_manager_execute_all(const struct cred *cred); int ksu_umount_manager_get_entries(struct ksu_umount_entry_info __user *entries, u32 *count); int ksu_umount_manager_clear_custom(void);