xen-gntalloc: integer overflow in gntalloc_ioctl_alloc()
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 4 Nov 2011 18:24:08 +0000 (21:24 +0300)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Wed, 16 Nov 2011 17:13:47 +0000 (12:13 -0500)
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>
drivers/xen/gntalloc.c

index f6832f46aea4a4861368465321cc8423f997cdfc..23c60cf4313ed26095bb2e0e93bab5064fb22b11 100644 (file)
@@ -280,7 +280,7 @@ static long gntalloc_ioctl_alloc(struct gntalloc_file_private_data *priv,
                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) {
                rc = -ENOMEM;
                goto out;