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

Change-Id: I5d556137be1f6b5894dd261b7d01f89d3e724ffe
This commit is contained in:
weishu 2024-01-12 20:01:46 +02:00 committed by Lup Gabriel
parent 1361f9c9bd
commit 60d14e00c4
2 changed files with 13 additions and 0 deletions

View File

@ -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;
}

View File

@ -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