]> git.karo-electronics.de Git - linux-beck.git/commitdiff
xen: fix potential integer overflow in queue_reply
authorInsu Yun <wuninsu@gmail.com>
Mon, 18 Jan 2016 16:54:43 +0000 (11:54 -0500)
committerDavid Vrabel <david.vrabel@citrix.com>
Mon, 15 Feb 2016 13:56:57 +0000 (13:56 +0000)
When len is greater than UINT_MAX - sizeof(*rb), in next allocation,
it can overflow integer range and allocates small size of heap.
After that, memcpy will overflow the allocated heap.
Therefore, it needs to check the size of given length.

Signed-off-by: Insu Yun <wuninsu@gmail.com>
Signed-off-by: David Vrabel <david.vrabel@citrix.com>
drivers/xen/xenbus/xenbus_dev_frontend.c

index 9433e46518c8dc8680fd1e5a44d823aa7f65fdb0..912b64edb42b4a016201b4e7d1a695ca25056610 100644 (file)
@@ -188,6 +188,8 @@ static int queue_reply(struct list_head *queue, const void *data, size_t len)
 
        if (len == 0)
                return 0;
+       if (len > XENSTORE_PAYLOAD_MAX)
+               return -EINVAL;
 
        rb = kmalloc(sizeof(*rb) + len, GFP_KERNEL);
        if (rb == NULL)