
From: Srivatsa Vaddagiri <vatsa@in.ibm.com>

Fix the race in sys_sched_getaffinity.  Patch below takes cpu_hotplug lock
before reading cpus_allowed mask of a task.


---

 25-akpm/kernel/sched.c |    2 ++
 1 files changed, 2 insertions(+)

diff -puN kernel/sched.c~sched-sys_sched_getaffinity_lock_cpu_hotplug kernel/sched.c
--- 25/kernel/sched.c~sched-sys_sched_getaffinity_lock_cpu_hotplug	2004-04-30 00:02:34.505217080 -0700
+++ 25-akpm/kernel/sched.c	2004-04-30 00:02:34.510216320 -0700
@@ -2941,6 +2941,7 @@ asmlinkage long sys_sched_getaffinity(pi
 	if (len < real_len)
 		return -EINVAL;
 
+	lock_cpu_hotplug();
 	read_lock(&tasklist_lock);
 
 	retval = -ESRCH;
@@ -2953,6 +2954,7 @@ asmlinkage long sys_sched_getaffinity(pi
 
 out_unlock:
 	read_unlock(&tasklist_lock);
+	unlock_cpu_hotplug();
 	if (retval)
 		return retval;
 	if (copy_to_user(user_mask_ptr, &mask, real_len))

_
