]> git.hungrycats.org Git - linux/commitdiff
[PATCH] Fix ABI in set_mempolicy()
authorAndi Kleen <ak@suse.de>
Tue, 14 Sep 2004 01:38:02 +0000 (18:38 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Tue, 14 Sep 2004 01:38:02 +0000 (18:38 -0700)
Fix ABI in set_mempolicy() that got broken by an earlier change.

Add a check for very big input values and prevent excessive looping in the
kernel.

Cc: Paul "nyer, nyer, your mother wears combat boots!" Jackson <pj@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
mm/mempolicy.c

index 9b59ac453269debedff9139bc8fcee54b2166d7d..8fe9c7ee985334b02663ae22626d0db5606c500b 100644 (file)
@@ -132,6 +132,7 @@ static int get_nodes(unsigned long *nodes, unsigned long __user *nmask,
        unsigned long nlongs;
        unsigned long endmask;
 
+       --maxnode;
        bitmap_zero(nodes, MAX_NUMNODES);
        if (maxnode == 0 || !nmask)
                return 0;
@@ -145,6 +146,8 @@ static int get_nodes(unsigned long *nodes, unsigned long __user *nmask,
        /* When the user specified more nodes than supported just check
           if the non supported part is all zero. */
        if (nlongs > BITS_TO_LONGS(MAX_NUMNODES)) {
+               if (nlongs > PAGE_SIZE/sizeof(long))
+                       return -EINVAL;
                for (k = BITS_TO_LONGS(MAX_NUMNODES); k < nlongs; k++) {
                        unsigned long t;
                        if (get_user(t,  nmask + k))