]> git.hungrycats.org Git - linux/commitdiff
[PATCH] sched_getaffinity vs cpu hotplug race fix
authorAndrew Morton <akpm@osdl.org>
Mon, 10 May 2004 06:30:12 +0000 (23:30 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Mon, 10 May 2004 06:30:12 +0000 (23:30 -0700)
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.

kernel/sched.c

index 059fc20851ea3841e39c2b41c99d7b2c18b5d88c..422bfeb614e1eee4b259b96652af41fd479e3b94 100644 (file)
@@ -2934,6 +2934,7 @@ asmlinkage long sys_sched_getaffinity(pid_t pid, unsigned int len,
        if (len < real_len)
                return -EINVAL;
 
+       lock_cpu_hotplug();
        read_lock(&tasklist_lock);
 
        retval = -ESRCH;
@@ -2946,6 +2947,7 @@ asmlinkage long sys_sched_getaffinity(pid_t pid, unsigned int len,
 
 out_unlock:
        read_unlock(&tasklist_lock);
+       unlock_cpu_hotplug();
        if (retval)
                return retval;
        if (copy_to_user(user_mask_ptr, &mask, real_len))