All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: linux-kernel@vger.kernel.org, Markus.Lidel@shadowconnect.com
Cc: kernel-janitors@vger.kernel.org
Subject: [patch] message/i2o: add sanity check
Date: Fri, 23 Jul 2010 11:47:06 +0000	[thread overview]
Message-ID: <20100723114706.GH26313@bicker> (raw)

We use "reply_size" to determine the size of the "reply" buffer.  These
days the "reply" buffer is just some context information, an error code,
and a bunch of zeroes.  We stopped using it for useful information four
years ago in dcceafe25a5f47 "[PATCH] I2O: Bugfixes"

This patch ensures that "reply" is large enough to hold the context
information.   In the current code if "reply_size" is zero that would
cause memory corruption when we save the error code:
	reply[4] = ((u32) rcode) << 24;

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/drivers/message/i2o/i2o_config.c b/drivers/message/i2o/i2o_config.c
index c4b117f..8b1d55e 100644
--- a/drivers/message/i2o/i2o_config.c
+++ b/drivers/message/i2o/i2o_config.c
@@ -817,6 +817,11 @@ static int i2o_cfg_passthru(unsigned long arg)
 	reply_size >>= 16;
 	reply_size <<= 2;
 
+	if (reply_size < 5 * sizeof(u32)) {
+		rcode = -EINVAL;
+		goto out;
+	}
+
 	reply = kzalloc(reply_size, GFP_KERNEL);
 	if (!reply) {
 		printk(KERN_WARNING "%s: Could not allocate reply buffer\n",

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <error27@gmail.com>
To: linux-kernel@vger.kernel.org, Markus.Lidel@shadowconnect.com
Cc: kernel-janitors@vger.kernel.org
Subject: [patch] message/i2o: add sanity check
Date: Fri, 23 Jul 2010 13:47:06 +0200	[thread overview]
Message-ID: <20100723114706.GH26313@bicker> (raw)

We use "reply_size" to determine the size of the "reply" buffer.  These
days the "reply" buffer is just some context information, an error code,
and a bunch of zeroes.  We stopped using it for useful information four
years ago in dcceafe25a5f47 "[PATCH] I2O: Bugfixes"

This patch ensures that "reply" is large enough to hold the context
information.   In the current code if "reply_size" is zero that would
cause memory corruption when we save the error code:
	reply[4] = ((u32) rcode) << 24;

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/drivers/message/i2o/i2o_config.c b/drivers/message/i2o/i2o_config.c
index c4b117f..8b1d55e 100644
--- a/drivers/message/i2o/i2o_config.c
+++ b/drivers/message/i2o/i2o_config.c
@@ -817,6 +817,11 @@ static int i2o_cfg_passthru(unsigned long arg)
 	reply_size >>= 16;
 	reply_size <<= 2;
 
+	if (reply_size < 5 * sizeof(u32)) {
+		rcode = -EINVAL;
+		goto out;
+	}
+
 	reply = kzalloc(reply_size, GFP_KERNEL);
 	if (!reply) {
 		printk(KERN_WARNING "%s: Could not allocate reply buffer\n",

             reply	other threads:[~2010-07-23 11:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-23 11:47 Dan Carpenter [this message]
2010-07-23 11:47 ` [patch] message/i2o: add sanity check Dan Carpenter

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=20100723114706.GH26313@bicker \
    --to=error27@gmail.com \
    --cc=Markus.Lidel@shadowconnect.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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.