浏览代码

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 <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>
Linus Torvalds 15 年之前
父节点
当前提交
6f5a55f1a6
共有 1 个文件被更改,包括 3 次插入0 次删除
  1. 3 0
      mm/migrate.c

+ 3 - 0
mm/migrate.c

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