]> git.hungrycats.org Git - linux/commitdiff
[PATCH] Backward compatibility for compat sched_getaffinity
authorAnton Blanchard <anton@samba.org>
Mon, 13 Sep 2004 07:05:30 +0000 (00:05 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Mon, 13 Sep 2004 07:05:30 +0000 (00:05 -0700)
The follow patch special cases the NR_CPUS <= BITS_PER_COMPAT_LONG case.
Without this patch, a 32bit task would be required to have a 64bit
cpumask no matter what value of NR_CPUS are used.

With this patch a compat long sized bitmask is allowed if NR_CPUS is
small enough to fit within it.

Of course applications should be using the glibc wrappers that use an
opaque cpu_mask_t type, but there could be older applications using the
syscalls directly.

Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
kernel/compat.c

index 9f3f23fd2788644c75d4b3c4a50ca28a72256df8..33880d2240775b359dcc52c0017b5e6484a804b8 100644 (file)
@@ -446,8 +446,12 @@ asmlinkage long compat_sys_sched_getaffinity(compat_pid_t pid, unsigned int len,
        int ret;
        cpumask_t mask;
        unsigned long *k;
+       unsigned int min_length = sizeof(cpumask_t);
 
-       if (len < sizeof(cpumask_t))
+       if (NR_CPUS <= BITS_PER_COMPAT_LONG)
+               min_length = sizeof(compat_ulong_t);
+
+       if (len < min_length)
                return -EINVAL;
 
        ret = sched_getaffinity(pid, &mask);
@@ -455,11 +459,11 @@ asmlinkage long compat_sys_sched_getaffinity(compat_pid_t pid, unsigned int len,
                return ret;
 
        k = cpus_addr(mask);
-       ret = compat_put_bitmap(user_mask_ptr, k, sizeof(cpumask_t) * 8);
+       ret = compat_put_bitmap(user_mask_ptr, k, min_length * 8);
        if (ret)
                return ret;
 
-       return sizeof(cpumask_t);
+       return min_length;
 }
 
 static int get_compat_itimerspec(struct itimerspec *dst,