Skip to content

Commit

Permalink
kernel: make path_umount backporting mandatory
Browse files Browse the repository at this point in the history
References:
backslashxx@d24b41d
backslashxx@d2fa0b9

Thanks to @backslashxx

Signed-off-by: rsuntk <rissu.ntk@gmail.com>
  • Loading branch information
rsuntk committed Dec 10, 2024
1 parent 1b771be commit 2f3637b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
3 changes: 0 additions & 3 deletions kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ ccflags-y += -DEXPECTED_HASH_CUST=\"$(KSU_EXPECTED_HASH_CUST)\"

ifeq ($(shell grep -q "int path_umount" $(srctree)/fs/namespace.c; echo $$?),0)
ccflags-y += -DKSU_UMOUNT
else
$(info -- Did you know you can backport path_umount to fs/namespace.c from 5.9?)
$(info -- Read: https://kernelsu.org/guide/how-to-integrate-for-non-gki.html#how-to-backport-path-umount)
endif

ccflags-y += -Wno-implicit-function-declaration -Wno-strict-prototypes -Wno-int-conversion -Wno-gcc-compat
Expand Down
26 changes: 14 additions & 12 deletions kernel/core_hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,14 +450,12 @@ static bool should_umount(struct path *path)
return false;
}

static int 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) || defined(KSU_UMOUNT)
return path_umount(path, flags);
#else
// TODO: umount for non GKI kernel
return -ENOSYS;
#endif
int err = path_umount(path, flags);
if (err) {
pr_info("umount %s failed: %d\n", path->dentry->d_iname, err);
}
}

static void try_umount(const char *mnt, bool check_mnt, int flags)
Expand All @@ -477,11 +475,15 @@ static void try_umount(const char *mnt, bool check_mnt, int flags)
if (check_mnt && !should_umount(&path)) {
return;
}

err = ksu_umount_mnt(&path, flags);
if (err) {
pr_warn("umount %s failed: %d\n", mnt, err);
}

#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0) || defined(KSU_UMOUNT)
ksu_umount_mnt(&path, flags);
#else
#error You should backport path_umount to fs/namespace.c !
#error Read: https://kernelsu.org/guide/how-to-integrate-for-non-gki.html#how-to-backport-path-umount
#error Read: https://github.com/tiann/KernelSU/pull/1464
#endif

}

int ksu_handle_setuid(struct cred *new, const struct cred *old)
Expand Down

0 comments on commit 2f3637b

Please sign in to comment.