lkml.org 
[lkml]   [2010]   [Sep]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[064/123] sched: Protect task->cpus_allowed access in sched_getaffinity()

From: Thomas Gleixner <tglx@linutronix.de>

commit 3160568371da441b7f2fb57f2f1225404207e8f2 upstream

sched_getaffinity() is not protected against a concurrent
modification of the tasks affinity.

Serialize the access with task_rq_lock(task).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra <peterz@infradead.org>
LKML-Reference: <20091208202026.769251187@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Mike Galbraith <efault@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
kernel/sched.c | 4 ++++
1 file changed, 4 insertions(+)

--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -6686,6 +6686,8 @@ SYSCALL_DEFINE3(sched_setaffinity, pid_t
long sched_getaffinity(pid_t pid, struct cpumask *mask)
{
struct task_struct *p;
+ unsigned long flags;
+ struct rq *rq;
int retval;

get_online_cpus();
@@ -6700,7 +6702,9 @@ long sched_getaffinity(pid_t pid, struct
if (retval)
goto out_unlock;

+ rq = task_rq_lock(p, &flags);
cpumask_and(mask, &p->cpus_allowed, cpu_online_mask);
+ task_rq_unlock(rq, &flags);

out_unlock:
read_unlock(&tasklist_lock);



\
 
 \ /
  Last update: 2010-09-18 21:51    [W:0.266 / U:37.648 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site