Skip to content

Commit f08a5e6

Browse files
stephensmalleygregkh
authored andcommitted
selinux: revert "stop passing MAY_NOT_BLOCK to the AVC upon follow_link"
commit 1a37079 upstream. This reverts commit e46e01e ("selinux: stop passing MAY_NOT_BLOCK to the AVC upon follow_link"). The correct fix is to instead fall back to ref-walk if audit is required irrespective of the specific audit data type. This is done in the next commit. Fixes: e46e01e ("selinux: stop passing MAY_NOT_BLOCK to the AVC upon follow_link") Reported-by: Will Deacon <will@kernel.org> Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov> Signed-off-by: Paul Moore <paul@paul-moore.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8cec0fa commit f08a5e6

3 files changed

Lines changed: 30 additions & 4 deletions

File tree

‎security/selinux/avc.c‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -862,8 +862,9 @@ static int avc_update_node(struct selinux_avc *avc,
862862
* permissive mode that only appear when in enforcing mode.
863863
*
864864
* See the corresponding handling in slow_avc_audit(), and the
865-
* logic in selinux_inode_permission for the MAY_NOT_BLOCK flag,
866-
* which is transliterated into AVC_NONBLOCKING.
865+
* logic in selinux_inode_follow_link and selinux_inode_permission
866+
* for the VFS MAY_NOT_BLOCK flag, which is transliterated into
867+
* AVC_NONBLOCKING for avc_has_perm_noaudit().
867868
*/
868869
if (flags & AVC_NONBLOCKING)
869870
return 0;
@@ -1205,6 +1206,25 @@ int avc_has_perm(struct selinux_state *state, u32 ssid, u32 tsid, u16 tclass,
12051206
return rc;
12061207
}
12071208

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

‎security/selinux/hooks.c‎

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

3007-
return avc_has_perm(&selinux_state,
3008-
sid, isec->sid, isec->sclass, FILE__READ, &ad);
3007+
return avc_has_perm_flags(&selinux_state,
3008+
sid, isec->sid, isec->sclass, FILE__READ, &ad,
3009+
rcu ? MAY_NOT_BLOCK : 0);
30093010
}
30103011

30113012
static noinline int audit_inode_permission(struct inode *inode,

‎security/selinux/include/avc.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ 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);
156161

157162
int avc_has_extended_perms(struct selinux_state *state,
158163
u32 ssid, u32 tsid, u16 tclass, u32 requested,

0 commit comments

Comments
 (0)