@@ -62,13 +62,11 @@ LSM_HANDLER_TYPE ksu_handle_setuid(struct cred *new, const struct cred *old)
6262 disable_seccomp ();
6363 pr_info ("install fd for: %d\n" , new_uid );
6464 ksu_install_fd ();
65- set_thread_flag (TIF_KSU_MANAGED );
6665 return 0 ;
6766 }
6867
6968 if (unlikely (ksu_is_allow_uid_for_current (new_uid ))) {
7069 disable_seccomp ();
71- set_thread_flag (TIF_KSU_MANAGED );
7270 return 0 ;
7371 }
7472
@@ -105,6 +103,19 @@ LSM_HANDLER_TYPE ksu_file_permission(struct file *file, int mask)
105103 return 0 ;
106104}
107105
106+ LSM_HANDLER_TYPE ksu_task_alloc (struct task_struct * p , unsigned long clone_flags )
107+ {
108+ struct mount_entry * entry ;
109+ kuid_t child_uid = p -> cred -> uid ; // new uid beuing prepped
110+
111+ if (unlikely (ksu_is_allow_uid_for_current (child_uid .val ))) {
112+ pr_info ("task_alloc: uid: %d pid: %d\n" , child_uid .val , p -> pid );
113+ set_ti_thread_flag (task_thread_info (p ), TIF_KSU_MANAGED );
114+ }
115+
116+ return 0 ;
117+ }
118+
108119#ifdef CONFIG_KSU_LSM_SECURITY_HOOKS
109120static int ksu_inode_rename (struct inode * old_inode , struct dentry * old_dentry ,
110121 struct inode * new_inode , struct dentry * new_dentry )
@@ -123,6 +134,8 @@ static struct security_hook_list ksu_hooks[] = {
123134 LSM_HOOK_INIT (inode_rename , ksu_inode_rename ),
124135 LSM_HOOK_INIT (task_fix_setuid , ksu_task_fix_setuid ),
125136 LSM_HOOK_INIT (bprm_check_security , ksu_bprm_check ),
137+ LSM_HOOK_INIT (task_alloc , ksu_task_alloc ),
138+
126139#if !defined (CONFIG_KSU_TAMPER_SYSCALL_TABLE ) && !defined (CONFIG_KSU_KPROBES_KSUD )
127140 LSM_HOOK_INIT (file_permission , ksu_file_permission ),
128141#endif
0 commit comments