#include <linux/mutex.h>
#include <linux/workqueue.h>
#include <linux/cgroup.h>
+#include <linux/kthread.h>
/*
* Workqueue for cpuset related tasks.
* unnecessary. Thus, cpusets are not applicable for such
* threads. This prevents checking for success of
* set_cpus_allowed_ptr() on all attached tasks before
- * cpus_allowed may be changed.
+ * cpus_allowed may be changed. We also disallow attaching
+ * kthreadd, to prevent its child from becoming trapped should
+ * it then acquire PF_THREAD_BOUND.
*/
- if (task->flags & PF_THREAD_BOUND)
+ if (task->flags & PF_THREAD_BOUND || task == kthreadd_task)
return -EINVAL;
if ((ret = security_task_setscheduler(task)))
return ret;
#include <linux/ftrace.h>
#include <linux/slab.h>
#include <linux/init_task.h>
+#include <linux/kthread.h>
#include <asm/tlb.h>
#include <asm/irq_regs.h>
struct task_struct *task;
cgroup_taskset_for_each(task, cgrp, tset) {
+ /*
+ * kthreadd can fork workers for an RT workqueue in a cgroup
+ * which may or may not have rt_runtime allocated. Just say no,
+ * as attaching a global resource to a non-root group doesn't
+ * make any sense anyway.
+ */
+ if (task == kthreadd_task)
+ return -EINVAL;
#ifdef CONFIG_RT_GROUP_SCHED
if (!sched_rt_can_attach(cgroup_tg(cgrp), task))
return -EINVAL;