Re: [tip:sched/urgent] cpuset: Fix cpuset_cpus_allowed_fallback(),don't update tsk->rt.nr_cpus_allowed

From: Peter Zijlstra
Date: Mon Jun 20 2011 - 06:21:50 EST


On Sat, 2011-05-28 at 16:35 +0000, tip-bot for KOSAKI Motohiro wrote:
> +++ b/kernel/kthread.c
> @@ -202,8 +202,8 @@ void kthread_bind(struct task_struct *p, unsigned int cpu)
> return;
> }
>
> - p->cpus_allowed = cpumask_of_cpu(cpu);
> - p->rt.nr_cpus_allowed = 1;
> + /* It's safe because the task is inactive. */
> + do_set_cpus_allowed(p, cpumask_of(cpu));
> p->flags |= PF_THREAD_BOUND;
> }


I just happened to be staring at this stuff again, and I'm wondering
how and why this is correct. After kthread_create() the thread exists
and is exposed in the pid-hash, therefore userspace can come and do
sys_sched_setaffinity() on it, and since we're not holding any locks and
set PF_THREAD_BOUND _after_ setting cpus_allowed, things can end up
funny.

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