lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 14 Dec 2011 18:50:08 -0800 (PST)
From:	David Rientjes <rientjes@...gle.com>
To:	Andrew Morton <akpm@...ux-foundation.org>
cc:	Mike Galbraith <efault@....de>, Paul Menage <paul@...lmenage.org>,
	LKML <linux-kernel@...r.kernel.org>,
	Tejun Heo <htejun@...il.com>, Li Zefan <lizf@...fujitsu.com>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>
Subject: Re: [resubmit] Re: [patch-final] Re: patch] cpusets, cgroups: disallow
 attaching kthreadd

On Wed, 14 Dec 2011, Andrew Morton wrote:

> diff -puN kernel/cpuset.c~cpusets-cgroups-disallow-attaching-kthreadd kernel/cpuset.c
> --- a/kernel/cpuset.c~cpusets-cgroups-disallow-attaching-kthreadd
> +++ a/kernel/cpuset.c
> @@ -59,6 +59,7 @@
>  #include <linux/mutex.h>
>  #include <linux/workqueue.h>
>  #include <linux/cgroup.h>
> +#include <linux/kthread.h>
>  
>  /*
>   * Workqueue for cpuset related tasks.
> @@ -1417,9 +1418,11 @@ static int cpuset_can_attach(struct cgro
>  		 * 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 (tsk->flags & PF_THREAD_BOUND || tsk == kthreadd_task)
>  			return -EINVAL;
>  		if ((ret = security_task_setscheduler(task)))
>  			return ret;
> diff -puN kernel/sched/core.c~cpusets-cgroups-disallow-attaching-kthreadd kernel/sched/core.c
> --- a/kernel/sched/core.c~cpusets-cgroups-disallow-attaching-kthreadd
> +++ a/kernel/sched/core.c
> @@ -71,6 +71,7 @@
>  #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>
> @@ -7535,6 +7536,14 @@ static int cpu_cgroup_can_attach(struct 
>  	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 (tsk == kthreadd_task)
> +			return -EINVAL;
>  #ifdef CONFIG_RT_GROUP_SCHED
>  		if (!sched_rt_can_attach(cgroup_tg(cgrp), task))
>  			return -EINVAL;

Ah, yes, this requires knowledge of the cgroups' proc file trigger to 
move all threads into the cgroup.  The ->can_attach() functions then 
have all-or-nothing behavior; either all the threads can be moved or 
none of them can.  So the above are the correct fixups for both 
->can_attach() functions.

The above diff references non-existant symbols (tsk instead of task) in 
both functions, but it appears (and compiles correctly) in linux-next.  So 
please preserve my acked-by.

Thanks for fixing this up!
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ