All of lore.kernel.org
 help / color / mirror / Atom feed
From: Insu Yun <wuninsu@gmail.com>
To: konrad.wilk@oracle.com, boris.ostrovsky@oracle.com,
	david.vrabel@citrix.com, Jennifer.Herbert@citrix.com,
	xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org
Cc: taesoo@gatech.edu, yeongjin.jang@gatech.edu, insu@gatech.edu,
	changwoo@gatech.edu, Insu Yun <wuninsu@gmail.com>
Subject: [PATCH] xen: fix potential integer overflow in queue_reply
Date: Mon, 18 Jan 2016 11:29:07 -0500	[thread overview]
Message-ID: <1453134547-13875-1-git-send-email-wuninsu@gmail.com> (raw)

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>
---
 drivers/xen/xenbus/xenbus_dev_frontend.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/xen/xenbus/xenbus_dev_frontend.c b/drivers/xen/xenbus/xenbus_dev_frontend.c
index 9433e46..b45ed69 100644
--- a/drivers/xen/xenbus/xenbus_dev_frontend.c
+++ b/drivers/xen/xenbus/xenbus_dev_frontend.c
@@ -186,7 +186,7 @@ static int queue_reply(struct list_head *queue, const void *data, size_t len)
 {
 	struct read_buffer *rb;
 
-	if (len == 0)
+	if (len == 0 || len >= UINT_MAX - sizeof(*rb))
 		return 0;
 
 	rb = kmalloc(sizeof(*rb) + len, GFP_KERNEL);
-- 
1.9.1

             reply	other threads:[~2016-01-18 16:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-18 16:29 Insu Yun [this message]
2016-01-18 16:38 ` [PATCH] xen: fix potential integer overflow in queue_reply David Vrabel
2016-01-18 16:47   ` [Xen-devel] " David Vrabel
2016-01-18 16:47   ` David Vrabel
2016-01-18 16:38 ` David Vrabel
2016-01-18 16:29 Insu Yun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1453134547-13875-1-git-send-email-wuninsu@gmail.com \
    --to=wuninsu@gmail.com \
    --cc=Jennifer.Herbert@citrix.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=changwoo@gatech.edu \
    --cc=david.vrabel@citrix.com \
    --cc=insu@gatech.edu \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=taesoo@gatech.edu \
    --cc=xen-devel@lists.xenproject.org \
    --cc=yeongjin.jang@gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.