summaryrefslogtreecommitdiffstats
path: root/security/selinux
diff options
context:
space:
mode:
authorStephen Smalley <sds@tycho.nsa.gov>2018-12-12 10:10:56 -0500
committerPaul Moore <paul@paul-moore.com>2019-01-10 20:34:37 -0500
commite46e01eebbbcf2ff6d28ee7cae9f117e9d1572c8 (patch)
tree21fb06603d0a98d0146053922e1a93ba5ded5817 /security/selinux
parent3a28cff3bd4bf43f02be0c4e7933aebf3dc8197e (diff)
selinux: stop passing MAY_NOT_BLOCK to the AVC upon follow_link
commit bda0be7ad9948 ("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>
Diffstat (limited to 'security/selinux')
-rw-r--r--security/selinux/avc.c24
-rw-r--r--security/selinux/hooks.c5
-rw-r--r--security/selinux/include/avc.h5
3 files changed, 4 insertions, 30 deletions
diff --git a/security/selinux/avc.c b/security/selinux/avc.c
index 5de18a6d5c3f..9b63d8ee1687 100644
--- a/security/selinux/avc.c
+++ b/security/selinux/avc.c
@@ -867,9 +867,8 @@ static int avc_update_node(struct selinux_avc *avc,
867 * permissive mode that only appear when in enforcing mode. 867 * permissive mode that only appear when in enforcing mode.
868 * 868 *
869 * See the corresponding handling in slow_avc_audit(), and the 869 * See the corresponding handling in slow_avc_audit(), and the
870 * logic in selinux_inode_follow_link and selinux_inode_permission 870 * logic in selinux_inode_permission for the MAY_NOT_BLOCK flag,
871 * for the VFS MAY_NOT_BLOCK flag, which is transliterated into 871 * which is transliterated into AVC_NONBLOCKING.
872 * AVC_NONBLOCKING for avc_has_perm_noaudit().
873 */ 872 */
874 if (flags & AVC_NONBLOCKING) 873 if (flags & AVC_NONBLOCKING)
875 return 0; 874 return 0;
@@ -1209,25 +1208,6 @@ int avc_has_perm(struct selinux_state *state, u32 ssid, u32 tsid, u16 tclass,
1209 return rc; 1208 return rc;
1210} 1209}
1211 1210
1212int 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
1231u32 avc_policy_seqno(struct selinux_state *state) 1211u32 avc_policy_seqno(struct selinux_state *state)
1232{ 1212{
1233 return state->avc->avc_cache.latest_notif; 1213 return state->avc->avc_cache.latest_notif;
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 7f6068489a02..f08a0f201967 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -2925,9 +2925,8 @@ static int selinux_inode_follow_link(struct dentry *dentry, struct inode *inode,
2925 if (IS_ERR(isec)) 2925 if (IS_ERR(isec))
2926 return PTR_ERR(isec); 2926 return PTR_ERR(isec);
2927 2927
2928 return avc_has_perm_flags(&selinux_state, 2928 return avc_has_perm(&selinux_state,
2929 sid, isec->sid, isec->sclass, FILE__READ, &ad, 2929 sid, isec->sid, isec->sclass, FILE__READ, &ad);
2930 rcu ? MAY_NOT_BLOCK : 0);
2931} 2930}
2932 2931
2933static noinline int audit_inode_permission(struct inode *inode, 2932static noinline int audit_inode_permission(struct inode *inode,
diff --git a/security/selinux/include/avc.h b/security/selinux/include/avc.h
index 74ea50977c20..7be0e1e90e8b 100644
--- a/security/selinux/include/avc.h
+++ b/security/selinux/include/avc.h
@@ -153,11 +153,6 @@ int avc_has_perm(struct selinux_state *state,
153 u32 ssid, u32 tsid, 153 u32 ssid, u32 tsid,
154 u16 tclass, u32 requested, 154 u16 tclass, u32 requested,
155 struct common_audit_data *auditdata); 155 struct common_audit_data *auditdata);
156int 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);
161 156
162int avc_has_extended_perms(struct selinux_state *state, 157int avc_has_extended_perms(struct selinux_state *state,
163 u32 ssid, u32 tsid, u16 tclass, u32 requested, 158 u32 ssid, u32 tsid, u16 tclass, u32 requested,