Skip to content

Commit

Permalink
security/selinux: pass 'flags' arg to avc_audit() and avc_has_perm_fl…
Browse files Browse the repository at this point in the history
…ags()

This allows MAY_NOT_BLOCK to be passed, in RCU-walk mode, through
the new avc_has_perm_flags() to avc_audit() and thence the slow_avc_audit.

Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
neilbrown authored and Al Viro committed May 11, 2015
1 parent 181548c commit 7b20ea2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
18 changes: 17 additions & 1 deletion security/selinux/avc.c
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,23 @@ int avc_has_perm(u32 ssid, u32 tsid, u16 tclass,

rc = avc_has_perm_noaudit(ssid, tsid, tclass, requested, 0, &avd);

rc2 = avc_audit(ssid, tsid, tclass, requested, &avd, rc, auditdata);
rc2 = avc_audit(ssid, tsid, tclass, requested, &avd, rc, auditdata, 0);
if (rc2)
return rc2;
return rc;
}

int avc_has_perm_flags(u32 ssid, u32 tsid, u16 tclass,
u32 requested, struct common_audit_data *auditdata,
int flags)
{
struct av_decision avd;
int rc, rc2;

rc = avc_has_perm_noaudit(ssid, tsid, tclass, requested, 0, &avd);

rc2 = avc_audit(ssid, tsid, tclass, requested, &avd, rc,
auditdata, flags);
if (rc2)
return rc2;
return rc;
Expand Down
2 changes: 1 addition & 1 deletion security/selinux/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -1564,7 +1564,7 @@ static int cred_has_capability(const struct cred *cred,

rc = avc_has_perm_noaudit(sid, sid, sclass, av, 0, &avd);
if (audit == SECURITY_CAP_AUDIT) {
int rc2 = avc_audit(sid, sid, sclass, av, &avd, rc, &ad);
int rc2 = avc_audit(sid, sid, sclass, av, &avd, rc, &ad, 0);
if (rc2)
return rc2;
}
Expand Down
9 changes: 7 additions & 2 deletions security/selinux/include/avc.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,16 @@ static inline int avc_audit(u32 ssid, u32 tsid,
u16 tclass, u32 requested,
struct av_decision *avd,
int result,
struct common_audit_data *a)
struct common_audit_data *a,
int flags)
{
u32 audited, denied;
audited = avc_audit_required(requested, avd, result, 0, &denied);
if (likely(!audited))
return 0;
return slow_avc_audit(ssid, tsid, tclass,
requested, audited, denied, result,
a, 0);
a, flags);
}

#define AVC_STRICT 1 /* Ignore permissive mode. */
Expand All @@ -150,6 +151,10 @@ int avc_has_perm_noaudit(u32 ssid, u32 tsid,
int avc_has_perm(u32 ssid, u32 tsid,
u16 tclass, u32 requested,
struct common_audit_data *auditdata);
int avc_has_perm_flags(u32 ssid, u32 tsid,
u16 tclass, u32 requested,
struct common_audit_data *auditdata,
int flags);

u32 avc_policy_seqno(void);

Expand Down

0 comments on commit 7b20ea2

Please sign in to comment.