]> git.baikalelectronics.ru Git - kernel.git/commit
cgroup: fix invalid controller enable rejections with cgroup namespace
authorTejun Heo <tj@kernel.org>
Fri, 23 Sep 2016 20:55:49 +0000 (16:55 -0400)
committerTejun Heo <tj@kernel.org>
Fri, 23 Sep 2016 20:55:49 +0000 (16:55 -0400)
commit2a678eb3216757165252822ffeac57bc93b80f5d
tree3b2cea5209fae8b62b46ab19c3ce4d4a897b9b40
parenta8cb333de2de700e3730ad8b498f752698a2a52b
cgroup: fix invalid controller enable rejections with cgroup namespace

On the v2 hierarchy, "cgroup.subtree_control" rejects controller
enables if the cgroup has processes in it.  The enforcement of this
logic assumes that the cgroup wouldn't have any css_sets associated
with it if there are no tasks in the cgroup, which is no longer true
since bd9694d6c00e ("cgroup: introduce cgroup namespaces").

When a cgroup namespace is created, it pins the css_set of the
creating task to use it as the root css_set of the namespace.  This
extra reference stays as long as the namespace is around and makes
"cgroup.subtree_control" think that the namespace root cgroup is not
empty even when it is and thus reject controller enables.

Fix it by making cgroup_subtree_control() walk and test emptiness of
each css_set instead of testing whether the list_head is empty.

While at it, update the comment of cgroup_task_count() to indicate
that the returned value may be higher than the number of tasks, which
has always been true due to temporary references and doesn't break
anything.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: Evgeny Vereshchagin <evvers@ya.ru>
Cc: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Cc: Aditya Kali <adityakali@google.com>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: stable@vger.kernel.org # v4.6+
Fixes: bd9694d6c00e ("cgroup: introduce cgroup namespaces")
Link: https://github.com/systemd/systemd/pull/3589#issuecomment-249089541
kernel/cgroup.c