浏览代码

[PATCH] sys_mbind sanity checking

Make sure maxnodes is safe size before calculating nlongs in
get_nodes().

Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Chris Wright 19 年之前
父节点
当前提交
636f13c174
共有 1 个文件被更改,包括 2 次插入0 次删除
  1. 2 0
      mm/mempolicy.c

+ 2 - 0
mm/mempolicy.c

@@ -808,6 +808,8 @@ static int get_nodes(nodemask_t *nodes, const unsigned long __user *nmask,
 	nodes_clear(*nodes);
 	nodes_clear(*nodes);
 	if (maxnode == 0 || !nmask)
 	if (maxnode == 0 || !nmask)
 		return 0;
 		return 0;
+	if (maxnode > PAGE_SIZE)
+		return -EINVAL;
 
 
 	nlongs = BITS_TO_LONGS(maxnode);
 	nlongs = BITS_TO_LONGS(maxnode);
 	if ((maxnode % BITS_PER_LONG) == 0)
 	if ((maxnode % BITS_PER_LONG) == 0)