aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-01-31 16:54:41 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-01-31 16:54:41 -0500
commitf1774f46d49f806614d81854321ee9e5138135e5 (patch)
tree3ea8462bc0c1951c38ee93e7d91a5449a565b6b7
parent298a2d87518ec01bb36070fafe31da7746556db0 (diff)
parent07cd12945551b63ecb1a349d50a6d69d1d6feb4a (diff)
Merge branch 'for-4.10-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup
Pull cgroup fix from Tejun Heo: "The cgroup creation path was getting the order of operations wrong and exposing cgroups which don't have their names set yet to controllers which can lead to NULL derefs. This contains the fix for the bug" * 'for-4.10-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup: cgroup: don't online subsystems before cgroup_name/path() are operational
-rw-r--r--kernel/cgroup.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 2ee9ec3051b2..688dd02af985 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -5221,6 +5221,11 @@ err_free_css:
5221 return ERR_PTR(err); 5221 return ERR_PTR(err);
5222} 5222}
5223 5223
5224/*
5225 * The returned cgroup is fully initialized including its control mask, but
5226 * it isn't associated with its kernfs_node and doesn't have the control
5227 * mask applied.
5228 */
5224static struct cgroup *cgroup_create(struct cgroup *parent) 5229static struct cgroup *cgroup_create(struct cgroup *parent)
5225{ 5230{
5226 struct cgroup_root *root = parent->root; 5231 struct cgroup_root *root = parent->root;
@@ -5288,11 +5293,6 @@ static struct cgroup *cgroup_create(struct cgroup *parent)
5288 5293
5289 cgroup_propagate_control(cgrp); 5294 cgroup_propagate_control(cgrp);
5290 5295
5291 /* @cgrp doesn't have dir yet so the following will only create csses */
5292 ret = cgroup_apply_control_enable(cgrp);
5293 if (ret)
5294 goto out_destroy;
5295
5296 return cgrp; 5296 return cgrp;
5297 5297
5298out_cancel_ref: 5298out_cancel_ref:
@@ -5300,9 +5300,6 @@ out_cancel_ref:
5300out_free_cgrp: 5300out_free_cgrp:
5301 kfree(cgrp); 5301 kfree(cgrp);
5302 return ERR_PTR(ret); 5302 return ERR_PTR(ret);
5303out_destroy:
5304 cgroup_destroy_locked(cgrp);
5305 return ERR_PTR(ret);
5306} 5303}
5307 5304
5308static int cgroup_mkdir(struct kernfs_node *parent_kn, const char *name, 5305static int cgroup_mkdir(struct kernfs_node *parent_kn, const char *name,