@@ -98,11 +98,7 @@ static void setup_groups(struct root_profile *profile, struct cred *cred)
9898 put_group_info (group_info );
9999 return ;
100100 }
101- #if LINUX_VERSION_CODE >= KERNEL_VERSION (4 , 9 , 0 )
102101 group_info -> gid [i ] = kgid ;
103- #else
104- GROUP_AT (group_info , i ) = kgid ;
105- #endif
106102 }
107103
108104 groups_sort (group_info );
@@ -449,14 +445,12 @@ static bool should_umount(struct path *path)
449445 return false;
450446}
451447
452- static int ksu_umount_mnt (struct path * path , int flags )
448+ static void ksu_umount_mnt (struct path * path , int flags )
453449{
454- #if LINUX_VERSION_CODE >= KERNEL_VERSION (5 , 9 , 0 ) || defined(KSU_UMOUNT )
455- return path_umount (path , flags );
456- #else
457- // TODO: umount for non GKI kernel
458- return - ENOSYS ;
459- #endif
450+ int err = path_umount (path , flags );
451+ if (err ) {
452+ pr_info ("umount %s failed: %d\n" , path -> dentry -> d_iname , err );
453+ }
460454}
461455
462456static void try_umount (const char * mnt , bool check_mnt , int flags )
@@ -477,10 +471,7 @@ static void try_umount(const char *mnt, bool check_mnt, int flags)
477471 return ;
478472 }
479473
480- err = ksu_umount_mnt (& path , flags );
481- if (err ) {
482- pr_warn ("umount %s failed: %d\n" , mnt , err );
483- }
474+ ksu_umount_mnt (& path , flags );
484475}
485476
486477int ksu_handle_setuid (struct cred * new , const struct cred * old )
@@ -557,14 +548,8 @@ static int handler_pre(struct kprobe *p, struct pt_regs *regs)
557548 int option = (int )PT_REGS_PARM1 (real_regs );
558549 unsigned long arg2 = (unsigned long )PT_REGS_PARM2 (real_regs );
559550 unsigned long arg3 = (unsigned long )PT_REGS_PARM3 (real_regs );
560- #if LINUX_VERSION_CODE >= KERNEL_VERSION (4 , 16 , 0 )
561551 // PRCTL_SYMBOL is the arch-specificed one, which receive raw pt_regs from syscall
562552 unsigned long arg4 = (unsigned long )PT_REGS_SYSCALL_PARM4 (real_regs );
563- #else
564- // PRCTL_SYMBOL is the common one, called by C convention in do_syscall_64
565- // https://elixir.bootlin.com/linux/v4.15.18/source/arch/x86/entry/common.c#L287
566- unsigned long arg4 = (unsigned long )PT_REGS_CCALL_PARM4 (real_regs );
567- #endif
568553 unsigned long arg5 = (unsigned long )PT_REGS_PARM5 (real_regs );
569554
570555 return ksu_handle_prctl (option , arg2 , arg3 , arg4 , arg5 );
@@ -624,23 +609,7 @@ static int ksu_task_prctl(int option, unsigned long arg2, unsigned long arg3,
624609 ksu_handle_prctl (option , arg2 , arg3 , arg4 , arg5 );
625610 return - ENOSYS ;
626611}
627- // kernel 4.4 and 4.9
628- #if LINUX_VERSION_CODE < KERNEL_VERSION (4 , 10 , 0 ) || defined(CONFIG_IS_HW_HISI )
629- static int ksu_key_permission (key_ref_t key_ref , const struct cred * cred ,
630- unsigned perm )
631- {
632- if (init_session_keyring != NULL ) {
633- return 0 ;
634- }
635- if (strcmp (current -> comm , "init" )) {
636- // we are only interested in `init` process
637- return 0 ;
638- }
639- init_session_keyring = cred -> session_keyring ;
640- pr_info ("kernel_compat: got init_session_keyring\n" );
641- return 0 ;
642- }
643- #endif
612+
644613static int ksu_inode_rename (struct inode * old_inode , struct dentry * old_dentry ,
645614 struct inode * new_inode , struct dentry * new_dentry )
646615{
@@ -658,19 +627,11 @@ static struct security_hook_list ksu_hooks[] = {
658627 LSM_HOOK_INIT (task_prctl , ksu_task_prctl ),
659628 LSM_HOOK_INIT (inode_rename , ksu_inode_rename ),
660629 LSM_HOOK_INIT (task_fix_setuid , ksu_task_fix_setuid ),
661- #if LINUX_VERSION_CODE < KERNEL_VERSION (4 , 10 , 0 ) || defined (CONFIG_IS_HW_HISI )
662- LSM_HOOK_INIT (key_permission , ksu_key_permission )
663- #endif
664630};
665631
666632void __init ksu_lsm_hook_init (void )
667633{
668- #if LINUX_VERSION_CODE >= KERNEL_VERSION (4 , 11 , 0 )
669634 security_add_hooks (ksu_hooks , ARRAY_SIZE (ksu_hooks ), "ksu" );
670- #else
671- // https://elixir.bootlin.com/linux/v4.10.17/source/include/linux/lsm_hooks.h#L1892
672- security_add_hooks (ksu_hooks , ARRAY_SIZE (ksu_hooks ));
673- #endif
674635}
675636
676637#else
0 commit comments