aboutsummaryrefslogtreecommitdiff
path: root/security/device_cgroup.c
diff options
context:
space:
mode:
authorAristeu Rozanski <aris@redhat.com>2013-02-15 11:55:44 -0500
committerTejun Heo <tj@kernel.org>2013-03-20 07:50:09 -0700
commit26898fdff371d78f122cf15d8732d1d37f2d1338 (patch)
treee6da9b9fe1f6d957f0aae86288525ecb8afb4e08 /security/device_cgroup.c
parent3ac1707a13a3da9cfc8f242a15b2fae6df2c5f88 (diff)
devcg: expand may_access() logic
In order to make the next patch more clear, expand may_access() logic. v2: may_access() returns bool now Acked-by: Tejun Heo <tj@kernel.org> Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Cc: Tejun Heo <tj@kernel.org> Cc: Serge Hallyn <serge.hallyn@canonical.com> Signed-off-by: Aristeu Rozanski <aris@redhat.com> Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'security/device_cgroup.c')
-rw-r--r--security/device_cgroup.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/security/device_cgroup.c b/security/device_cgroup.c
index 1c69e38e3a2..4ad55a9c692 100644
--- a/security/device_cgroup.c
+++ b/security/device_cgroup.c
@@ -305,8 +305,8 @@ static int devcgroup_seq_read(struct cgroup *cgroup, struct cftype *cft,
* @dev_cgroup: dev cgroup to be tested against
* @refex: new exception
*/
-static int may_access(struct dev_cgroup *dev_cgroup,
- struct dev_exception_item *refex)
+static bool may_access(struct dev_cgroup *dev_cgroup,
+ struct dev_exception_item *refex)
{
struct dev_exception_item *ex;
bool match = false;
@@ -332,16 +332,19 @@ static int may_access(struct dev_cgroup *dev_cgroup,
/*
* In two cases we'll consider this new exception valid:
- * - the dev cgroup has its default policy to allow + exception list:
- * the new exception should *not* match any of the exceptions
- * (behavior == DEVCG_DEFAULT_ALLOW, !match)
* - the dev cgroup has its default policy to deny + exception list:
* the new exception *should* match the exceptions
- * (behavior == DEVCG_DEFAULT_DENY, match)
+ * - the dev cgroup has its default policy to allow + exception list:
+ * the new exception should *not* match any of the exceptions
*/
- if ((dev_cgroup->behavior == DEVCG_DEFAULT_DENY) == match)
- return 1;
- return 0;
+ if (dev_cgroup->behavior == DEVCG_DEFAULT_DENY) {
+ if (match)
+ return true;
+ } else {
+ if (!match)
+ return true;
+ }
+ return false;
}
/*