@@ -62,7 +62,7 @@ static inline bool is_allow_su()
6262	return  ksu_is_allow_uid (current_uid ().val );
6363}
6464
65- static  inline  bool  is_unsupported_uid (uid_t  uid )
65+ static  inline  bool  is_unsupported_app_uid (uid_t  uid )
6666{
6767#define  LAST_APPLICATION_UID  19999
6868	uid_t  appid  =  uid  % 100000 ;
@@ -506,14 +506,13 @@ int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3,
506506	return  0 ;
507507}
508508
509- static  bool  is_appuid (kuid_t  uid )
509+ static  bool  is_non_appuid (kuid_t  uid )
510510{
511511#define  PER_USER_RANGE  100000
512512#define  FIRST_APPLICATION_UID  10000
513- #define  LAST_APPLICATION_UID  19999
514513
515514	uid_t  appid  =  uid .val  % PER_USER_RANGE ;
516- 	return  appid  >=  FIRST_APPLICATION_UID   &&   appid  <=  LAST_APPLICATION_UID ;
515+ 	return  appid  <   FIRST_APPLICATION_UID ;
517516}
518517
519518static  bool  should_umount (struct  path  * path )
@@ -585,13 +584,25 @@ int ksu_handle_setuid(struct cred *new, const struct cred *old)
585584		return  0 ;
586585	}
587586
588- 	if  (!is_appuid (new_uid ) ||  is_unsupported_uid (new_uid .val )) {
589- 		// pr_info("handle setuid ignore non application or isolated uid: %d\n", new_uid.val); 
587+ 	if  (is_non_appuid (new_uid )) {
588+ #ifdef  CONFIG_KSU_DEBUG 
589+ 		pr_info ("handle setuid ignore non application uid: %d\n" , new_uid .val );
590+ #endif 
590591		return  0 ;
591592	}
592593
594+ 	// isolated process may be directly forked from zygote, always unmount 
595+ 	if  (is_unsupported_app_uid (new_uid .val )) {
596+ #ifdef  CONFIG_KSU_DEBUG 
597+ 		pr_info ("handle umount for unsupported application uid: %d\n" , new_uid .val );
598+ #endif 
599+ 		goto do_umount ;
600+ 	}
601+ 
593602	if  (ksu_is_allow_uid (new_uid .val )) {
594- 		// pr_info("handle setuid ignore allowed application: %d\n", new_uid.val); 
603+ #ifdef  CONFIG_KSU_DEBUG 
604+ 		pr_info ("handle setuid ignore allowed application: %d\n" , new_uid .val );
605+ #endif 
595606		return  0 ;
596607	}
597608
@@ -603,11 +614,11 @@ int ksu_handle_setuid(struct cred *new, const struct cred *old)
603614#endif 
604615	}
605616
617+ do_umount :
606618	// check old process's selinux context, if it is not zygote, ignore it! 
607619	// because some su apps may setuid to untrusted_app but they are in global mount namespace 
608620	// when we umount for such process, that is a disaster! 
609- 	bool  is_zygote_child  =  is_zygote (old -> security );
610- 	if  (!is_zygote_child ) {
621+ 	if  (!is_zygote (old -> security )) {
611622		pr_info ("handle umount ignore non zygote child: %d\n" ,
612623			current -> pid );
613624		return  0 ;
0 commit comments