Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 298234
b: refs/heads/master
c: a554bea
h: refs/heads/master
v: v3
  • Loading branch information
Linus Torvalds committed Mar 31, 2012
1 parent ad30275 commit 42067b1
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 15 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: fa2a4519cb6ad94224eb56a1341fff570fd44ea1
refs/heads/master: a554bea89948dfb6d2f9c4c62ce2b12b2dac18ad
52 changes: 38 additions & 14 deletions trunk/security/selinux/avc.c
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,41 @@ int avc_ss_reset(u32 seqno)
return rc;
}

/*
* Slow-path helper function for avc_has_perm_noaudit,
* when the avc_node lookup fails. We get called with
* the RCU read lock held, and need to return with it
* still held, but drop if for the security compute.
*
* Don't inline this, since it's the slow-path and just
* results in a bigger stack frame.
*/
static noinline struct avc_node *avc_compute_av(u32 ssid, u32 tsid,
u16 tclass, struct av_decision *avd)
{
rcu_read_unlock();
security_compute_av(ssid, tsid, tclass, avd);
rcu_read_lock();
return avc_insert(ssid, tsid, tclass, avd);
}

static noinline int avc_denied(u32 ssid, u32 tsid,
u16 tclass, u32 requested,
unsigned flags,
struct av_decision *avd)
{
if (flags & AVC_STRICT)
return -EACCES;

if (selinux_enforcing && !(avd->flags & AVD_FLAGS_PERMISSIVE))
return -EACCES;

avc_update_node(AVC_CALLBACK_GRANT, requested, ssid,
tsid, tclass, avd->seqno);
return 0;
}


/**
* avc_has_perm_noaudit - Check permissions but perform no auditing.
* @ssid: source security identifier
Expand Down Expand Up @@ -776,26 +811,15 @@ int avc_has_perm_noaudit(u32 ssid, u32 tsid,

node = avc_lookup(ssid, tsid, tclass);
if (unlikely(!node)) {
rcu_read_unlock();
security_compute_av(ssid, tsid, tclass, avd);
rcu_read_lock();
node = avc_insert(ssid, tsid, tclass, avd);
node = avc_compute_av(ssid, tsid, tclass, avd);
} else {
memcpy(avd, &node->ae.avd, sizeof(*avd));
avd = &node->ae.avd;
}

denied = requested & ~(avd->allowed);

if (denied) {
if (flags & AVC_STRICT)
rc = -EACCES;
else if (!selinux_enforcing || (avd->flags & AVD_FLAGS_PERMISSIVE))
avc_update_node(AVC_CALLBACK_GRANT, requested, ssid,
tsid, tclass, avd->seqno);
else
rc = -EACCES;
}
if (unlikely(denied))
rc = avc_denied(ssid, tsid, tclass, requested, flags, avd);

rcu_read_unlock();
return rc;
Expand Down

0 comments on commit 42067b1

Please sign in to comment.