Skip to contentSkip to conversation

xen: fix potential integer overflow in queue_reply

PATCH Superseded Insu Yun 1 participant 1 message Jan 18, 2016 Xen hypervisor interface

lore
Share & tools
lore

Insu Yun

author
#0 lore raw

PATCH v2 1/1 xen: fix potential integer overflow in queue_reply

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.

---
 drivers/xen/xenbus/xenbus_dev_frontend.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/xen/xenbus/xenbus_dev_frontend.c +2 -0
index 9433e46..912b64e 100644
@@ -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)
Signature · 1 line
1.9.1