Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 293926
b: refs/heads/master
c: 48aab2f
h: refs/heads/master
v: v3
  • Loading branch information
Linus Torvalds committed Mar 23, 2012
1 parent 057d051 commit c1c5fa9
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 30 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f7493e5d9cc10ac97cf1f1579fdc14117460b40b
refs/heads/master: 48aab2f79dfc1357c48ce22ff5c989b52a590069
70 changes: 41 additions & 29 deletions trunk/security/selinux/avc.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,42 @@ static void avc_audit_post_callback(struct audit_buffer *ab, void *a)
ad->selinux_audit_data.tclass);
}

/* This is the slow part of avc audit with big stack footprint */
static noinline int slow_avc_audit(u32 ssid, u32 tsid, u16 tclass,
u32 requested, u32 audited, u32 denied,
struct av_decision *avd, struct common_audit_data *a,
unsigned flags)
{
struct common_audit_data stack_data;

if (!a) {
a = &stack_data;
COMMON_AUDIT_DATA_INIT(a, NONE);
}

/*
* When in a RCU walk do the audit on the RCU retry. This is because
* the collection of the dname in an inode audit message is not RCU
* safe. Note this may drop some audits when the situation changes
* during retry. However this is logically just as if the operation
* happened a little later.
*/
if ((a->type == LSM_AUDIT_DATA_INODE) &&
(flags & MAY_NOT_BLOCK))
return -ECHILD;

a->selinux_audit_data.tclass = tclass;
a->selinux_audit_data.requested = requested;
a->selinux_audit_data.ssid = ssid;
a->selinux_audit_data.tsid = tsid;
a->selinux_audit_data.audited = audited;
a->selinux_audit_data.denied = denied;
a->lsm_pre_audit = avc_audit_pre_callback;
a->lsm_post_audit = avc_audit_post_callback;
common_lsm_audit(a);
return 0;
}

/**
* avc_audit - Audit the granting or denial of permissions.
* @ssid: source security identifier
Expand All @@ -482,10 +518,9 @@ int avc_audit(u32 ssid, u32 tsid,
struct av_decision *avd, int result, struct common_audit_data *a,
unsigned flags)
{
struct common_audit_data stack_data;
u32 denied, audited;
denied = requested & ~avd->allowed;
if (denied) {
if (unlikely(denied)) {
audited = denied & avd->auditdeny;
/*
* a->selinux_audit_data.auditdeny is TRICKY! Setting a bit in
Expand All @@ -511,35 +546,12 @@ int avc_audit(u32 ssid, u32 tsid,
audited = denied = requested;
else
audited = requested & avd->auditallow;
if (!audited)
if (likely(!audited))
return 0;

if (!a) {
a = &stack_data;
COMMON_AUDIT_DATA_INIT(a, NONE);
}

/*
* When in a RCU walk do the audit on the RCU retry. This is because
* the collection of the dname in an inode audit message is not RCU
* safe. Note this may drop some audits when the situation changes
* during retry. However this is logically just as if the operation
* happened a little later.
*/
if ((a->type == LSM_AUDIT_DATA_INODE) &&
(flags & MAY_NOT_BLOCK))
return -ECHILD;

a->selinux_audit_data.tclass = tclass;
a->selinux_audit_data.requested = requested;
a->selinux_audit_data.ssid = ssid;
a->selinux_audit_data.tsid = tsid;
a->selinux_audit_data.audited = audited;
a->selinux_audit_data.denied = denied;
a->lsm_pre_audit = avc_audit_pre_callback;
a->lsm_post_audit = avc_audit_post_callback;
common_lsm_audit(a);
return 0;
return slow_avc_audit(ssid, tsid, tclass,
requested, audited, denied,
avd, a, flags);
}

/**
Expand Down

0 comments on commit c1c5fa9

Please sign in to comment.