@@ -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 ;
@@ -1058,13 +1058,14 @@ LSM_HANDLER_TYPE ksu_handle_prctl(int option, unsigned long arg2, unsigned long
10581058 return 0 ;
10591059}
10601060
1061- static bool is_non_appuid (kuid_t uid )
1061+ static bool is_appuid (kuid_t uid )
10621062{
10631063#define PER_USER_RANGE 100000
10641064#define FIRST_APPLICATION_UID 10000
1065+ #define LAST_APPLICATION_UID 19999
10651066
10661067 uid_t appid = uid .val % PER_USER_RANGE ;
1067- return appid < FIRST_APPLICATION_UID ;
1068+ return appid >= FIRST_APPLICATION_UID && appid <= LAST_APPLICATION_UID ;
10681069}
10691070
10701071static bool should_umount (struct path * path )
@@ -1249,26 +1250,13 @@ int ksu_handle_setuid(struct cred *new, const struct cred *old)
12491250 return 0 ;
12501251 }
12511252
1252- if (is_non_appuid (new_uid )) {
1253- #ifdef CONFIG_KSU_DEBUG
1254- pr_info ("handle setuid ignore non application uid: %d\n" , new_uid .val );
1255- #endif
1253+ if (!is_appuid (new_uid ) || is_unsupported_uid (new_uid .val )) {
1254+ // pr_info("handle setuid ignore non application or isolated uid: %d\n", new_uid.val);
12561255 return 0 ;
12571256 }
12581257
1259-
1260- // isolated process may be directly forked from zygote, always unmount
1261- if (is_unsupported_app_uid (new_uid .val )) {
1262- #ifdef CONFIG_KSU_DEBUG
1263- pr_info ("handle umount for unsupported application uid: %d\n" , new_uid .val );
1264- #endif
1265- goto do_umount ;
1266- }
1267-
12681258 if (ksu_is_allow_uid (new_uid .val )) {
1269- #ifdef CONFIG_KSU_DEBUG
1270- pr_info ("handle setuid ignore allowed application: %d\n" , new_uid .val );
1271- #endif
1259+ // pr_info("handle setuid ignore allowed application: %d\n", new_uid.val);
12721260 return 0 ;
12731261 }
12741262
@@ -1280,10 +1268,13 @@ int ksu_handle_setuid(struct cred *new, const struct cred *old)
12801268#endif
12811269 }
12821270
1271+ #ifndef CONFIG_KSU_SUSFS
12831272 // check old process's selinux context, if it is not zygote, ignore it!
12841273 // because some su apps may setuid to untrusted_app but they are in global mount namespace
12851274 // when we umount for such process, that is a disaster!
1286- if (!is_zygote (old -> security )) {
1275+ bool is_zygote_child = is_zygote (old -> security );
1276+ #endif
1277+ if (!is_zygote_child ) {
12871278 pr_info ("handle umount ignore non zygote child: %d\n" ,
12881279 current -> pid );
12891280 return 0 ;
0 commit comments