kernel & KernelSU: Synced with upstream; Original add_try_umount will be used if susfs TRY_UMOUNT is disabled during compile time
Co-authored-by: simonpunk <simonpunk2016@gmail.com>
This commit is contained in:
@@ -96,11 +96,11 @@ static int ksu_sys_umount(const char *mnt, int flags)
|
|||||||
})
|
})
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_KSU_SUSFS_TRY_UMOUNT
|
#ifndef CONFIG_KSU_SUSFS_TRY_UMOUNT
|
||||||
void try_umount(const char *mnt, int flags)
|
|
||||||
#else
|
|
||||||
static void try_umount(const char *mnt, int flags)
|
static void try_umount(const char *mnt, int flags)
|
||||||
#endif // #ifdef CONFIG_KSU_SUSFS_TRY_UMOUNT
|
#else
|
||||||
|
void try_umount(const char *mnt, int flags)
|
||||||
|
#endif // #ifndef CONFIG_KSU_SUSFS_TRY_UMOUNT
|
||||||
{
|
{
|
||||||
struct path path;
|
struct path path;
|
||||||
int ret;
|
int ret;
|
||||||
@@ -132,17 +132,10 @@ static void try_umount(const char *mnt, int flags)
|
|||||||
#ifdef CONFIG_KSU_SUSFS_TRY_UMOUNT
|
#ifdef CONFIG_KSU_SUSFS_TRY_UMOUNT
|
||||||
void susfs_try_umount_all(void) {
|
void susfs_try_umount_all(void) {
|
||||||
susfs_try_umount();
|
susfs_try_umount();
|
||||||
try_umount("/odm", true, 0);
|
|
||||||
try_umount("/system", true, 0);
|
|
||||||
try_umount("/vendor", true, 0);
|
|
||||||
try_umount("/product", true, 0);
|
|
||||||
try_umount("/system_ext", true, 0);
|
|
||||||
try_umount("/data/adb/modules", false, MNT_DETACH);
|
|
||||||
try_umount("/debug_ramdisk", true, MNT_DETACH);
|
|
||||||
}
|
}
|
||||||
#endif // #ifdef CONFIG_KSU_SUSFS_TRY_UMOUNT
|
#endif // #ifdef CONFIG_KSU_SUSFS_TRY_UMOUNT
|
||||||
|
|
||||||
#ifndef CONFIG_KSU_SUSFS
|
#if !defined(CONFIG_KSU_SUSFS) || !defined(CONFIG_KSU_SUSFS_TRY_UMOUNT)
|
||||||
struct umount_tw {
|
struct umount_tw {
|
||||||
struct callback_head cb;
|
struct callback_head cb;
|
||||||
const struct cred *old_cred;
|
const struct cred *old_cred;
|
||||||
@@ -177,6 +170,7 @@ int ksu_handle_umount(uid_t old_uid, uid_t new_uid)
|
|||||||
{
|
{
|
||||||
struct umount_tw *tw;
|
struct umount_tw *tw;
|
||||||
|
|
||||||
|
#if defined(CONFIG_KSU_SUSFS) || !defined(CONFIG_KSU_SUSFS_TRY_UMOUNT)
|
||||||
// this hook is used for umounting overlayfs for some uid, if there isn't any module mounted, just ignore it!
|
// this hook is used for umounting overlayfs for some uid, if there isn't any module mounted, just ignore it!
|
||||||
if (!ksu_module_mounted) {
|
if (!ksu_module_mounted) {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -206,6 +200,7 @@ int ksu_handle_umount(uid_t old_uid, uid_t new_uid)
|
|||||||
#if __SULOG_GATE
|
#if __SULOG_GATE
|
||||||
ksu_sulog_report_syscall(new_uid, NULL, "setuid", NULL);
|
ksu_sulog_report_syscall(new_uid, NULL, "setuid", NULL);
|
||||||
#endif
|
#endif
|
||||||
|
#endif // #if defined(CONFIG_KSU_SUSFS) || !defined(CONFIG_KSU_SUSFS_TRY_UMOUNT)
|
||||||
// umount the target mnt
|
// umount the target mnt
|
||||||
pr_info("handle umount for uid: %d, pid: %d\n", new_uid, current->pid);
|
pr_info("handle umount for uid: %d, pid: %d\n", new_uid, current->pid);
|
||||||
|
|
||||||
@@ -227,7 +222,7 @@ int ksu_handle_umount(uid_t old_uid, uid_t new_uid)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif // #ifndef CONFIG_KSU_SUSFS
|
#endif // #if !defined(CONFIG_KSU_SUSFS) || !defined(CONFIG_KSU_SUSFS_TRY_UMOUNT)
|
||||||
|
|
||||||
void ksu_kernel_umount_init(void)
|
void ksu_kernel_umount_init(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,10 +8,10 @@
|
|||||||
void ksu_kernel_umount_init(void);
|
void ksu_kernel_umount_init(void);
|
||||||
void ksu_kernel_umount_exit(void);
|
void ksu_kernel_umount_exit(void);
|
||||||
|
|
||||||
#ifndef CONFIG_KSU_SUSFS
|
#if !defined(CONFIG_KSU_SUSFS) || !defined(CONFIG_KSU_SUSFS_TRY_UMOUNT)
|
||||||
// Handler function to be called from setresuid hook
|
// Handler function to be called from setresuid hook
|
||||||
int ksu_handle_umount(uid_t old_uid, uid_t new_uid);
|
int ksu_handle_umount(uid_t old_uid, uid_t new_uid);
|
||||||
#endif // #ifndef CONFIG_KSU_SUSFS
|
#endif // #if !defined(CONFIG_KSU_SUSFS) || !defined(CONFIG_KSU_SUSFS_TRY_UMOUNT)
|
||||||
|
|
||||||
// for the umount list
|
// for the umount list
|
||||||
struct mount_entry {
|
struct mount_entry {
|
||||||
|
|||||||
@@ -318,6 +318,9 @@ do_umount:
|
|||||||
#ifdef CONFIG_KSU_SUSFS_TRY_UMOUNT
|
#ifdef CONFIG_KSU_SUSFS_TRY_UMOUNT
|
||||||
pr_info("susfs: running susfs_try_umount_all() for uid: %u\n", new_uid);
|
pr_info("susfs: running susfs_try_umount_all() for uid: %u\n", new_uid);
|
||||||
susfs_try_umount_all();
|
susfs_try_umount_all();
|
||||||
|
#else
|
||||||
|
// Handle kernel umount
|
||||||
|
ksu_handle_umount(old_uid, new_uid);
|
||||||
#endif // #ifdef CONFIG_KSU_SUSFS_TRY_UMOUNT
|
#endif // #ifdef CONFIG_KSU_SUSFS_TRY_UMOUNT
|
||||||
|
|
||||||
skip_try_umount:
|
skip_try_umount:
|
||||||
|
|||||||
Reference in New Issue
Block a user