Skip to content

Commit

Permalink
device_cgroup: use css_has_online_children() instead of has_children()
Browse files Browse the repository at this point in the history
devcgroup_update_access() wants to know whether there are child
cgroups which are online and visible to userland and has_children()
may return false positive.  Replace it with css_has_online_children().

Signed-off-by: Tejun Heo <[email protected]>
Acked-by: Aristeu Rozanski <[email protected]>
Acked-by: Serge Hallyn <[email protected]>
Acked-by: Li Zefan <[email protected]>
  • Loading branch information
htejun committed May 16, 2014
1 parent f3d4650 commit 7a3bb24
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions security/device_cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -587,21 +587,6 @@ static int propagate_exception(struct dev_cgroup *devcg_root,
return rc;
}

static inline bool has_children(struct dev_cgroup *devcgroup)
{
bool ret;

/*
* FIXME: There may be lingering offline csses and this function
* may return %true when there isn't any userland-visible child
* which is incorrect for our purposes.
*/
rcu_read_lock();
ret = css_next_child(NULL, &devcgroup->css);
rcu_read_unlock();
return ret;
}

/*
* Modify the exception list using allow/deny rules.
* CAP_SYS_ADMIN is needed for this. It's at least separate from CAP_MKNOD
Expand Down Expand Up @@ -634,7 +619,7 @@ static int devcgroup_update_access(struct dev_cgroup *devcgroup,
case 'a':
switch (filetype) {
case DEVCG_ALLOW:
if (has_children(devcgroup))
if (css_has_online_children(&devcgroup->css))
return -EINVAL;

if (!may_allow_all(parent))
Expand All @@ -650,7 +635,7 @@ static int devcgroup_update_access(struct dev_cgroup *devcgroup,
return rc;
break;
case DEVCG_DENY:
if (has_children(devcgroup))
if (css_has_online_children(&devcgroup->css))
return -EINVAL;

dev_exception_clean(devcgroup);
Expand Down

0 comments on commit 7a3bb24

Please sign in to comment.