Fix potential crash with sys_move_pages
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 6 Feb 2010 00:16:50 +0000 (16:16 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 6 Feb 2010 21:00:37 +0000 (13:00 -0800)
We incorrectly depended on the 'node_state/node_isset()' functions
testing the node range, rather than checking it explicitly.  That's not
reliable, even if it might often happen to work.  So do the proper
explicit test.

Reported-by: Marcus Meissner <meissner@suse.de>
Acked-and-tested-by: Brice Goglin <Brice.Goglin@inria.fr>
Acked-by: Hugh Dickins <hugh.dickins@tiscali.co.uk>
Cc: stable@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/migrate.c

index efddbf0926b283ae5ef292e076ff9900842c4dd5..9a0db5bbabe4c93c0fce3ee7c24f13f2fbf84dc0 100644 (file)
@@ -912,6 +912,9 @@ static int do_pages_move(struct mm_struct *mm, struct task_struct *task,
                                goto out_pm;
 
                        err = -ENODEV;
+                       if (node < 0 || node >= MAX_NUMNODES)
+                               goto out_pm;
+
                        if (!node_state(node, N_HIGH_MEMORY))
                                goto out_pm;