cgroups.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH cgroup/for-3.11] cgroup: disallow rename(2) if sane_behavior
@ 2013-06-14  3:47 Tejun Heo
       [not found] ` <20130614034717.GA31533-Gd/HAXX7CRxy/B6EtB590w@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Tejun Heo @ 2013-06-14  3:47 UTC (permalink / raw)
  To: Li Zefan
  Cc: cgroups-u79uwXL29TY76Z2rM5mHXA,
	containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	Kay Sievers, Lennart Poettering

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.

Signed-off-by: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
---
 include/linux/cgroup.h |    2 ++
 kernel/cgroup.c        |    7 +++++++
 2 files changed, 9 insertions(+)

diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 1760476..f975227 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -270,6 +270,8 @@ enum {
 	 * - "release_agent" and "notify_on_release" are removed.
 	 *   Replacement notification mechanism will be implemented.
 	 *
+	 * - rename(2) is disallowed.
+	 *
 	 * - memcg: use_hierarchy is on by default and the cgroup file for
 	 *   the flag is not created.
 	 */
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 2e9da7b..7d78902 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 -EINVAL;
+
 	name = cgroup_alloc_name(new_dentry);
 	if (!name)
 		return -ENOMEM;

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2013-06-21  8:35 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-14  3:47 [PATCH cgroup/for-3.11] cgroup: disallow rename(2) if sane_behavior Tejun Heo
     [not found] ` <20130614034717.GA31533-Gd/HAXX7CRxy/B6EtB590w@public.gmane.org>
2013-06-14  7:44   ` Li Zefan
2013-06-14 18:18   ` [PATCH v2 " Tejun Heo
     [not found]     ` <20130614181822.GC6593-9pTldWuhBndy/B6EtB590w@public.gmane.org>
2013-06-18  9:11       ` Li Zefan
2013-06-18 15:16       ` Tejun Heo
2013-06-16  7:16   ` [PATCH " Lennart Poettering
     [not found]     ` <20130616071648.GA1978-kS5D54t9nk0aINubkmmoJbNAH6kLmebB@public.gmane.org>
2013-06-16 22:15       ` Tejun Heo
     [not found]         ` <20130616221556.GC28587-Gd/HAXX7CRxy/B6EtB590w@public.gmane.org>
2013-06-17 13:00           ` Aristeu Rozanski
     [not found]             ` <20130617130029.GB3212-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2013-06-17 17:06               ` Tejun Heo
2013-06-17 13:51           ` Michal Hocko
     [not found]             ` <20130617135122.GD5018-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2013-06-17 16:51               ` Tejun Heo
     [not found]                 ` <20130617165129.GA32663-9pTldWuhBndy/B6EtB590w@public.gmane.org>
2013-06-21  8:35                   ` Michal Hocko
2013-06-17 16:33           ` Lennart Poettering
     [not found]             ` <20130617163353.GD22846-kS5D54t9nk0aINubkmmoJbNAH6kLmebB@public.gmane.org>
2013-06-17 16:53               ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).