summaryrefslogtreecommitdiffstats
path: root/kernel/cgroup.c
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-06-14 11:18:22 -0700
committerTejun Heo <tj@kernel.org>2013-06-18 08:14:23 -0700
commit6db8e85c5c1f89cd0183b76dab027c81009f129f (patch)
tree6195edbc8abb6645d39a4986fd2d48c89bbefa92 /kernel/cgroup.c
parentf63674fd0d6afa1ba24309aee1f8c60195d39041 (diff)
downloadlinux-6db8e85c5c1f89cd0183b76dab027c81009f129f.tar.gz
linux-6db8e85c5c1f89cd0183b76dab027c81009f129f.tar.xz
cgroup: disallow rename(2) if sane_behavior
cgroup's rename(2) isn't a proper migration implementation - it can't move the cgroup to a different parent in the hierarchy. All it can do is swapping the name string for that cgroup. This isn't useful and can mislead users to think that cgroup supports proper cgroup-level migration. Disallow rename(2) if sane_behavior. v2: Fail with -EPERM instead of -EINVAL so that it matches the vfs return value when ->rename is not implemented as suggested by Li. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Li Zefan <lizefan@huawei.com>
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r--kernel/cgroup.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 2e9da7bf25cb..c2c64005bbc2 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2508,6 +2508,13 @@ static int cgroup_rename(struct inode *old_dir, struct dentry *old_dentry,
cgrp = __d_cgrp(old_dentry);
+ /*
+ * This isn't a proper migration and its usefulness is very
+ * limited. Disallow if sane_behavior.
+ */
+ if (cgroup_sane_behavior(cgrp))
+ return -EPERM;
+
name = cgroup_alloc_name(new_dentry);
if (!name)
return -ENOMEM;