@@ -64,7 +64,7 @@ static inline bool is_allow_su()
6464 return ksu_is_allow_uid (current_uid ().val );
6565}
6666
67- static inline bool is_unsupported_uid (uid_t uid )
67+ static inline bool is_unsupported_app_uid (uid_t uid )
6868{
6969#define LAST_APPLICATION_UID 19999
7070 uid_t appid = uid % 100000 ;
@@ -592,14 +592,13 @@ int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3,
592592 return 0 ;
593593}
594594
595- static bool is_appuid (kuid_t uid )
595+ static bool is_non_appuid (kuid_t uid )
596596{
597597#define PER_USER_RANGE 100000
598598#define FIRST_APPLICATION_UID 10000
599- #define LAST_APPLICATION_UID 19999
600599
601600 uid_t appid = uid .val % PER_USER_RANGE ;
602- return appid >= FIRST_APPLICATION_UID && appid <= LAST_APPLICATION_UID ;
601+ return appid < FIRST_APPLICATION_UID ;
603602}
604603
605604static bool should_umount (struct path * path )
@@ -676,13 +675,25 @@ int ksu_handle_setuid(struct cred *new, const struct cred *old)
676675 return 0 ;
677676 }
678677
679- if (!is_appuid (new_uid ) || is_unsupported_uid (new_uid .val )) {
680- // pr_info("handle setuid ignore non application or isolated uid: %d\n", new_uid.val);
678+ if (is_non_appuid (new_uid )) {
679+ #ifdef CONFIG_KSU_DEBUG
680+ pr_info ("handle setuid ignore non application or isolated uid: %d\n" , new_uid .val );
681+ #endif
681682 return 0 ;
682683 }
683684
685+ // isolated process may be directly forked from zygote, always unmount
686+ if (is_unsupported_app_uid (new_uid .val )) {
687+ #ifdef CONFIG_KSU_DEBUG
688+ pr_info ("handle umount for unsupported application uid: %d\n" , new_uid .val );
689+ #endif
690+ goto do_umount ;
691+ }
692+
684693 if (ksu_is_allow_uid (new_uid .val )) {
685- // pr_info("handle setuid ignore allowed application: %d\n", new_uid.val);
694+ #ifdef CONFIG_KSU_DEBUG
695+ pr_info ("handle setuid ignore allowed application: %d\n" , new_uid .val );
696+ #endif
686697 return 0 ;
687698 }
688699
@@ -694,11 +705,11 @@ int ksu_handle_setuid(struct cred *new, const struct cred *old)
694705#endif
695706 }
696707
708+ do_umount :
697709 // check old process's selinux context, if it is not zygote, ignore it!
698710 // because some su apps may setuid to untrusted_app but they are in global mount namespace
699711 // when we umount for such process, that is a disaster!
700- bool is_zygote_child = is_zygote (old -> security );
701- if (!is_zygote_child ) {
712+ if (!is_zygote (old -> security )) {
702713 pr_info ("handle umount ignore non zygote child: %d\n" ,
703714 current -> pid );
704715 return 0 ;
0 commit comments