[PATCH v2 1/4] cgroup: Child cgroup creation not allowed on invalid domain
From: Waiman Long
Date: Fri Jul 21 2017 - 16:35:31 EST
When thread mode is used, it is possible that some cgroups may be
in an invalid state. Currently users may not be aware that they are
invalid until they try to migrate tasks over. This patch disallows
child cgroup creation on invalid domain. This adds one more failure
point in reminding users that they are dealing with invalid domains.
It also minimizes the number of invalid domains outstanding as much
as possible.
Signed-off-by: Waiman Long <longman@xxxxxxxxxx>
---
kernel/cgroup/cgroup.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index e9a377d..5fc8133 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -4664,6 +4664,14 @@ int cgroup_mkdir(struct kernfs_node *parent_kn, const char *name, umode_t mode)
if (!parent)
return -ENODEV;
+ /*
+ * New cgroup creation isn't allowed on an invalid domain parent.
+ */
+ if (!cgroup_is_threaded(parent) && !cgroup_is_valid_domain(parent)) {
+ ret = -EOPNOTSUPP;
+ goto out_unlock;
+ }
+
cgrp = cgroup_create(parent);
if (IS_ERR(cgrp)) {
ret = PTR_ERR(cgrp);
--
1.8.3.1