浏览代码

xen-gntalloc: integer overflow in gntalloc_ioctl_alloc()

On 32 bit systems a high value of op.count could lead to an integer
overflow in the kzalloc() and gref_ids would be smaller than
expected.  If the you triggered another integer overflow in
"if (gref_size + op.count > limit)" then you'd probably get memory
corruption inside add_grefs().

CC: stable@kernel.org
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Dan Carpenter 13 年之前
父节点
当前提交
21643e69a4
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      drivers/xen/gntalloc.c

+ 1 - 1
drivers/xen/gntalloc.c

@@ -280,7 +280,7 @@ static long gntalloc_ioctl_alloc(struct gntalloc_file_private_data *priv,
 		goto out;
 		goto out;
 	}
 	}
 
 
-	gref_ids = kzalloc(sizeof(gref_ids[0]) * op.count, GFP_TEMPORARY);
+	gref_ids = kcalloc(op.count, sizeof(gref_ids[0]), GFP_TEMPORARY);
 	if (!gref_ids) {
 	if (!gref_ids) {
 		rc = -ENOMEM;
 		rc = -ENOMEM;
 		goto out;
 		goto out;