Skip to content

Commit

Permalink
kernel: avoding umount when there isn't any module. close #556
Browse files Browse the repository at this point in the history
  • Loading branch information
tiann committed Jan 8, 2024
1 parent 757e69b commit e9997a0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions kernel/core_hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions kernel/ksu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e9997a0

Please sign in to comment.