Skip to content

Commit 7b20ea2

Browse files
neilbrownAl Viro
authored andcommitted
security/selinux: pass 'flags' arg to avc_audit() and avc_has_perm_flags()
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>
1 parent 181548c commit 7b20ea2

3 files changed

Lines changed: 25 additions & 4 deletions

File tree

‎security/selinux/avc.c‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,23 @@ int avc_has_perm(u32 ssid, u32 tsid, u16 tclass,
761761

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

764-
rc2 = avc_audit(ssid, tsid, tclass, requested, &avd, rc, auditdata);
764+
rc2 = avc_audit(ssid, tsid, tclass, requested, &avd, rc, auditdata, 0);
765+
if (rc2)
766+
return rc2;
767+
return rc;
768+
}
769+
770+
int avc_has_perm_flags(u32 ssid, u32 tsid, u16 tclass,
771+
u32 requested, struct common_audit_data *auditdata,
772+
int flags)
773+
{
774+
struct av_decision avd;
775+
int rc, rc2;
776+
777+
rc = avc_has_perm_noaudit(ssid, tsid, tclass, requested, 0, &avd);
778+
779+
rc2 = avc_audit(ssid, tsid, tclass, requested, &avd, rc,
780+
auditdata, flags);
765781
if (rc2)
766782
return rc2;
767783
return rc;

‎security/selinux/hooks.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1564,7 +1564,7 @@ static int cred_has_capability(const struct cred *cred,
15641564

15651565
rc = avc_has_perm_noaudit(sid, sid, sclass, av, 0, &avd);
15661566
if (audit == SECURITY_CAP_AUDIT) {
1567-
int rc2 = avc_audit(sid, sid, sclass, av, &avd, rc, &ad);
1567+
int rc2 = avc_audit(sid, sid, sclass, av, &avd, rc, &ad, 0);
15681568
if (rc2)
15691569
return rc2;
15701570
}

‎security/selinux/include/avc.h‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,16 @@ static inline int avc_audit(u32 ssid, u32 tsid,
130130
u16 tclass, u32 requested,
131131
struct av_decision *avd,
132132
int result,
133-
struct common_audit_data *a)
133+
struct common_audit_data *a,
134+
int flags)
134135
{
135136
u32 audited, denied;
136137
audited = avc_audit_required(requested, avd, result, 0, &denied);
137138
if (likely(!audited))
138139
return 0;
139140
return slow_avc_audit(ssid, tsid, tclass,
140141
requested, audited, denied, result,
141-
a, 0);
142+
a, flags);
142143
}
143144

144145
#define AVC_STRICT 1 /* Ignore permissive mode. */
@@ -150,6 +151,10 @@ int avc_has_perm_noaudit(u32 ssid, u32 tsid,
150151
int avc_has_perm(u32 ssid, u32 tsid,
151152
u16 tclass, u32 requested,
152153
struct common_audit_data *auditdata);
154+
int avc_has_perm_flags(u32 ssid, u32 tsid,
155+
u16 tclass, u32 requested,
156+
struct common_audit_data *auditdata,
157+
int flags);
153158

154159
u32 avc_policy_seqno(void);
155160

0 commit comments

Comments
 (0)