mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Haogang Chen <haogangchen@gmail.com>
To: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	Jeremy Fitzhardinge <jeremy@goop.org>,
	Ian Campbell <Ian.Campbell@citrix.com>
Cc: xen-devel@lists.xensource.com,
	virtualization@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org,
	Haogang Chen <haogangchen@gmail.com>
Subject: [PATCH] XEN: xenbus: integer overflow in process_msg()
Date: Tue,  3 Jan 2012 14:42:11 -0500	[thread overview]
Message-ID: <1325619731-13936-1-git-send-email-haogangchen@gmail.com> (raw)

There is a potential integer overflow in process_msg() that could result
in cross-domain attack.

	body = kmalloc(msg->hdr.len + 1, GFP_NOIO | __GFP_HIGH);

When a malicious guest passes 0xffffffff in msg->hdr.len, the subsequent
call to xb_read() would write to a zero-length buffer. This causes
kernel oops in the receiving guest and hangs its xenbus kernel thread.
The patch returns -EINVAL in that case.

Signed-off-by: Haogang Chen <haogangchen@gmail.com>
---
 drivers/xen/xenbus/xenbus_xs.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/drivers/xen/xenbus/xenbus_xs.c b/drivers/xen/xenbus/xenbus_xs.c
index ede860f..e32aefb 100644
--- a/drivers/xen/xenbus/xenbus_xs.c
+++ b/drivers/xen/xenbus/xenbus_xs.c
@@ -801,6 +801,12 @@ static int process_msg(void)
 		goto out;
 	}
 
+	if (msg->hdr.len == UINT_MAX) {
+		kfree(msg);
+		err = -EINVAL;
+		goto out;
+	}
+
 	body = kmalloc(msg->hdr.len + 1, GFP_NOIO | __GFP_HIGH);
 	if (body == NULL) {
 		kfree(msg);
-- 
1.7.5.4


             reply	other threads:[~2012-01-03 19:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-03 19:42 Haogang Chen [this message]
2012-01-04  9:24 ` Ian Campbell
2012-01-04  9:34   ` Ian Campbell
2012-01-04 11:39     ` [PATCH 0/2] xen: Miscelaneous xenbus cleanups Ian Campbell
2012-01-04 11:39       ` [PATCH 1/2] xenbus: maximum buffer size is XENSTORE_PAYLOAD_MAX Ian Campbell
2012-01-04 11:39       ` [PATCH 2/2] xen/xenbus: don't reimplement kvasprintf via a fixed size buffer Ian Campbell
2012-01-04 11:58         ` [Xen-devel] " Jan Beulich
2012-01-04 15:12           ` Konrad Rzeszutek Wilk

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=1325619731-13936-1-git-send-email-haogangchen@gmail.com \
    --to=haogangchen@gmail.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=jeremy@goop.org \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=xen-devel@lists.xensource.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®