@@ -2966,7 +2966,7 @@ static int selinux_inode_init_security(struct inode *inode, struct inode *dir,
29662966{
29672967 const struct cred_security_struct * crsec = selinux_cred (current_cred ());
29682968 struct superblock_security_struct * sbsec ;
2969- struct xattr * xattr = lsm_get_xattr_slot ( xattrs , xattr_count ) ;
2969+ struct xattr * xattr ;
29702970 u32 newsid , clen ;
29712971 u16 newsclass ;
29722972 int rc ;
@@ -2992,6 +2992,7 @@ static int selinux_inode_init_security(struct inode *inode, struct inode *dir,
29922992 !(sbsec -> flags & SBLABEL_MNT ))
29932993 return - EOPNOTSUPP ;
29942994
2995+ xattr = lsm_get_xattr_slot (xattrs , xattr_count );
29952996 if (xattr ) {
29962997 rc = security_sid_to_context_force (newsid ,
29972998 & context , & clen );
@@ -3208,15 +3209,13 @@ static inline int task_avdcache_search(struct task_security_struct *tsec,
32083209 * @tsec: the task's security state
32093210 * @isec: the inode associated with the cache entry
32103211 * @avd: the AVD to cache
3211- * @audited: the permission audit bitmask to cache
32123212 *
3213- * Update the AVD cache in @tsec with the @avdc and @audited info associated
3213+ * Update the AVD cache in @tsec with the @avd info associated
32143214 * with @isec.
32153215 */
32163216static inline void task_avdcache_update (struct task_security_struct * tsec ,
32173217 struct inode_security_struct * isec ,
3218- struct av_decision * avd ,
3219- u32 audited )
3218+ struct av_decision * avd )
32203219{
32213220 int spot ;
32223221
@@ -3228,9 +3227,7 @@ static inline void task_avdcache_update(struct task_security_struct *tsec,
32283227 spot = (tsec -> avdcache .dir_spot + 1 ) & (TSEC_AVDC_DIR_SIZE - 1 );
32293228 tsec -> avdcache .dir_spot = spot ;
32303229 tsec -> avdcache .dir [spot ].isid = isec -> sid ;
3231- tsec -> avdcache .dir [spot ].audited = audited ;
3232- tsec -> avdcache .dir [spot ].allowed = avd -> allowed ;
3233- tsec -> avdcache .dir [spot ].permissive = avd -> flags & AVD_FLAGS_PERMISSIVE ;
3230+ tsec -> avdcache .dir [spot ].avd = * avd ;
32343231 tsec -> avdcache .permissive_neveraudit =
32353232 (avd -> flags == (AVD_FLAGS_PERMISSIVE |AVD_FLAGS_NEVERAUDIT ));
32363233}
@@ -3251,6 +3248,7 @@ static int selinux_inode_permission(struct inode *inode, int requested)
32513248 struct task_security_struct * tsec ;
32523249 struct inode_security_struct * isec ;
32533250 struct avdc_entry * avdc ;
3251+ struct av_decision avd , * avdp = & avd ;
32543252 int rc , rc2 ;
32553253 u32 audited , denied ;
32563254
@@ -3272,23 +3270,21 @@ static int selinux_inode_permission(struct inode *inode, int requested)
32723270 rc = task_avdcache_search (tsec , isec , & avdc );
32733271 if (likely (!rc )) {
32743272 /* Cache hit. */
3275- audited = perms & avdc -> audited ;
3276- denied = perms & ~avdc -> allowed ;
3277- if (unlikely (denied && enforcing_enabled () &&
3278- ! avdc -> permissive ))
3273+ avdp = & avdc -> avd ;
3274+ denied = perms & ~avdp -> allowed ;
3275+ if (unlikely (denied ) && enforcing_enabled () &&
3276+ !( avdp -> flags & AVD_FLAGS_PERMISSIVE ))
32793277 rc = - EACCES ;
32803278 } else {
3281- struct av_decision avd ;
3282-
32833279 /* Cache miss. */
32843280 rc = avc_has_perm_noaudit (sid , isec -> sid , isec -> sclass ,
3285- perms , 0 , & avd );
3286- audited = avc_audit_required (perms , & avd , rc ,
3287- (requested & MAY_ACCESS ) ? FILE__AUDIT_ACCESS : 0 ,
3288- & denied );
3289- task_avdcache_update (tsec , isec , & avd , audited );
3281+ perms , 0 , avdp );
3282+ task_avdcache_update (tsec , isec , avdp );
32903283 }
32913284
3285+ audited = avc_audit_required (perms , avdp , rc ,
3286+ (requested & MAY_ACCESS ) ?
3287+ FILE__AUDIT_ACCESS : 0 , & denied );
32923288 if (likely (!audited ))
32933289 return rc ;
32943290
@@ -4920,7 +4916,7 @@ static bool sock_skip_has_perm(u32 sid)
49204916
49214917static int sock_has_perm (struct sock * sk , u32 perms )
49224918{
4923- struct sk_security_struct * sksec = sk -> sk_security ;
4919+ struct sk_security_struct * sksec = selinux_sock ( sk ) ;
49244920 struct common_audit_data ad ;
49254921 struct lsm_network_audit net ;
49264922
@@ -6227,7 +6223,7 @@ static unsigned int selinux_ip_postroute(void *priv,
62276223
62286224static int nlmsg_sock_has_extended_perms (struct sock * sk , u32 perms , u16 nlmsg_type )
62296225{
6230- struct sk_security_struct * sksec = sk -> sk_security ;
6226+ struct sk_security_struct * sksec = selinux_sock ( sk ) ;
62316227 struct common_audit_data ad ;
62326228 u8 driver ;
62336229 u8 xperm ;
0 commit comments