Skip to content

Commit e46e01e

Browse files
stephensmalleypcmoore
authored andcommitted
selinux: stop passing MAY_NOT_BLOCK to the AVC upon follow_link
commit bda0be7 ("security: make inode_follow_link RCU-walk aware") switched selinux_inode_follow_link() to use avc_has_perm_flags() and pass down the MAY_NOT_BLOCK flag if called during RCU walk. However, the only test of MAY_NOT_BLOCK occurs during slow_avc_audit() and only if passing an inode as audit data (LSM_AUDIT_DATA_INODE). Since selinux_inode_follow_link() passes a dentry directly, passing MAY_NOT_BLOCK here serves no purpose. Switch selinux_inode_follow_link() to use avc_has_perm() and drop avc_has_perm_flags() since there are no other users. Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov> Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent 3a28cff commit e46e01e

3 files changed

Lines changed: 4 additions & 30 deletions

File tree

‎security/selinux/avc.c‎

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -867,9 +867,8 @@ static int avc_update_node(struct selinux_avc *avc,
867867
* permissive mode that only appear when in enforcing mode.
868868
*
869869
* See the corresponding handling in slow_avc_audit(), and the
870-
* logic in selinux_inode_follow_link and selinux_inode_permission
871-
* for the VFS MAY_NOT_BLOCK flag, which is transliterated into
872-
* AVC_NONBLOCKING for avc_has_perm_noaudit().
870+
* logic in selinux_inode_permission for the MAY_NOT_BLOCK flag,
871+
* which is transliterated into AVC_NONBLOCKING.
873872
*/
874873
if (flags & AVC_NONBLOCKING)
875874
return 0;
@@ -1209,25 +1208,6 @@ int avc_has_perm(struct selinux_state *state, u32 ssid, u32 tsid, u16 tclass,
12091208
return rc;
12101209
}
12111210

1212-
int avc_has_perm_flags(struct selinux_state *state,
1213-
u32 ssid, u32 tsid, u16 tclass, u32 requested,
1214-
struct common_audit_data *auditdata,
1215-
int flags)
1216-
{
1217-
struct av_decision avd;
1218-
int rc, rc2;
1219-
1220-
rc = avc_has_perm_noaudit(state, ssid, tsid, tclass, requested,
1221-
(flags & MAY_NOT_BLOCK) ? AVC_NONBLOCKING : 0,
1222-
&avd);
1223-
1224-
rc2 = avc_audit(state, ssid, tsid, tclass, requested, &avd, rc,
1225-
auditdata, flags);
1226-
if (rc2)
1227-
return rc2;
1228-
return rc;
1229-
}
1230-
12311211
u32 avc_policy_seqno(struct selinux_state *state)
12321212
{
12331213
return state->avc->avc_cache.latest_notif;

‎security/selinux/hooks.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2925,9 +2925,8 @@ static int selinux_inode_follow_link(struct dentry *dentry, struct inode *inode,
29252925
if (IS_ERR(isec))
29262926
return PTR_ERR(isec);
29272927

2928-
return avc_has_perm_flags(&selinux_state,
2929-
sid, isec->sid, isec->sclass, FILE__READ, &ad,
2930-
rcu ? MAY_NOT_BLOCK : 0);
2928+
return avc_has_perm(&selinux_state,
2929+
sid, isec->sid, isec->sclass, FILE__READ, &ad);
29312930
}
29322931

29332932
static noinline int audit_inode_permission(struct inode *inode,

‎security/selinux/include/avc.h‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,6 @@ int avc_has_perm(struct selinux_state *state,
153153
u32 ssid, u32 tsid,
154154
u16 tclass, u32 requested,
155155
struct common_audit_data *auditdata);
156-
int avc_has_perm_flags(struct selinux_state *state,
157-
u32 ssid, u32 tsid,
158-
u16 tclass, u32 requested,
159-
struct common_audit_data *auditdata,
160-
int flags);
161156

162157
int avc_has_extended_perms(struct selinux_state *state,
163158
u32 ssid, u32 tsid, u16 tclass, u32 requested,

0 commit comments

Comments
 (0)