|
16 | 16 | #include <linux/mount.h> |
17 | 17 | #include <linux/fs.h> |
18 | 18 | #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) |
20 | 20 | #include <linux/syscalls.h> // sys_umount |
21 | 21 | #endif |
22 | 22 |
|
@@ -509,13 +509,11 @@ static bool should_umount(struct path *path) |
509 | 509 | return false; |
510 | 510 | } |
511 | 511 |
|
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) |
514 | 514 | { |
515 | 515 | 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); |
519 | 517 | } |
520 | 518 | #else |
521 | 519 | static void ksu_sys_umount(const char *mnt, int flags) |
@@ -543,20 +541,23 @@ static void try_umount(const char *mnt, bool check_mnt, int flags) |
543 | 541 | } |
544 | 542 |
|
545 | 543 | if (path.dentry != path.mnt->mnt_root) { |
| 544 | + path_put(&path); |
546 | 545 | // it is not root mountpoint, maybe umounted by others already. |
547 | 546 | return; |
548 | 547 | } |
549 | 548 |
|
550 | 549 | // we are only interest in some specific mounts |
551 | 550 | if (check_mnt && !should_umount(&path)) { |
| 551 | + path_put(&path); |
552 | 552 | return; |
553 | 553 | } |
554 | 554 |
|
555 | | -#ifdef KSU_HAS_PATH_UMOUNT |
556 | | - ksu_umount_mnt(&path, flags); |
| 555 | +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0) || defined(KSU_HAS_PATH_UMOUNT) |
| 556 | + ksu_path_umount(mnt, &path, flags); |
557 | 557 | #else |
558 | 558 | ksu_sys_umount(mnt, flags); |
559 | 559 | #endif |
| 560 | + path_put(&path); |
560 | 561 | } |
561 | 562 |
|
562 | 563 | int ksu_handle_setuid(struct cred *new, const struct cred *old) |
|
0 commit comments