@@ -2961,7 +2961,7 @@ static int selinux_inode_init_security_anon(struct inode *inode,
2961
2961
const struct qstr * name ,
2962
2962
const struct inode * context_inode )
2963
2963
{
2964
- const struct task_security_struct * tsec = selinux_cred ( current_cred () );
2964
+ u32 sid = current_sid ( );
2965
2965
struct common_audit_data ad ;
2966
2966
struct inode_security_struct * isec ;
2967
2967
int rc ;
@@ -2990,7 +2990,7 @@ static int selinux_inode_init_security_anon(struct inode *inode,
2990
2990
} else {
2991
2991
isec -> sclass = SECCLASS_ANON_INODE ;
2992
2992
rc = security_transition_sid (
2993
- tsec -> sid , tsec -> sid ,
2993
+ sid , sid ,
2994
2994
isec -> sclass , name , & isec -> sid );
2995
2995
if (rc )
2996
2996
return rc ;
@@ -3005,7 +3005,7 @@ static int selinux_inode_init_security_anon(struct inode *inode,
3005
3005
ad .type = LSM_AUDIT_DATA_ANONINODE ;
3006
3006
ad .u .anonclass = name ? (const char * )name -> name : "?" ;
3007
3007
3008
- return avc_has_perm (tsec -> sid ,
3008
+ return avc_has_perm (sid ,
3009
3009
isec -> sid ,
3010
3010
isec -> sclass ,
3011
3011
FILE__CREATE ,
@@ -3063,14 +3063,12 @@ static int selinux_inode_readlink(struct dentry *dentry)
3063
3063
static int selinux_inode_follow_link (struct dentry * dentry , struct inode * inode ,
3064
3064
bool rcu )
3065
3065
{
3066
- const struct cred * cred = current_cred ();
3067
3066
struct common_audit_data ad ;
3068
3067
struct inode_security_struct * isec ;
3069
- u32 sid ;
3068
+ u32 sid = current_sid () ;
3070
3069
3071
3070
ad .type = LSM_AUDIT_DATA_DENTRY ;
3072
3071
ad .u .dentry = dentry ;
3073
- sid = cred_sid (cred );
3074
3072
isec = inode_security_rcu (inode , rcu );
3075
3073
if (IS_ERR (isec ))
3076
3074
return PTR_ERR (isec );
@@ -3094,12 +3092,11 @@ static noinline int audit_inode_permission(struct inode *inode,
3094
3092
3095
3093
static int selinux_inode_permission (struct inode * inode , int mask )
3096
3094
{
3097
- const struct cred * cred = current_cred ();
3098
3095
u32 perms ;
3099
3096
bool from_access ;
3100
3097
bool no_block = mask & MAY_NOT_BLOCK ;
3101
3098
struct inode_security_struct * isec ;
3102
- u32 sid ;
3099
+ u32 sid = current_sid () ;
3103
3100
struct av_decision avd ;
3104
3101
int rc , rc2 ;
3105
3102
u32 audited , denied ;
@@ -3116,7 +3113,6 @@ static int selinux_inode_permission(struct inode *inode, int mask)
3116
3113
3117
3114
perms = file_mask_to_av (inode -> i_mode , mask );
3118
3115
3119
- sid = cred_sid (cred );
3120
3116
isec = inode_security_rcu (inode , no_block );
3121
3117
if (IS_ERR (isec ))
3122
3118
return PTR_ERR (isec );
@@ -5564,13 +5560,7 @@ static void selinux_inet_conn_established(struct sock *sk, struct sk_buff *skb)
5564
5560
5565
5561
static int selinux_secmark_relabel_packet (u32 sid )
5566
5562
{
5567
- const struct task_security_struct * tsec ;
5568
- u32 tsid ;
5569
-
5570
- tsec = selinux_cred (current_cred ());
5571
- tsid = tsec -> sid ;
5572
-
5573
- return avc_has_perm (tsid , sid , SECCLASS_PACKET , PACKET__RELABELTO ,
5563
+ return avc_has_perm (current_sid (), sid , SECCLASS_PACKET , PACKET__RELABELTO ,
5574
5564
NULL );
5575
5565
}
5576
5566
0 commit comments