]> Git Repo - linux.git/commitdiff
sched: Fix sched_getaffinity()
authorAnton Blanchard <[email protected]>
Tue, 6 Apr 2010 07:02:19 +0000 (17:02 +1000)
committerIngo Molnar <[email protected]>
Tue, 6 Apr 2010 08:01:35 +0000 (10:01 +0200)
taskset on 2.6.34-rc3 fails on one of my ppc64 test boxes with
the following error:

  sched_getaffinity(0, 16, 0x10029650030) = -1 EINVAL (Invalid argument)

This box has 128 threads and 16 bytes is enough to cover it.

Commit cd3d8031eb4311e516329aee03c79a08333141f1 (sched:
sched_getaffinity(): Allow less than NR_CPUS length) is
comparing this 16 bytes agains nr_cpu_ids.

Fix it by comparing nr_cpu_ids to the number of bits in the
cpumask we pass in.

Signed-off-by: Anton Blanchard <[email protected]>
Reviewed-by: KOSAKI Motohiro <[email protected]>
Cc: Sharyathi Nagesh <[email protected]>
Cc: Ulrich Drepper <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Jack Steiner <[email protected]>
Cc: Russ Anderson <[email protected]>
Cc: Mike Travis <[email protected]>
LKML-Reference: <20100406070218.GM5594@kryten>
Signed-off-by: Ingo Molnar <[email protected]>
kernel/sched.c

index 528a10592c16782e813238e050fb1abba79e05e7..eaf5c7375dfdbbb7c95f1daef7f5b23f0ea5335a 100644 (file)
@@ -4902,7 +4902,7 @@ SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len,
        int ret;
        cpumask_var_t mask;
 
-       if (len < nr_cpu_ids)
+       if ((len * BITS_PER_BYTE) < nr_cpu_ids)
                return -EINVAL;
        if (len & (sizeof(unsigned long)-1))
                return -EINVAL;
This page took 0.066843 seconds and 4 git commands to generate.