@@ -2220,8 +2220,8 @@ pfm_alloc_file(pfm_context_t *ctx)
22202220 DPRINT (("new inode ino=%ld @%p\n" , inode -> i_ino , inode ));
22212221
22222222 inode -> i_mode = S_IFCHR |S_IRUGO ;
2223- inode -> i_uid = current -> fsuid ;
2224- inode -> i_gid = current -> fsgid ;
2223+ inode -> i_uid = current_fsuid () ;
2224+ inode -> i_gid = current_fsgid () ;
22252225
22262226 sprintf (name , "[%lu]" , inode -> i_ino );
22272227 this .name = name ;
@@ -2399,22 +2399,33 @@ pfm_smpl_buffer_alloc(struct task_struct *task, struct file *filp, pfm_context_t
23992399static int
24002400pfm_bad_permissions (struct task_struct * task )
24012401{
2402+ const struct cred * tcred ;
2403+ uid_t uid = current_uid ();
2404+ gid_t gid = current_gid ();
2405+ int ret ;
2406+
2407+ rcu_read_lock ();
2408+ tcred = __task_cred (task );
2409+
24022410 /* inspired by ptrace_attach() */
24032411 DPRINT (("cur: uid=%d gid=%d task: euid=%d suid=%d uid=%d egid=%d sgid=%d\n" ,
2404- current -> uid ,
2405- current -> gid ,
2406- task -> euid ,
2407- task -> suid ,
2408- task -> uid ,
2409- task -> egid ,
2410- task -> sgid ));
2411-
2412- return ((current -> uid != task -> euid )
2413- || (current -> uid != task -> suid )
2414- || (current -> uid != task -> uid )
2415- || (current -> gid != task -> egid )
2416- || (current -> gid != task -> sgid )
2417- || (current -> gid != task -> gid )) && !capable (CAP_SYS_PTRACE );
2412+ uid ,
2413+ gid ,
2414+ tcred -> euid ,
2415+ tcred -> suid ,
2416+ tcred -> uid ,
2417+ tcred -> egid ,
2418+ tcred -> sgid ));
2419+
2420+ ret = ((uid != tcred -> euid )
2421+ || (uid != tcred -> suid )
2422+ || (uid != tcred -> uid )
2423+ || (gid != tcred -> egid )
2424+ || (gid != tcred -> sgid )
2425+ || (gid != tcred -> gid )) && !capable (CAP_SYS_PTRACE );
2426+
2427+ rcu_read_unlock ();
2428+ return ret ;
24182429}
24192430
24202431static int
0 commit comments