linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] cgroups: disallow attaching kthreadd
@ 2012-04-03 17:58 Mike Galbraith
  2012-04-03 18:49 ` Tejun Heo
                   ` (2 more replies)
  0 siblings, 3 replies; 53+ messages in thread
From: Mike Galbraith @ 2012-04-03 17:58 UTC (permalink / raw)
  To: Tejun Heo; +Cc: Peter Zijlstra, Li Zefan, David Rientjes, Paul Menage, LKML

The hazzards of moving kthreadd into a non-root cgroup is still present
in mainline.  Last go 'round stalled with Peter not liking the
cpuset,cpu per controller specific exclusion.  I agree that total
exclusion is the better option, and below is a respin doing that.

cgroups: disallow attaching kthreadd

Allowing kthreadd to be moved to a non-root group makes no sense, it being
a global resource, and needlessly leads unsuspecting users toward trouble.

1. An RT workqueue worker thread spawned in a task group with no rt_runtime
allocated is not schedulable.  Simple user error, but harmful to the box.

2. A worker thread which acquires PF_THREAD_BOUND can never leave a cpuset,
rendering the cpuset immortal.

Save the user some unexpected trouble, just say no.

Signed-off-by: Mike Galbraith <mgalbraith@suse.de>
---
 kernel/cgroup.c |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -60,6 +60,7 @@
 #include <linux/eventfd.h>
 #include <linux/poll.h>
 #include <linux/flex_array.h> /* used in cgroup_attach_proc */
+#include <linux/kthread.h>
 
 #include <linux/atomic.h>
 
@@ -1894,6 +1895,14 @@ int cgroup_attach_task(struct cgroup *cg
 	if (tsk->flags & PF_EXITING)
 		return -ESRCH;
 
+	/*
+	 * Workqueue threads may acquire PF_THREAD_BOUND and become
+	 * trapped in a cpuset, or RT worker may be born in a cgroup
+	 * with no rt_runtime allocated.  Just say no.
+	 */
+	if (tsk == kthreadd_task)
+		return -EINVAL;
+
 	/* Nothing to do if the task is already in that cgroup */
 	oldcgrp = task_cgroup_from_root(tsk, root);
 	if (cgrp == oldcgrp)
@@ -2172,6 +2181,17 @@ static int attach_task_by_pid(struct cgr
 
 	if (threadgroup)
 		tsk = tsk->group_leader;
+
+	/*
+	 * Workqueue threads may acquire PF_THREAD_BOUND and become
+	 * trapped in a cpuset, or RT worker may be born in a cgroup
+	 * with no rt_runtime allocated.  Just say no.
+	 */
+	if (tsk == kthreadd_task) {
+		ret = -EINVAL;
+		goto out_unlock_cgroup;
+	}
+
 	get_task_struct(tsk);
 	rcu_read_unlock();
 




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

end of thread, other threads:[~2012-04-23 18:05 UTC | newest]

Thread overview: 53+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-03 17:58 [patch] cgroups: disallow attaching kthreadd Mike Galbraith
2012-04-03 18:49 ` Tejun Heo
2012-04-04  2:34   ` Mike Galbraith
2012-04-04 23:06     ` Tejun Heo
2012-04-04 23:10       ` Tejun Heo
2012-04-04  7:15 ` David Rientjes
2012-04-04 10:38   ` Mike Galbraith
2012-04-04 11:29     ` David Rientjes
2012-04-04 12:30       ` Mike Galbraith
2012-04-04 21:17         ` David Rientjes
2012-04-04 23:09           ` Tejun Heo
2012-04-04 23:14             ` David Rientjes
2012-04-05  4:47             ` Mike Galbraith
2012-04-05  4:58               ` David Rientjes
2012-04-05  5:49                 ` Mike Galbraith
2012-04-05  6:07                   ` David Rientjes
2012-04-05  6:42                     ` Mike Galbraith
2012-04-05  6:49                       ` David Rientjes
2012-04-05  7:14                         ` [patch 0/2] cpusets, cpu_cgroup: " David Rientjes
2012-04-05  7:14                           ` [patch 1/2] cpusets: " David Rientjes
2012-04-05  7:14                           ` [patch 2/2] cpu_cgroup: " David Rientjes
2012-04-05 16:08                           ` [patch 0/2] cpusets, " Tejun Heo
2012-04-05 21:26                             ` David Rientjes
2012-04-05 21:37                               ` Tejun Heo
2012-04-05 21:46                                 ` Tejun Heo
2012-04-06  7:50                                   ` Li Zefan
2012-04-06 15:54                                     ` Tejun Heo
2012-04-05 22:03                                 ` David Rientjes
2012-04-05 22:24                                   ` Tejun Heo
2012-04-05 22:31                                     ` Tejun Heo
2012-04-05 22:55                                     ` David Rientjes
2012-04-05 22:58                                       ` Tejun Heo
2012-04-05 23:05                                         ` David Rientjes
2012-04-05 23:13                                           ` Tejun Heo
2012-04-05 23:40                                             ` David Rientjes
2012-04-06 15:52                                               ` Tejun Heo
2012-04-06 18:26                                                 ` Peter Zijlstra
2012-04-06 20:49                                                   ` David Rientjes
2012-04-07 15:02                                                     ` Hiroyuki Kamezawa
2012-04-10  0:52                                                       ` David Rientjes
2012-04-14 11:35                                                         ` Peter Zijlstra
2012-04-20 17:55                                                         ` Tejun Heo
2012-04-06 20:46                                                 ` David Rientjes
2012-04-14 11:28                                                   ` Peter Zijlstra
2012-04-05  7:36                         ` [patch] cgroups: " Mike Galbraith
2012-04-05  8:00                           ` David Rientjes
2012-04-14 11:17                     ` Peter Zijlstra
2012-04-05 16:11               ` Tejun Heo
2012-04-20 17:57 ` Tejun Heo
2012-04-21  5:31   ` Mike Galbraith
2012-04-21  6:54     ` Li Zefan
2012-04-21  7:13       ` Mike Galbraith
2012-04-23 18:05         ` 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).