kernel: avoding umount when there isn't any module. close #556

This commit is contained in:
weishu
2024-01-08 12:55:08 +08:00
parent 757e69b15e
commit e9997a07c1
2 changed files with 13 additions and 0 deletions

View File

@@ -30,6 +30,8 @@
#include "uid_observer.h" #include "uid_observer.h"
#include "kernel_compat.h" #include "kernel_compat.h"
static bool ksu_module_mounted = false;
extern int handle_sepolicy(unsigned long arg3, void __user *arg4); extern int handle_sepolicy(unsigned long arg3, void __user *arg4);
static inline bool is_allow_su() static inline bool is_allow_su()
@@ -331,6 +333,11 @@ int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3,
} }
break; break;
} }
case EVENT_MODULE_MOUNTED: {
ksu_module_mounted = true;
pr_info("module mounted!\n");
break;
}
default: default:
break; 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) 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) { if (!new || !old) {
return 0; return 0;
} }

View File

@@ -24,6 +24,7 @@
#define EVENT_POST_FS_DATA 1 #define EVENT_POST_FS_DATA 1
#define EVENT_BOOT_COMPLETED 2 #define EVENT_BOOT_COMPLETED 2
#define EVENT_MODULE_MOUNTED 3
#define KSU_APP_PROFILE_VER 2 #define KSU_APP_PROFILE_VER 2
#define KSU_MAX_PACKAGE_NAME 256 #define KSU_MAX_PACKAGE_NAME 256