diff --git a/kernel/core_hook.c b/kernel/core_hook.c index 998ff5b29e4d..9c863660dd29 100644 --- a/kernel/core_hook.c +++ b/kernel/core_hook.c @@ -30,6 +30,8 @@ #include "uid_observer.h" #include "kernel_compat.h" +static bool ksu_module_mounted = false; + extern int handle_sepolicy(unsigned long arg3, void __user *arg4); static inline bool is_allow_su() @@ -331,6 +333,11 @@ int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3, } break; } + case EVENT_MODULE_MOUNTED: { + ksu_module_mounted = true; + pr_info("module mounted!\n"); + break; + } default: break; } @@ -522,6 +529,11 @@ static void try_umount(const char *mnt, bool check_mnt, int flags) int ksu_handle_setuid(struct cred *new, const struct cred *old) { + // this hook is used for umounting overlayfs for some uid, if there isn't any module mounted, just ignore it! + if (!ksu_module_mounted) { + return 0; + } + if (!new || !old) { return 0; } diff --git a/kernel/ksu.h b/kernel/ksu.h index cdffb5aece87..b98c0fd1bfb5 100644 --- a/kernel/ksu.h +++ b/kernel/ksu.h @@ -24,6 +24,7 @@ #define EVENT_POST_FS_DATA 1 #define EVENT_BOOT_COMPLETED 2 +#define EVENT_MODULE_MOUNTED 3 #define KSU_APP_PROFILE_VER 2 #define KSU_MAX_PACKAGE_NAME 256