]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
[PATCH] sys_set_mempolicy() doesnt check if mode < 0
authorEric Dumazet <dada1@cosmosbay.com>
Thu, 4 Aug 2005 01:43:22 +0000 (18:43 -0700)
committerChris Wright <chrisw@osdl.org>
Mon, 15 Aug 2005 00:20:07 +0000 (17:20 -0700)
A kernel BUG() is triggered by a call to set_mempolicy() with a negative
first argument.  This is because the mode is declared as an int, and the
validity check doesnt check < 0 values.  Alternatively, mode could be
declared as unsigned int or unsigned long.

Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>
Cc: Andi Kleen <ak@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Chris Wright <chrisw@osdl.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
mm/mempolicy.c

index 08c41da429cf015e9c22443ae5d811d4f5fa3569..b8e1ba10a8e5c1e74da992675aed7f61f211b493 100644 (file)
@@ -409,7 +409,7 @@ asmlinkage long sys_set_mempolicy(int mode, unsigned long __user *nmask,
        struct mempolicy *new;
        DECLARE_BITMAP(nodes, MAX_NUMNODES);
 
-       if (mode > MPOL_MAX)
+       if (mode < 0 || mode > MPOL_MAX)
                return -EINVAL;
        err = get_nodes(nodes, nmask, maxnode, mode);
        if (err)