From: Linus Torvalds Date: Sat, 6 Feb 2010 00:16:50 +0000 (-0800) Subject: Fix potential crash with sys_move_pages X-Git-Tag: 2.1b_release~9509 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6f5a55f1a6c5abee15a0e878e5c74d9f1569b8b0;p=platform%2Fkernel%2Fkernel-mfld-blackbay.git Fix potential crash with sys_move_pages 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 Acked-and-tested-by: Brice Goglin Acked-by: Hugh Dickins Cc: stable@kernel.org Signed-off-by: Linus Torvalds --- diff --git a/mm/migrate.c b/mm/migrate.c index efddbf0..9a0db5b 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -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;