From 35102771fe53efe19d6a4ffb27057d0237830f1e Mon Sep 17 00:00:00 2001 From: backslashxx <118538522+backslashxx@users.noreply.github.com> Date: Mon, 18 Mar 2024 10:27:31 +0800 Subject: [PATCH] Suggest non-gki kernel users to backport path_umount (#1464) Most kernel builders have to touch their kernel source code anyway, why not also tell them to backport path_umount so even non-gki users can benefit from this? I know this might be a bit controversial as this will raise the barrier of entry, but the benefits are just so high. Idea was from OnlyTomInSecond on KernelSU group chat way back, and it has been on the discussions for some time references: https://t.me/KernelSU_group/27237/176515 https://t.me/KernelSU_group/3249/184908 https://github.com/tiann/KernelSU/discussions/955#discussioncomment-7617166 https://github.com/OnlyTomInSecond/android_kernel_xiaomi_sdm845/commit/03d233db8bbe9fe101509430bfa09d1899168aa7 https://github.com/tiann/KernelSU/pull/1060 https://elixir.bootlin.com/linux/v5.9.1/source/fs/namespace.c#L1728 https://elixir.bootlin.com/linux/v5.10.9/source/fs/namespace.c#L1730 https://elixir.bootlin.com/linux/v6.5/source/fs/namespace.c#L1887 https://github.com/tiann/KernelSU/pull/1464#issuecomment-2002492107 Kernel side change examples 5.4 https://github.com/natsumerinchan/kernel_oneplus_sm8350/commit/961d9788624e88c3c58918b3781b9fbdd19ecbeb 4.19 https://github.com/backslashxx/android_karnol_ximi_fog/commit/164917f56d0e75ab51bb9f1bdf489acac7a6d3db 4.14 https://github.com/crdroidandroid/android_kernel_xiaomi_sm6150/commit/c07c70a0c59fb46ac0c1c812c3e993022e375cd5 4.9 https://github.com/backslashxx/msm8953-los21/commit/195f07593ae9769a992f3945bcdc43ff7fc99827 4.4 https://github.com/riarumoda/android_kernel_samsung_a9y18qlte/commit/21ea33fe41ce079ec1d663c0bd2201bc00a8084a https://github.com/tiann/KernelSU/pull/1464#issuecomment-2002424069 ofcourse having someone on 3.18 confirm this will be nice. **PROS**: umount modules for everyone **CONS**: barrier of entry +1 --------- Co-authored-by: Christoph Hellwig Co-authored-by: Fede2782 <78815152+Fede2782@users.noreply.github.com> Co-authored-by: Tom <31297720+onlytominsecond@users.noreply.github.com> --- drivers/kernelsu/Makefile | 7 +++++++ drivers/kernelsu/core_hook.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/kernelsu/Makefile b/drivers/kernelsu/Makefile index 9cf898c9d3d5..f63146d3e687 100644 --- a/drivers/kernelsu/Makefile +++ b/drivers/kernelsu/Makefile @@ -56,5 +56,12 @@ $(info -- KernelSU Manager signature hash: $(KSU_EXPECTED_HASH)) ccflags-y += -DEXPECTED_SIZE=$(KSU_EXPECTED_SIZE) ccflags-y += -DEXPECTED_HASH=\"$(KSU_EXPECTED_HASH)\" +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#path_umount) +endif + ccflags-y += -Wno-implicit-function-declaration -Wno-strict-prototypes -Wno-int-conversion -Wno-gcc-compat ccflags-y += -Wno-declaration-after-statement -Wno-unused-function diff --git a/drivers/kernelsu/core_hook.c b/drivers/kernelsu/core_hook.c index 81b4ea3210fd..b5eb5b59da4f 100644 --- a/drivers/kernelsu/core_hook.c +++ b/drivers/kernelsu/core_hook.c @@ -522,7 +522,7 @@ static bool should_umount(struct path *path) static void ksu_umount_mnt(struct path *path, int flags) { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0) || KSU_UMOUNT int err = path_umount(path, flags); if (err) { pr_info("umount %s failed: %d\n", path->dentry->d_iname, err);