Skip to content

Commit 06ef68c

Browse files
committed
Revert "Unmount isolated process which forks from zygote unconditionally (tiann/KernelSU#2747) (KernelSU-Next#776)"
This reverts commit cf3b0da196df6942d54d5f5321fb112299c5f50c. -10/7/25: carry-over mismerge fix from: 'Unmount isolated process which forks from zygote unconditionally'
1 parent 4352bd8 commit 06ef68c

File tree

1 file changed

+11
-21
lines changed

1 file changed

+11
-21
lines changed

kernel/core_hook.c

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ static inline bool is_allow_su()
154154
return ksu_is_allow_uid(current_uid().val);
155155
}
156156

157-
static inline bool is_unsupported_app_uid(uid_t uid)
157+
static inline bool is_unsupported_uid(uid_t uid)
158158
{
159159
#define LAST_APPLICATION_UID 19999
160160
uid_t appid = uid % 100000;
@@ -1019,13 +1019,14 @@ LSM_HANDLER_TYPE ksu_handle_prctl(int option, unsigned long arg2, unsigned long
10191019
return 0;
10201020
}
10211021

1022-
static bool is_non_appuid(kuid_t uid)
1022+
static bool is_appuid(kuid_t uid)
10231023
{
10241024
#define PER_USER_RANGE 100000
10251025
#define FIRST_APPLICATION_UID 10000
1026+
#define LAST_APPLICATION_UID 19999
10261027

10271028
uid_t appid = uid.val % PER_USER_RANGE;
1028-
return appid < FIRST_APPLICATION_UID;
1029+
return appid >= FIRST_APPLICATION_UID && appid <= LAST_APPLICATION_UID;
10291030
}
10301031

10311032
static bool should_umount(struct path *path)
@@ -1210,26 +1211,13 @@ int ksu_handle_setuid(struct cred *new, const struct cred *old)
12101211
return 0;
12111212
}
12121213

1213-
if (is_non_appuid(new_uid)) {
1214-
#ifdef CONFIG_KSU_DEBUG
1215-
pr_info("handle setuid ignore non application uid: %d\n", new_uid.val);
1216-
#endif
1214+
if (!is_appuid(new_uid) || is_unsupported_uid(new_uid.val)) {
1215+
// pr_info("handle setuid ignore non application or isolated uid: %d\n", new_uid.val);
12171216
return 0;
12181217
}
12191218

1220-
1221-
// isolated process may be directly forked from zygote, always unmount
1222-
if (is_unsupported_app_uid(new_uid.val)) {
1223-
#ifdef CONFIG_KSU_DEBUG
1224-
pr_info("handle umount for unsupported application uid: %d\n", new_uid.val);
1225-
#endif
1226-
goto do_umount;
1227-
}
1228-
12291219
if (ksu_is_allow_uid(new_uid.val)) {
1230-
#ifdef CONFIG_KSU_DEBUG
1231-
pr_info("handle setuid ignore allowed application: %d\n", new_uid.val);
1232-
#endif
1220+
// pr_info("handle setuid ignore allowed application: %d\n", new_uid.val);
12331221
return 0;
12341222
}
12351223

@@ -1241,11 +1229,13 @@ int ksu_handle_setuid(struct cred *new, const struct cred *old)
12411229
#endif
12421230
}
12431231

1244-
do_umount:
1232+
#ifndef CONFIG_KSU_SUSFS
12451233
// check old process's selinux context, if it is not zygote, ignore it!
12461234
// because some su apps may setuid to untrusted_app but they are in global mount namespace
12471235
// when we umount for such process, that is a disaster!
1248-
if (!is_zygote(old->security)) {
1236+
bool is_zygote_child = is_zygote(old->security);
1237+
#endif
1238+
if (!is_zygote_child) {
12491239
pr_info("handle umount ignore non zygote child: %d\n",
12501240
current->pid);
12511241
return 0;

0 commit comments

Comments
 (0)