Skip to content

Commit 26898fd

Browse files
aristeuhtejun
authored andcommitted
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>
1 parent 3ac1707 commit 26898fd

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

‎security/device_cgroup.c‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,8 @@ static int devcgroup_seq_read(struct cgroup *cgroup, struct cftype *cft,
305305
* @dev_cgroup: dev cgroup to be tested against
306306
* @refex: new exception
307307
*/
308-
static int may_access(struct dev_cgroup *dev_cgroup,
309-
struct dev_exception_item *refex)
308+
static bool may_access(struct dev_cgroup *dev_cgroup,
309+
struct dev_exception_item *refex)
310310
{
311311
struct dev_exception_item *ex;
312312
bool match = false;
@@ -332,16 +332,19 @@ static int may_access(struct dev_cgroup *dev_cgroup,
332332

333333
/*
334334
* In two cases we'll consider this new exception valid:
335-
* - the dev cgroup has its default policy to allow + exception list:
336-
* the new exception should *not* match any of the exceptions
337-
* (behavior == DEVCG_DEFAULT_ALLOW, !match)
338335
* - the dev cgroup has its default policy to deny + exception list:
339336
* the new exception *should* match the exceptions
340-
* (behavior == DEVCG_DEFAULT_DENY, match)
337+
* - the dev cgroup has its default policy to allow + exception list:
338+
* the new exception should *not* match any of the exceptions
341339
*/
342-
if ((dev_cgroup->behavior == DEVCG_DEFAULT_DENY) == match)
343-
return 1;
344-
return 0;
340+
if (dev_cgroup->behavior == DEVCG_DEFAULT_DENY) {
341+
if (match)
342+
return true;
343+
} else {
344+
if (!match)
345+
return true;
346+
}
347+
return false;
345348
}
346349

347350
/*

0 commit comments

Comments
 (0)