lkml.org 
[lkml]   [2012]   [Apr]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[patch 1/2] cpusets: disallow attaching kthreadd
    From: Mike Galbraith <efault@gmx.de>

    A worker thread spawned by kthreadd may acquire PF_THREAD_BOUND and never
    be able to leave a cpuset, rending the cpuset immortal. Save the user
    some unexpected trouble, just say no.

    Acked-by: Paul Menage <paul@paulmenage.org>
    Signed-off-by: Mike Galbraith <efault@gmx.de>
    Signed-off-by: David Rientjes <rientjes@google.com>
    ---
    kernel/cpuset.c | 7 +++++--
    1 file changed, 5 insertions(+), 2 deletions(-)

    diff --git a/kernel/cpuset.c b/kernel/cpuset.c
    --- a/kernel/cpuset.c
    +++ b/kernel/cpuset.c
    @@ -53,6 +53,7 @@
    #include <linux/time.h>
    #include <linux/backing-dev.h>
    #include <linux/sort.h>
    +#include <linux/kthread.h>

    #include <asm/uaccess.h>
    #include <linux/atomic.h>
    @@ -1389,9 +1390,11 @@ static int cpuset_can_attach(struct cgroup *cgrp, struct cgroup_taskset *tset)
    * 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 a child from becoming trapped should it
    + * later 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;

    \
     
     \ /
      Last update: 2012-04-05 09:17    [W:0.021 / U:1.220 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site